Skip to content

Commit

Permalink
Implement phases section
Browse files Browse the repository at this point in the history
  • Loading branch information
leynier committed Jul 7, 2020
1 parent a63b768 commit b1e4bc8
Show file tree
Hide file tree
Showing 24 changed files with 789 additions and 8 deletions.
Binary file added assets/images/medical_services.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/stair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions lib/src/blocs/general_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import 'package:covid19cuba/src/models/faqs/faqs_state.dart';
import 'package:covid19cuba/src/models/model.dart';
import 'package:covid19cuba/src/models/news/news.dart';
import 'package:covid19cuba/src/models/news/news_state.dart';
import 'package:covid19cuba/src/models/phases/phases.dart';
import 'package:covid19cuba/src/models/phases/phases_state.dart';
import 'package:covid19cuba/src/models/protocols/protocols.dart';
import 'package:covid19cuba/src/models/protocols/protocols_state.dart';
import 'package:covid19cuba/src/models/tips/tips.dart';
Expand Down Expand Up @@ -77,6 +79,12 @@ class GeneralBloc<T extends Model, E extends CacheModel>
);
}

static GeneralBloc<Phases, PhasesState> getPhasesBloc() {
return GeneralBloc<Phases, PhasesState>(
provider: PhasesProvider(),
);
}

static GeneralBloc<Protocols, ProtocolsState> getProtocolsBloc() {
return GeneralBloc<Protocols, ProtocolsState>(
provider: ProtocolsProvider(),
Expand Down
1 change: 1 addition & 0 deletions lib/src/data_providers/data_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export 'state_provider.dart';
export 'about_us_provider.dart';
export 'faqs_provider.dart';
export 'bulletins_provider.dart';
export 'phases_provider.dart';
export 'data_provider.dart';
export 'tips_provider.dart';
40 changes: 40 additions & 0 deletions lib/src/data_providers/phases_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (C) 2020 covid19cuba
// Use of this source code is governed by a GNU GPL 3 license that can be
// found in the LICENSE file.

import 'package:covid19cuba/src/data_providers/data_providers.dart';
import 'package:covid19cuba/src/models/phases/phases.dart';
import 'package:covid19cuba/src/models/phases/phases_state.dart';
import 'package:covid19cuba/src/utils/utils.dart';

class PhasesProvider extends DataProvider<Phases, PhasesState> {
@override
String get urlDataCU =>
'https://cusobu.nat.cu/covid/api/v2/phases.json';

@override
String get urlDataIO =>
'https://covid19cuba.github.io/covid19cubadata.github.io/api/v2/phases.json';

@override
String get urlDataStateCU =>
'https://cusobu.nat.cu/covid/api/v2/phases_state.json';

@override
String get urlDataStateIO =>
'https://covid19cuba.github.io/covid19cubadata.github.io/api/v2/phases_state.json';

@override
String get prefData => Constants.prefPhases;

@override
String get prefHash => Constants.prefPhasesState;

@override
Phases dataFromJson(Map<String, dynamic> data) =>
Phases.fromJson(data);

@override
PhasesState dataStateFromJson(Map<String, dynamic> data) =>
PhasesState.fromJson(data);
}
24 changes: 24 additions & 0 deletions lib/src/models/phases/phases.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2020 covid19cuba
// Use of this source code is governed by a GNU GPL 3 license that can be
// found in the LICENSE file.

import 'package:covid19cuba/src/models/model.dart';
import 'package:covid19cuba/src/models/phases/phases_category.dart';
import 'package:covid19cuba/src/models/phases/phases_item.dart';
import 'package:covid19cuba/src/models/phases/phases_measure.dart';
import 'package:json_annotation/json_annotation.dart';

part 'phases.g.dart';

@JsonSerializable()
class Phases extends Model {
List<PhasesItem> phases;
Map<String, PhasesCategory> categories;
Map<String, PhasesMeasure> measures;

Phases();

factory Phases.fromJson(Map<String, dynamic> json) => _$PhasesFromJson(json);

Map<String, dynamic> toJson() => _$PhasesToJson(this);
}
32 changes: 32 additions & 0 deletions lib/src/models/phases/phases.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions lib/src/models/phases/phases_category.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2020 covid19cuba
// Use of this source code is governed by a GNU GPL 3 license that can be
// found in the LICENSE file.

import 'package:json_annotation/json_annotation.dart';

part 'phases_category.g.dart';

@JsonSerializable()
class PhasesCategory {
String name;
@JsonKey(required: false)
String parent;

PhasesCategory();

factory PhasesCategory.fromJson(Map<String, dynamic> json) =>
_$PhasesCategoryFromJson(json);

Map<String, dynamic> toJson() => _$PhasesCategoryToJson(this);
}
19 changes: 19 additions & 0 deletions lib/src/models/phases/phases_category.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions lib/src/models/phases/phases_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) 2020 covid19cuba
// Use of this source code is governed by a GNU GPL 3 license that can be
// found in the LICENSE file.

import 'package:json_annotation/json_annotation.dart';

part 'phases_item.g.dart';

@JsonSerializable()
class PhasesItem {
int order;
String name;
List<String> provinces;
List<String> measures;

PhasesItem();

factory PhasesItem.fromJson(Map<String, dynamic> json) =>
_$PhasesItemFromJson(json);

Map<String, dynamic> toJson() => _$PhasesItemToJson(this);
}
23 changes: 23 additions & 0 deletions lib/src/models/phases/phases_item.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions lib/src/models/phases/phases_measure.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2020 covid19cuba
// Use of this source code is governed by a GNU GPL 3 license that can be
// found in the LICENSE file.

import 'package:json_annotation/json_annotation.dart';

part 'phases_measure.g.dart';

@JsonSerializable()
class PhasesMeasure {
String text;
String category;
List<int> phases;

PhasesMeasure();

factory PhasesMeasure.fromJson(Map<String, dynamic> json) =>
_$PhasesMeasureFromJson(json);

Map<String, dynamic> toJson() => _$PhasesMeasureToJson(this);
}
21 changes: 21 additions & 0 deletions lib/src/models/phases/phases_measure.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions lib/src/models/phases/phases_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2020 covid19cuba
// Use of this source code is governed by a GNU GPL 3 license that can be
// found in the LICENSE file.

import 'package:covid19cuba/src/models/model.dart';
import 'package:json_annotation/json_annotation.dart';

part 'phases_state.g.dart';

@JsonSerializable()
class PhasesState extends CacheModel {
PhasesState();

factory PhasesState.fromJson(Map<String, dynamic> json) =>
_$PhasesStateFromJson(json);

Map<String, dynamic> toJson() => _$PhasesStateToJson(this);
}
16 changes: 16 additions & 0 deletions lib/src/models/phases/phases_state.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/src/pages/notifications_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class NotificationSettingsState extends State<NotificationSettings> {
}

void showDialog({@required BuildContext context, bool start = true}) {
DateTime now = DateTime.now();
showTimePicker(
context: context,
initialTime:
Expand Down
1 change: 1 addition & 0 deletions lib/src/pages/pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export 'news_page_more.dart';
export 'municipality_item_page.dart';
export 'municipality_list_page.dart';
export 'on_boarding_page.dart';
export 'phases_page.dart';
export 'phone_details_page.dart';
export 'province_item_page.dart';
export 'province_list_page.dart';
Expand Down
Loading

0 comments on commit b1e4bc8

Please sign in to comment.