From 5959670f80927b00aeeaf0824a668d8f71233748 Mon Sep 17 00:00:00 2001 From: "Vicente J. Ruiz Jurado" Date: Tue, 24 Jul 2018 15:11:00 +0200 Subject: [PATCH] Added fire notify and support page --- lib/fireAlert.dart | 56 ++++++++++++++++++++++++++++----------- lib/firesApp.dart | 4 ++- lib/generated/i18n.dart | 13 +++++++-- lib/mainDrawer.dart | 3 ++- lib/supportPage.dart | 48 +++++++++++++++++++++++++++++++++ res/values/strings_en.arb | 5 +++- res/values/strings_es.arb | 5 +++- 7 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 lib/supportPage.dart diff --git a/lib/fireAlert.dart b/lib/fireAlert.dart index 289c768..4f8952e 100644 --- a/lib/fireAlert.dart +++ b/lib/fireAlert.dart @@ -16,6 +16,7 @@ class FireAlert extends StatefulWidget { class _FireAlertState extends State { final GlobalKey _scaffoldKey = new GlobalKey(); + int _currentStep = 0; Widget buildCallButton() { return new Align( @@ -54,25 +55,50 @@ class _FireAlertState extends State { ); } + List listWithoutNulls(List children) => + children.where(notNull).toList(); + @override Widget build(BuildContext context) { + List fireSteps = listWithoutNulls([ + new Step( + title: new Text(S.of(context).callEmergencyServicesTitle), + // subtitle: + content: new Column(children: [ + new Text(S.of(context).callEmergencyServicesDescription), + new SizedBox(height: 20.0), + buildCallButton() + ])), + // TODO conditional: this only in Spain + new Step( + title: new Text(S.of(context).tweetAboutAFireTitle), + // subtitle: new Text(S.of(context).tweetAboutAFireDescription), + content: new Column(children: [ + new Text(S.of(context).tweetAboutAFireDescription), + new SizedBox(height: 20.0), + buildTweetButton() + ])), + ]); + final stepInc = () { + setState(() { + if (_currentStep < fireSteps.length - 1) { + _currentStep += 1; + } else { + _currentStep = 0; + } + }); + }; return Scaffold( key: _scaffoldKey, appBar: new AppBar(title: new Text(S.of(context).notifyAFire)), - body: new CenteredColumn( - children: [ - new Flexible( - child: new CenteredColumn( - children: [ - new Text(S.of(context).callEmergencyServicesDescription, - softWrap: true), - new Text(S.of(context).tweetAboutAFireDescription), - ], - ), - ), - buildCallButton(), - buildTweetButton() - ], - )); + body: new Stepper( + currentStep: _currentStep, + // type: StepperType.horizontal, + onStepTapped: (num) => setState(() { + _currentStep = num; + }), + onStepContinue: stepInc, + onStepCancel: stepInc, + steps: fireSteps)); } } diff --git a/lib/firesApp.dart b/lib/firesApp.dart index db84fc7..3410fe0 100644 --- a/lib/firesApp.dart +++ b/lib/firesApp.dart @@ -14,6 +14,7 @@ import 'sandbox.dart'; import 'theme.dart'; import 'privacyPage.dart'; import 'fireAlert.dart'; +import 'supportPage.dart'; class FiresApp extends StatelessWidget { static final WidgetBuilder introWidget = (context) => new IntroPage(); @@ -25,7 +26,8 @@ class FiresApp extends StatelessWidget { PrivacyPage.routeName: (BuildContext context) => new PrivacyPage(context), ActiveFiresPage.routeName: (BuildContext context) => new ActiveFiresPage(), Sandbox.routeName: (BuildContext context) => new Sandbox(), - FireAlert.routeName: (BuildContext context) => new FireAlert() + FireAlert.routeName: (BuildContext context) => new FireAlert(), + SupportPage.routeName: (BuildContext context) => new SupportPage(), }; final Store store; diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index 38cef4c..521b610 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -38,6 +38,7 @@ class S implements WidgetsLocalizations { String get anHour => "an hour"; String get appName => "All Against The Fire!"; String get callEmergencyServicesDescription => "You can call 112 if you have not already done so to notify the emergency services."; + String get callEmergencyServicesTitle => "Call 112"; String get chooseAPlace => "Choose a place"; String get chooseAWatchRadio => "Choose a watch radio"; String get confirm => "Confirm"; @@ -50,10 +51,12 @@ class S implements WidgetsLocalizations { String get notPermsUbication => "We don't have permission to get your location"; String get notifyAFire => "Notify a fire"; String get privacyPolicy => "Privacy Policy"; + String get supportPageDescription => "You can support this initiative, spreading the word, helping us to develop our software, translating this app to your language, etc."; String get supportThisInitiative => "Support this initiative"; String get toDeleteThisPlace => "Slide horizontally to delete this place"; String get toFiresNotifications => "Subscribe to fires notifications"; - String get tweetAboutAFireDescription => "Additionally if you use twitter you can notify them with additional information, for example, attaching photos to the tweet if you have good visibility of the fire, when you took the photos, exact location, etc. Use #hashtags type #IFMinicipalTerminal for example #IFJumilla (Forest Fire in Jumilla)."; + String get tweetAboutAFireDescription => "Additionally if you use twitter you can share additional information with the emergency services, for example, attaching photos to the tweet if you have good visibility of the fire, when you took the photos, exact location, etc. Use #hashtags type #IFMinicipalTerminal for example #IFJumilla (Forest Fire in Jumilla)."; + String get tweetAboutAFireTitle => "Tweet about"; String get typeTheNameOfAPlace => "Type the name of a place, region, etc"; String get unsubscribe => "Unsubscribe"; String get warningThisIsAVeryLargeArea => "Warning: this is a very large area"; @@ -98,7 +101,7 @@ class es extends S { @override String get toDeleteThisPlace => "Desliza horizontalmente para borrar este lugar"; @override - String get tweetAboutAFireDescription => "Adicionalmente si usas twitter puedes notificarles con información adicional, por ejemplo, adjuntando fotos al tweet si tienes buena visibilidad del fuego, cuando tomaste las fotos, ubicación exacta, etc. Usa #hashtags tipo #IFTerminoMunicipal por ejemplo #IFJumilla (Incendio Forestal en Jumilla)."; + String get tweetAboutAFireDescription => "Adicionalmente si usas twitter puedes compartir información adicional con los servicios de emergencia, por ejemplo, adjuntando fotos al tweet si tienes buena visibilidad del fuego, cuando tomaste las fotos, ubicación exacta, etc. Usa #hashtags tipo #IFTerminoMunicipal por ejemplo #IFJumilla (Incendio Forestal en Jumilla)."; @override String get AvoidThisStringsIfisNotPlural => "Zero One Two Few Many Other"; @override @@ -112,6 +115,8 @@ class es extends S { @override String get youDeletedThisPlace => "Has borrado este lugar"; @override + String get callEmergencyServicesTitle => "Llama al 112"; + @override String get chooseAPlace => "Elige un lugar"; @override String get firesNearPlace => "Fuegos cercanos a ti"; @@ -120,6 +125,10 @@ class es extends S { @override String get UNDO => "DESHACER"; @override + String get tweetAboutAFireTitle => "Twittea"; + @override + String get supportPageDescription => "Puedes apoyar esta iniciativa, dando difusión, ayudándonos a desarrollar nuestro software, traduciendo esta aplicación a tu idioma, etc."; + @override String get aMinute => "un minuto"; @override String get firesInYourPlaces => "Fuegos en tus lugares"; diff --git a/lib/mainDrawer.dart b/lib/mainDrawer.dart index 5afd566..3314dc9 100644 --- a/lib/mainDrawer.dart +++ b/lib/mainDrawer.dart @@ -8,6 +8,7 @@ import 'generated/i18n.dart'; import 'package:comunes_flutter/comunes_flutter.dart'; import 'privacyPage.dart'; import 'fireAlert.dart'; +import 'supportPage.dart'; class MainDrawer extends Drawer { MainDrawer(BuildContext context, {key}) @@ -69,7 +70,7 @@ Widget mainDrawer(BuildContext context) { onTap: () { // Then close the drawer Navigator.pop(context); - Navigator.pushNamed(context, '/subscriptions'); + Navigator.pushNamed(context, SupportPage.routeName); }, ), new ListTile( diff --git a/lib/supportPage.dart b/lib/supportPage.dart new file mode 100644 index 0000000..05be94e --- /dev/null +++ b/lib/supportPage.dart @@ -0,0 +1,48 @@ +import 'package:comunes_flutter/comunes_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import 'generated/i18n.dart'; + +class SupportPage extends StatefulWidget { + static const String routeName = '/support'; + + @override + _SupportPageState createState() => _SupportPageState(); +} + +class _SupportPageState extends State { + final GlobalKey _scaffoldKey = new GlobalKey(); + + Widget buildSupportButton() { + return new Align( + alignment: const Alignment(0.0, -0.2), + child: new FloatingActionButton( + heroTag: 'callAction', + child: const Icon(Icons.favorite), + onPressed: () { + launch("https://comunes.org/"); + }, + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + appBar: + new AppBar(title: new Text(S.of(context).supportThisInitiative)), + body: Padding( + padding: const EdgeInsets.all(8.0), + child: new CenteredColumn(children: [ + new Flexible( + child: new CenteredColumn(children: [ + new Text(S.of(context).supportPageDescription, textAlign: TextAlign.center,), + new SizedBox(height: 20.0), + buildSupportButton() + ])) + ]), + )); + } +} diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 64a3437..d95217b 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -47,6 +47,9 @@ "CANCEL": "CANCEL", "privacyPolicy": "Privacy Policy", "errorFirePlaceDialog": "We couldn't get the location of the fire", + "callEmergencyServicesTitle": "Call 112", "callEmergencyServicesDescription": "You can call 112 if you have not already done so to notify the emergency services.", - "tweetAboutAFireDescription": "Additionally if you use twitter you can notify them with additional information, for example, attaching photos to the tweet if you have good visibility of the fire, when you took the photos, exact location, etc. Use #hashtags type #IFMinicipalTerminal for example #IFJumilla (Forest Fire in Jumilla)." + "tweetAboutAFireTitle": "Tweet about", + "tweetAboutAFireDescription": "Additionally if you use twitter you can share additional information with the emergency services, for example, attaching photos to the tweet if you have good visibility of the fire, when you took the photos, exact location, etc. Use #hashtags type #IFMinicipalTerminal for example #IFJumilla (Forest Fire in Jumilla).", + "supportPageDescription": "You can support this initiative, spreading the word, helping us to develop our software, translating this app to your language, etc." } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 0fb6768..7474b30 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -47,6 +47,9 @@ "CANCEL": "CANCELAR", "privacyPolicy": "Política de Privacidad", "errorFirePlaceDialog": "No hemos podido obtener la ubicación del fuego", + "callEmergencyServicesTitle": "Llama al 112", "callEmergencyServicesDescription": "Puedes llamar al 112 si no lo has hecho ya para avisar a los servicios de emergencia.", - "tweetAboutAFireDescription": "Adicionalmente si usas twitter puedes notificarles con información adicional, por ejemplo, adjuntando fotos al tweet si tienes buena visibilidad del fuego, cuando tomaste las fotos, ubicación exacta, etc. Usa #hashtags tipo #IFTerminoMunicipal por ejemplo #IFJumilla (Incendio Forestal en Jumilla)." + "tweetAboutAFireTitle": "Twittea", + "tweetAboutAFireDescription": "Adicionalmente si usas twitter puedes compartir información adicional con los servicios de emergencia, por ejemplo, adjuntando fotos al tweet si tienes buena visibilidad del fuego, cuando tomaste las fotos, ubicación exacta, etc. Usa #hashtags tipo #IFTerminoMunicipal por ejemplo #IFJumilla (Incendio Forestal en Jumilla).", + "supportPageDescription": "Puedes apoyar esta iniciativa, dando difusión, ayudándonos a desarrollar nuestro software, traduciendo esta aplicación a tu idioma, etc." } \ No newline at end of file