diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f22b79..12b0862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Covid19 Cuba Data Mobile Application Changelog +## [0.7.1] - May 4, 2020 + +### Added + +* Information button in top right of the charts. + +### Fixed + +* Links in update page. + ## [0.7.0] - May 3, 2020 ### Added diff --git a/lib/src/pages/update_page.dart b/lib/src/pages/update_page.dart index 68ff265..ef18b01 100644 --- a/lib/src/pages/update_page.dart +++ b/lib/src/pages/update_page.dart @@ -1,15 +1,15 @@ import 'dart:developer'; -import 'package:covid19cuba/src/data_providers/data_providers.dart'; -import 'package:covid19cuba/src/models/models.dart'; import 'package:getflutter/getflutter.dart'; import 'package:flutter/material.dart'; +import 'package:package_info/package_info.dart'; +import 'package:preferences/preference_service.dart'; +import 'package:covid19cuba/src/data_providers/data_providers.dart'; +import 'package:covid19cuba/src/models/models.dart'; import 'package:covid19cuba/src/pages/pages.dart'; import 'package:covid19cuba/src/utils/utils.dart'; import 'package:covid19cuba/src/widgets/widgets.dart'; -import 'package:package_info/package_info.dart'; -import 'package:preferences/preference_service.dart'; class UpdatePage extends StatefulWidget { final bool first; @@ -123,9 +123,8 @@ class UpdatePageState extends State { TouchableUrlImage( Constants.apklisBanner, () async { - var packageInfo = await PackageInfo.fromPlatform(); var apklisUrl = - 'https://archive.apklis.cu/application/apk/club.postdata.covid19cuba-v${packageInfo.buildNumber}.apk'; + 'https://www.apklis.cu/application/club.postdata.covid19cuba'; getUrl(apklisUrl); }, leftMargin: 50, @@ -152,9 +151,8 @@ class UpdatePageState extends State { TouchableUrlImage( Constants.githubBanner, () async { - var packageInfo = await PackageInfo.fromPlatform(); var gitHubUrl = - 'https://github.com/covid19cuba/covid19cuba-app/releases/download/v${packageInfo.version}/app.apk'; + 'https://github.com/covid19cuba/covid19cuba-app/releases'; getUrl(gitHubUrl); }, leftMargin: 50, diff --git a/lib/src/utils/notifications.dart b/lib/src/utils/notifications.dart index 15a7f4f..f3188de 100644 --- a/lib/src/utils/notifications.dart +++ b/lib/src/utils/notifications.dart @@ -3,6 +3,9 @@ import 'dart:developer'; import 'package:background_fetch/background_fetch.dart'; import 'package:demoji/demoji.dart'; import 'package:preferences/preferences.dart'; +import 'package:timezone/timezone.dart'; +import 'package:timezone/data/latest.dart' as tz; + import 'package:covid19cuba/src/models/models.dart'; import 'package:covid19cuba/src/utils/utils.dart'; @@ -90,7 +93,7 @@ Future showClaps() async { id: Constants.clapsNotification, title: 'Tiempo de aplausos!!!!!' + claps, body: - 'Ya casi son las 9 de la noche. Súmate a los aplausos por quienes trabajan por la salud y seguridad de todos. \n' + + 'Ya casi es la hora de los aplausos. Súmate al agradecimiento para quienes trabajan por la salud y seguridad de todos. \n' + claps + claps, ); @@ -103,7 +106,10 @@ bool timeToShowNotifications() { } bool clapsTime() { - DateTime date = DateTime.now(); + tz.initializeTimeZones(); + final havana = getLocation('America/Havana'); + final havanaTime = new TZDateTime.now(havana); + DateTime date = havanaTime; return date.hour >= Constants.startClapsHour && date.minute >= Constants.startClapsMinute && diff --git a/lib/src/widgets/comparison_widget.dart b/lib/src/widgets/comparison_widget.dart index 1161f61..ab1e016 100644 --- a/lib/src/widgets/comparison_widget.dart +++ b/lib/src/widgets/comparison_widget.dart @@ -1,16 +1,14 @@ import 'dart:math'; -import 'dart:developer' as dev; import 'package:charts_flutter/flutter.dart' as charts; import 'package:country_pickers/country.dart'; import 'package:country_pickers/country_pickers.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_linkify/flutter_linkify.dart'; import 'package:preferences/preferences.dart'; -import 'package:url_launcher/url_launcher.dart'; -import 'package:covid19cuba/src/utils/utils.dart'; import 'package:covid19cuba/src/models/models.dart'; +import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class ComparisonWidget extends StatefulWidget { final ComparisonOfAccumulatedCases comparisonOfAccumulatedCases; @@ -325,16 +323,27 @@ class ComparisonWidgetState extends State { children: [ Container( margin: EdgeInsets.only(left: 20, right: 20, top: 20), - child: Center( - child: Text( - 'Comparación de Cuba', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Comparación de Cuba', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), + InfoDialogWidget( + title: 'Comparación de Cuba', + text: getFooter(), + ) + ], ), ), Container( @@ -484,36 +493,6 @@ class ComparisonWidgetState extends State { ), ), ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - bottom: 20, - ), - child: Center( - child: Linkify( - text: getFooter(), - options: LinkifyOptions(humanize: true), - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - linkStyle: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - onOpen: (link) async { - if (await canLaunch(link.url)) { - await launch(link.url); - } else { - dev.log('Could not launch $link'); - } - }, - ), - ), - ), ], ); } diff --git a/lib/src/widgets/curves_evolution.dart b/lib/src/widgets/curves_evolution.dart index 581c014..f6590ff 100644 --- a/lib/src/widgets/curves_evolution.dart +++ b/lib/src/widgets/curves_evolution.dart @@ -1,15 +1,13 @@ import 'dart:math'; -import 'dart:developer' as dev; import 'package:charts_flutter/flutter.dart' as charts; import 'package:flutter/material.dart'; -import 'package:flutter_linkify/flutter_linkify.dart'; import 'package:getflutter/getflutter.dart'; import 'package:random_color/random_color.dart'; import 'package:searchable_dropdown/searchable_dropdown.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class CurvesEvolutionWidget extends StatefulWidget { final Map curvesEvolution; @@ -77,39 +75,37 @@ class CurvesEvolutionWidgetState extends State { right: 20, top: 20, ), - child: Center( - child: Text( - 'Evolución de la epidemia (paises seleccionados)', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Evolución de la epidemia (paises seleccionados)', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), - ), - ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - ), - child: Center( - child: Text( - 'El gráfico muestra a partir de 30 casos, en escala logarítmica ' - 'y agrupados cada siete días, los casos nuevos por el total ' - 'de casos confirmados de cada país. De esta manera, los países ' - 'mientras siguen una línea recta están en un crecimiento ' - 'exponencial y cuando se desvían de la recta comienzan a salir ' - 'del comportamiento exponencial.', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.normal, - fontSize: 12, - ), - ), + InfoDialogWidget( + title: 'Evolución de la epidemia (paises seleccionados)', + text: 'El gráfico muestra a partir de 30 casos, en escala ' + 'logarítmica y agrupados cada siete días, los casos ' + 'nuevos por el total de casos confirmados de cada país. ' + 'De esta manera, los países mientras siguen una línea ' + 'recta están en un crecimiento exponencial y cuando ' + 'se desvían de la recta comienzan a salir ' + 'del comportamiento exponencial.\n\n' + 'Datos de los países tomados ' + 'de\nhttps://github.com/pomber/covid19\ny ' + 'actualizado el ' + '${updated.toStrPlus()}', + ) + ], ), ), Container( @@ -232,6 +228,7 @@ class CurvesEvolutionWidgetState extends State { left: 20, right: 20, top: 20, + bottom: 20, ), child: GFButton( text: 'Seleccionar países iniciales', @@ -255,39 +252,6 @@ class CurvesEvolutionWidgetState extends State { }, ), ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - bottom: 20, - ), - child: Center( - child: Linkify( - text: 'Datos de los países tomados ' - 'de\nhttps://github.com/pomber/covid19\ny ' - 'actualizado el ' - '${updated.toStrPlus()}', - options: LinkifyOptions(humanize: true), - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - linkStyle: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - onOpen: (link) async { - if (await canLaunch(link.url)) { - await launch(link.url); - } else { - dev.log('Could not launch $link'); - } - }, - ), - ), - ), ], ); } diff --git a/lib/src/widgets/distribution_age_groups_diagnosed_widget.dart b/lib/src/widgets/distribution_age_groups_diagnosed_widget.dart index 04d0f84..23860d1 100644 --- a/lib/src/widgets/distribution_age_groups_diagnosed_widget.dart +++ b/lib/src/widgets/distribution_age_groups_diagnosed_widget.dart @@ -1,12 +1,9 @@ -import 'dart:developer'; - import 'package:charts_flutter/flutter.dart' as charts; import 'package:flutter/material.dart'; -import 'package:flutter_linkify/flutter_linkify.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'package:covid19cuba/src/models/models.dart'; import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class DistributionAgeGroupsDiagnosedWidget extends StatelessWidget { final List distributionByAgeRanges; @@ -24,16 +21,28 @@ class DistributionAgeGroupsDiagnosedWidget extends StatelessWidget { right: 20, top: 20, ), - child: Center( - child: Text( - 'Distribución por rangos etarios', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Distribución por rangos etarios', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), + InfoDialogWidget( + title: 'Distribución por rangos etarios', + text: '${distributionByAgeRanges.last.name} ' + 'representa edad desconocida', + ) + ], ), ), Container( @@ -84,35 +93,8 @@ class DistributionAgeGroupsDiagnosedWidget extends StatelessWidget { ], ), ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - bottom: 20, - ), - child: Center( - child: Linkify( - text: - '${distributionByAgeRanges.last.name} representa edad desconocida', - options: LinkifyOptions(humanize: true), - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - linkStyle: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - onOpen: (link) async { - if (await canLaunch(link.url)) { - await launch(link.url); - } else { - log('Could not launch $link'); - } - }, - ), - ), + SizedBox( + height: 5, ) ], ); diff --git a/lib/src/widgets/distribution_nationality_diagnosed_widget.dart b/lib/src/widgets/distribution_nationality_diagnosed_widget.dart index 7c2ff6f..8e936f2 100644 --- a/lib/src/widgets/distribution_nationality_diagnosed_widget.dart +++ b/lib/src/widgets/distribution_nationality_diagnosed_widget.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:covid19cuba/src/models/models.dart'; import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class DistributionNationalityDiagnosedWidget extends StatelessWidget { final List distributionByNationalityOfForeignCases; @@ -17,6 +18,12 @@ class DistributionNationalityDiagnosedWidget extends StatelessWidget { distributionByNationalityOfForeignCases.length == 0) { return Container(); } + String dialogText = ''; + for (var item in distributionByNationalityOfForeignCases) { + print(item.code + ' = ' + item.name); + dialogText += '\n' + item.code + ' = ' + item.name; + } + return Column( children: [ Container( @@ -25,16 +32,27 @@ class DistributionNationalityDiagnosedWidget extends StatelessWidget { right: 20, top: 20, ), - child: Center( - child: Text( - 'Distribución por nacionalidad de casos extranjeros', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Distribución por nacionalidad de casos extranjeros', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), + InfoDialogWidget( + title: 'Distribución por nacionalidad de casos extranjeros', + text: dialogText, + ) + ], ), ), Container( diff --git a/lib/src/widgets/effective_reproductive_number_widget.dart b/lib/src/widgets/effective_reproductive_number_widget.dart index 9836f17..afc5a3f 100644 --- a/lib/src/widgets/effective_reproductive_number_widget.dart +++ b/lib/src/widgets/effective_reproductive_number_widget.dart @@ -1,15 +1,13 @@ -import 'dart:developer'; - import 'package:charts_flutter/flutter.dart' as charts; import 'package:flutter/material.dart'; -import 'package:flutter_linkify/flutter_linkify.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'package:covid19cuba/src/models/models.dart'; import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class EffectiveReproductiveNumberWidget extends StatelessWidget { final EffectiveReproductiveNumber effectiveReproductiveNumber; + static String title = 'Número Reproductivo Efectivo'; const EffectiveReproductiveNumberWidget({this.effectiveReproductiveNumber}) : assert(effectiveReproductiveNumber != null); @@ -24,16 +22,34 @@ class EffectiveReproductiveNumberWidget extends StatelessWidget { right: 20, top: 20, ), - child: Center( - child: Text( - 'Número Reproductivo Efectivo', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + title, + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), + InfoDialogWidget( + title: title, + text: '$title\n' + 'https://en.wikipedia.org/wiki/basic_reproduction_number\n' + 'se cálcula en base al método propuesto por Anne Cori\n' + 'https://cran.r-project.org/package=EpiEstim\n\n' + 'Es una colaboración del Investigador Waldemar Baldoquín ' + 'del IPK y se actualizará periódicamente en base a sus ' + 'cálculos. Los márgenes refieren al rango con 95% de ' + 'confianza.', + ) + ], ), ), Container( @@ -78,7 +94,7 @@ class EffectiveReproductiveNumberWidget extends StatelessWidget { charts.OutsideJustification.middleDrawArea, ), charts.ChartTitle( - 'Número Reproductivo Efectivo', + title, behaviorPosition: charts.BehaviorPosition.start, titleStyleSpec: charts.TextStyleSpec(fontSize: 11), titleOutsideJustification: @@ -105,43 +121,6 @@ class EffectiveReproductiveNumberWidget extends StatelessWidget { ], ), ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - bottom: 20, - ), - child: Center( - child: Linkify( - text: 'El Número Reproductivo Efectivo\n' - 'https://en.wikipedia.org/wiki/basic_reproduction_number\n' - 'se cálcula en base al método propuesto por Anne Cori\n' - 'https://cran.r-project.org/package=EpiEstim\n\n' - 'Es una colaboración del Investigador Waldemar Baldoquín ' - 'del IPK y se actualizará periódicamente en base a sus ' - 'cálculos. Los márgenes refieren al rango con 95% de ' - 'confianza.', - options: LinkifyOptions(humanize: true), - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - linkStyle: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - onOpen: (link) async { - if (await canLaunch(link.url)) { - await launch(link.url); - } else { - log('Could not launch $link'); - } - }, - ), - ), - ), ], ); } diff --git a/lib/src/widgets/info_dialog_widget.dart b/lib/src/widgets/info_dialog_widget.dart new file mode 100644 index 0000000..ff5cc42 --- /dev/null +++ b/lib/src/widgets/info_dialog_widget.dart @@ -0,0 +1,64 @@ +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:flutter_linkify/flutter_linkify.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import 'package:covid19cuba/src/utils/utils.dart'; + +class InfoDialogWidget extends StatelessWidget { + final String title; + final String text; + + InfoDialogWidget({this.title, this.text}); + + @override + Widget build(BuildContext context) { + return GestureDetector( + child: Icon(Icons.info), + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text(title), + content: Container( + margin: EdgeInsets.only( + top: 10, + bottom: 10, + ), + child: Linkify( + text: text, + options: LinkifyOptions(humanize: true), + textAlign: TextAlign.left, + style: TextStyle( + color: Constants.primaryColor, + fontSize: 14, + ), + linkStyle: TextStyle( + color: Colors.red, + fontSize: 14, + ), + onOpen: (link) async { + if (await canLaunch(link.url)) { + await launch(link.url); + } else { + log('Could not launch $link'); + } + }, + ), + ), + actions: [ + FlatButton( + child: Text('Cerrar'), + onPressed: () { + Navigator.pop(context); + }), + ], + ); + }, + ); + }, + ); + } +} diff --git a/lib/src/widgets/map_widget.dart b/lib/src/widgets/map_widget.dart index 89d8459..760e391 100644 --- a/lib/src/widgets/map_widget.dart +++ b/lib/src/widgets/map_widget.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class WebViewKeepAlive extends StatefulWidget { final Map mapData; @@ -103,16 +104,29 @@ class MapWebViewWidgetState extends State { children: [ Container( margin: EdgeInsets.only(left: 20, right: 20, top: 20), - child: Center( - child: Text( - 'Distribución por Municipios', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Distribución por Municipios', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), + InfoDialogWidget( + title: 'Distribución por Provincias', + text: + 'El cuadrado representa aquellos que por distintas razones ' + 'no tengan localización conocida.', + ) + ], ), ), WebViewKeepAlive( @@ -161,16 +175,29 @@ class MapWebViewWidgetState extends State { ), Container( margin: EdgeInsets.only(left: 20, right: 20, top: 20), - child: Center( - child: Text( - 'Distribución por Provincias', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Distribución por Provincias', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), + InfoDialogWidget( + title: 'Distribución por Provincias', + text: + 'El cuadrado representa aquellos que por distintas razones ' + 'no tengan localización conocida.', + ) + ], ), ), WebViewKeepAlive( @@ -178,20 +205,7 @@ class MapWebViewWidgetState extends State { eventsData: widget.eventsData, jsCommand: Constants.showProvinces, ), - Container( - margin: EdgeInsets.only(left: 20, right: 20, top: 20, bottom: 20), - child: Center( - child: Text( - 'El cuadrado representa aquellos que por distintas razones ' - 'no tengan localización conocida.', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 10, - ), - ), - ), - ), + Container(height: 20), ], ); } diff --git a/lib/src/widgets/stringency_index_cuba_widget.dart b/lib/src/widgets/stringency_index_cuba_widget.dart index e234c61..5dbcadf 100644 --- a/lib/src/widgets/stringency_index_cuba_widget.dart +++ b/lib/src/widgets/stringency_index_cuba_widget.dart @@ -1,13 +1,10 @@ -import 'dart:developer'; - import 'package:charts_flutter/flutter.dart' as charts; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:covid19cuba/src/utils/utils.dart'; import 'package:covid19cuba/src/models/models.dart'; -import 'package:flutter_linkify/flutter_linkify.dart'; -import 'package:url_launcher/url_launcher.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class StringencyIndexCubaWidget extends StatelessWidget { final StringencyIndexCubaModel stringencyIndexCuba; @@ -26,33 +23,36 @@ class StringencyIndexCubaWidget extends StatelessWidget { right: 20, top: 20, ), - child: Center( - child: Text( - 'Evolución del Oxford Stringency Index para Cuba', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Evolución del Oxford Stringency Index para Cuba', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), - ), - ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - ), - child: Text( - 'El índice fue revisado y actualizado por Oxford y se ' - 'incorporaron nuevos criterios. Por tanto, en la gráfica ' - 'se mostrarán los valores de la versión actual (v2) y de ' - 'la versión previa (v1)', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - ), + InfoDialogWidget( + title: 'Oxford Stringency Index', + text: 'El Oxford Stringency Index\n' + 'https://www.bsg.ox.ac.uk/research/research-projects/' + 'coronavirus-government-response-tracker\nevalúa las ' + 'intervenciones del estado en la epidemia.\nLos valores ' + 'se obtienen de\nhttps://covidtracker.' + 'bsg.ox.ac.uk/about-api\n\n\n' + 'El índice fue revisado y actualizado por Oxford y se ' + 'incorporaron nuevos criterios. Por tanto, en la gráfica ' + 'se mostrarán los valores de la versión actual (v2) y de ' + 'la versión previa (v1)', + ), + ], ), ), Container( @@ -154,41 +154,6 @@ class StringencyIndexCubaWidget extends StatelessWidget { ], ), ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - bottom: 20, - ), - child: Center( - child: Linkify( - text: 'El Oxford Stringency Index\n' - 'https://www.bsg.ox.ac.uk/research/research-projects/' - 'coronavirus-government-response-tracker\nevalúa las ' - 'intervenciones del estado en la epidemia.\nLos valores ' - 'se obtienen de\nhttps://covidtracker.' - 'bsg.ox.ac.uk/about-api', - options: LinkifyOptions(humanize: true), - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - linkStyle: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - onOpen: (link) async { - if (await canLaunch(link.url)) { - await launch(link.url); - } else { - log('Could not launch $link'); - } - }, - ), - ), - ), ], ); } diff --git a/lib/src/widgets/test_behavior_comparison_widget.dart b/lib/src/widgets/test_behavior_comparison_widget.dart index ddd234c..da2fc50 100644 --- a/lib/src/widgets/test_behavior_comparison_widget.dart +++ b/lib/src/widgets/test_behavior_comparison_widget.dart @@ -1,15 +1,12 @@ -import 'dart:developer' as dev; - import 'package:charts_flutter/flutter.dart' as charts; import 'package:flutter/material.dart'; -import 'package:flutter_linkify/flutter_linkify.dart'; import 'package:getflutter/getflutter.dart'; import 'package:random_color/random_color.dart'; import 'package:searchable_dropdown/searchable_dropdown.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'package:covid19cuba/src/models/models.dart'; import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class TestBehaviorComparisonWidget extends StatefulWidget { final Map testBehaviorComparison; @@ -76,37 +73,36 @@ class TestBehaviorComparisonWidgetState right: 20, top: 20, ), - child: Center( - child: Text( - 'Comparación respecto al comportamiento de los Tests realizados', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Comparación respecto al comportamiento de los Tests ' + 'realizados', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), - ), - ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - ), - child: Center( - child: Text( - 'El gráfico permite comparar a Cuba con distintos paises ' - 'respecto, a la vez, el porciento de detección de contagiados ' - 'en base al total de tests realizados y el número de tests ' - 'por millón de habitantes.', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.normal, - fontSize: 12, - ), - ), + InfoDialogWidget( + title: 'Comparación respecto al comportamiento de los Tests ' + 'realizados', + text: 'El gráfico permite comparar a Cuba con distintos paises ' + 'respecto, a la vez, el porciento de detección de ' + 'contagiados en base al total de tests realizados y el ' + 'número de tests por millón de habitantes.\n\n' + 'Datos de los países tomados de Our World in Data.\n' + 'https://covid.ourworldindata.org/data/owid-covid-data.csv\n' + 'Los datos de Cuba se calculan a partir de la propia ' + 'información que provee esta aplicación.', + ) + ], ), ), Container( @@ -200,6 +196,7 @@ class TestBehaviorComparisonWidgetState left: 20, right: 20, top: 20, + bottom: 20, ), child: GFButton( text: 'Seleccionar países iniciales', @@ -223,39 +220,6 @@ class TestBehaviorComparisonWidgetState }, ), ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - bottom: 20, - ), - child: Center( - child: Linkify( - text: 'Datos de los países tomados de Our World in Data.\n' - 'https://covid.ourworldindata.org/data/owid-covid-data.csv\n' - 'Los datos de Cuba se calculan a partir de la propia ' - 'información que provee esta aplicación.', - options: LinkifyOptions(humanize: true), - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - linkStyle: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - onOpen: (link) async { - if (await canLaunch(link.url)) { - await launch(link.url); - } else { - dev.log('Could not launch $link'); - } - }, - ), - ), - ), ], ); } diff --git a/lib/src/widgets/test_evolution_widget.dart b/lib/src/widgets/test_evolution_widget.dart index 6611328..3267686 100644 --- a/lib/src/widgets/test_evolution_widget.dart +++ b/lib/src/widgets/test_evolution_widget.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:covid19cuba/src/models/models.dart'; import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class TestEvolutionWidget extends StatelessWidget { final TestsByDays testsByDays; @@ -19,16 +20,28 @@ class TestEvolutionWidget extends StatelessWidget { right: 20, top: 20, ), - child: Center( - child: Text( - 'Tests (PCR) por días', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Tests (PCR) por días', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), + InfoDialogWidget( + title: 'Tests (PCR) por días', + text: 'Esta información se reporta desde el ' + '${testsByDays.date.values[0].toStrPlus()}', + ) + ], ), ), Container( @@ -89,25 +102,9 @@ class TestEvolutionWidget extends StatelessWidget { ], ), ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - bottom: 20, - ), - child: Center( - child: Text( - 'Esta información se reporta desde el ' - '${testsByDays.date.values[0].toStrPlus()}', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - ), - ), - ), + SizedBox( + height: 5, + ) ], ); } diff --git a/lib/src/widgets/tests_positive_percent_widget.dart b/lib/src/widgets/tests_positive_percent_widget.dart index d67d0f5..a74ac13 100644 --- a/lib/src/widgets/tests_positive_percent_widget.dart +++ b/lib/src/widgets/tests_positive_percent_widget.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:covid19cuba/src/utils/utils.dart'; import 'package:covid19cuba/src/models/models.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class TestsPositivePercentWidget extends StatelessWidget { final TestsPositivePercent testsPositivePercent; @@ -20,16 +21,28 @@ class TestsPositivePercentWidget extends StatelessWidget { right: 20, top: 20, ), - child: Center( - child: Text( - '% Tests Positivos con respecto a Total de Tests (PCR)', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + '% Tests Positivos con respecto a Total de Tests (PCR)', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), ), - ), + InfoDialogWidget( + title: '% Tests Positivos con respecto a Total de Tests (PCR)', + text: 'Esta información se reporta desde el ' + '${testsPositivePercent.date.values[0].toStrPlus()}', + ) + ], ), ), Container( @@ -86,25 +99,9 @@ class TestsPositivePercentWidget extends StatelessWidget { ], ), ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - bottom: 20, - ), - child: Center( - child: Text( - 'Esta información se reporta desde el ' - '${testsPositivePercent.date.values[0].toStrPlus()}', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - ), - ), - ), + SizedBox( + height: 5, + ) ], ); } diff --git a/lib/src/widgets/top_20_accumulated_countries_widget.dart b/lib/src/widgets/top_20_accumulated_countries_widget.dart index 4f40243..91e6735 100644 --- a/lib/src/widgets/top_20_accumulated_countries_widget.dart +++ b/lib/src/widgets/top_20_accumulated_countries_widget.dart @@ -1,11 +1,8 @@ -import 'dart:developer'; - import 'package:flutter/material.dart'; -import 'package:flutter_linkify/flutter_linkify.dart'; -import 'package:url_launcher/url_launcher.dart'; -import 'package:covid19cuba/src/utils/utils.dart'; import 'package:covid19cuba/src/models/models.dart'; +import 'package:covid19cuba/src/utils/utils.dart'; +import 'package:covid19cuba/src/widgets/widgets.dart'; class Top20CountriesWidget extends StatelessWidget { final List top20AccumulatedCountries; @@ -32,124 +29,54 @@ class Top20CountriesWidget extends StatelessWidget { var index = 0; return Column( children: [ - Table( - children: [ - TableRow( - children: [ - TableCell( - child: Container( - margin: EdgeInsets.all(15), - child: Center( - child: Text( - 'Top 20 de países con más casos acumulados', - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 18, - ), - ), - ), + Container( + margin: EdgeInsets.only( + left: 20, + right: 20, + top: 20, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Top 20 de países con más casos acumulados', + textAlign: TextAlign.center, + maxLines: 3, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 18, ), ), - ], - ), - ], + ), + InfoDialogWidget( + title: 'Top 20 de países con más casos acumulados', + text: 'Datos de los países tomados ' + 'de\nhttps://github.com/pomber/covid19\ny ' + 'actualizado el ' + '${updated.toStrPlus()}', + ) + ], + ), ), - Table( - columnWidths: col, - border: TableBorder(horizontalInside: borderSide), - children: [ - TableRow( - children: [ - TableCell( - child: Container( - margin: EdgeInsets.all(5), - child: Text( - '#', - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 11, - ), - ), - ), - ), - TableCell( - child: Container( - alignment: Alignment.centerLeft, - margin: EdgeInsets.all(5), - child: Text( - 'País', - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 11, - ), - ), - ), - ), - TableCell( - child: Container( - margin: EdgeInsets.all(5), - child: Center( - child: Text( - 'Casos', - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 11, - ), - ), - ), - ), - ), - TableCell( - child: Container( - margin: EdgeInsets.all(5), - child: Center( - child: Text( - 'Recuperados', - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 11, - ), - ), - ), - ), - ), - TableCell( - child: Container( - margin: EdgeInsets.all(5), - child: Center( - child: Text( - 'Fallecidos', - style: TextStyle( - color: Constants.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 11, - ), - ), - ), - ), - ), - ], - ) - ] + - top20AccumulatedCountries.map( - (item) { - index += 1; - return TableRow( + Container( + margin: EdgeInsets.only(bottom: 10), + child: Table( + columnWidths: col, + border: TableBorder(horizontalInside: borderSide), + children: [ + TableRow( children: [ TableCell( child: Container( margin: EdgeInsets.all(5), child: Text( - '$index', + '#', style: TextStyle( color: Constants.primaryColor, - fontWeight: FontWeight.normal, + fontWeight: FontWeight.bold, fontSize: 11, ), ), @@ -160,10 +87,10 @@ class Top20CountriesWidget extends StatelessWidget { alignment: Alignment.centerLeft, margin: EdgeInsets.all(5), child: Text( - item.name, + 'País', style: TextStyle( color: Constants.primaryColor, - fontWeight: FontWeight.normal, + fontWeight: FontWeight.bold, fontSize: 11, ), ), @@ -174,10 +101,10 @@ class Top20CountriesWidget extends StatelessWidget { margin: EdgeInsets.all(5), child: Center( child: Text( - '${item.confirmed}', + 'Casos', style: TextStyle( color: Constants.primaryColor, - fontWeight: FontWeight.normal, + fontWeight: FontWeight.bold, fontSize: 11, ), ), @@ -189,10 +116,10 @@ class Top20CountriesWidget extends StatelessWidget { margin: EdgeInsets.all(5), child: Center( child: Text( - '${item.recovered}', + 'Recuperados', style: TextStyle( color: Constants.primaryColor, - fontWeight: FontWeight.normal, + fontWeight: FontWeight.bold, fontSize: 11, ), ), @@ -204,10 +131,10 @@ class Top20CountriesWidget extends StatelessWidget { margin: EdgeInsets.all(5), child: Center( child: Text( - '${item.deaths}', + 'Fallecidos', style: TextStyle( color: Constants.primaryColor, - fontWeight: FontWeight.normal, + fontWeight: FontWeight.bold, fontSize: 11, ), ), @@ -215,41 +142,89 @@ class Top20CountriesWidget extends StatelessWidget { ), ), ], - ); - }, - ).toList(), - ), - Container( - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 20, - bottom: 20, - ), - child: Center( - child: Linkify( - text: 'Datos de los países tomados ' - 'de\nhttps://github.com/pomber/covid19\ny ' - 'actualizado el ' - '${updated.toStrPlus()}', - options: LinkifyOptions(humanize: true), - textAlign: TextAlign.center, - style: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - linkStyle: TextStyle( - color: Constants.primaryColor, - fontSize: 12, - ), - onOpen: (link) async { - if (await canLaunch(link.url)) { - await launch(link.url); - } else { - log('Could not launch $link'); - } - }, - ), + ) + ] + + top20AccumulatedCountries.map( + (item) { + index += 1; + return TableRow( + children: [ + TableCell( + child: Container( + margin: EdgeInsets.all(5), + child: Text( + '$index', + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.normal, + fontSize: 11, + ), + ), + ), + ), + TableCell( + child: Container( + alignment: Alignment.centerLeft, + margin: EdgeInsets.all(5), + child: Text( + item.name, + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.normal, + fontSize: 11, + ), + ), + ), + ), + TableCell( + child: Container( + margin: EdgeInsets.all(5), + child: Center( + child: Text( + '${item.confirmed}', + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.normal, + fontSize: 11, + ), + ), + ), + ), + ), + TableCell( + child: Container( + margin: EdgeInsets.all(5), + child: Center( + child: Text( + '${item.recovered}', + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.normal, + fontSize: 11, + ), + ), + ), + ), + ), + TableCell( + child: Container( + margin: EdgeInsets.all(5), + child: Center( + child: Text( + '${item.deaths}', + style: TextStyle( + color: Constants.primaryColor, + fontWeight: FontWeight.normal, + fontSize: 11, + ), + ), + ), + ), + ), + ], + ); + }, + ).toList(), ), ), ], diff --git a/lib/src/widgets/widgets.dart b/lib/src/widgets/widgets.dart index bc3907f..f654e00 100644 --- a/lib/src/widgets/widgets.dart +++ b/lib/src/widgets/widgets.dart @@ -11,6 +11,7 @@ export 'evolution_recovered_widget.dart'; export 'evolution_death_widget.dart'; export 'home_drawer_widget.dart'; export 'cuba_widget.dart'; +export 'info_dialog_widget.dart'; export 'loading_widget.dart'; export 'map_widget.dart'; export 'municipality_widget.dart'; diff --git a/pubspec.lock b/pubspec.lock index c30753f..c9bac20 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -653,6 +653,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + timezone: + dependency: "direct main" + description: + name: timezone + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.7" timing: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 70c9070..15b2366 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: covid19cuba description: Mobile application of Covid19 Cuba Data project implemented with Flutter. -version: 0.7.0+11 +version: 0.7.1+12 environment: sdk: ">=2.6.0 <3.0.0" @@ -35,6 +35,7 @@ dependencies: country_pickers: ^1.2.1 flutter_linkify: ^3.1.2 searchable_dropdown: ^1.1.3 + timezone: ^0.5.7 dev_dependencies: flutter_native_splash: ^0.1.9