From 6d9ad379c4851afc65693c33b6269c495f0c05c2 Mon Sep 17 00:00:00 2001 From: "Vicente J. Ruiz Jurado" Date: Sun, 15 Jul 2018 09:33:32 +0200 Subject: [PATCH] FireAlerts (wip) --- assets/pages/privacy-en.md | 6 +-- assets/pages/privacy-es.md | 4 +- lib/activeFires.dart | 1 - lib/fireAlert.dart | 78 ++++++++++++++++++++++++++++++++++++++ lib/firesApp.dart | 2 + lib/generated/i18n.dart | 55 ++++++++++++++++----------- lib/homePage.dart | 3 +- lib/mainDrawer.dart | 3 +- pubspec.yaml | 9 ++--- res/values/strings_en.arb | 5 ++- res/values/strings_es.arb | 5 ++- 11 files changed, 133 insertions(+), 38 deletions(-) create mode 100644 lib/fireAlert.dart diff --git a/assets/pages/privacy-en.md b/assets/pages/privacy-en.md index 32115ef..4c42f76 100644 --- a/assets/pages/privacy-en.md +++ b/assets/pages/privacy-en.md @@ -1,4 +1,4 @@ -p# PRIVACY POLICY # +# PRIVACY POLICY # *Last updated July 12, 2018* @@ -144,13 +144,13 @@ We may update this privacy policy from time to time. The updated version will be If you have questions or comments about this policy, you may email us at info@comunes.org or by post to: ASOCIACIÓN COMUNES -CL COLÓN, 21 PORTAL D 5ºD +C/ COLÓN 21, 5º DCHA, ESC DCHA 03001 ALICANTE SPAIN If you have any further questions or comments about us or our policies, email us at info@comunes.org or by post to: ASOCIACIÓN COMUNES -CL COLÓN, 21 PORTAL D 5ºD +C/ COLÓN 21, 5º DCHA, ESC DCHA 03001 ALICANTE SPAIN diff --git a/assets/pages/privacy-es.md b/assets/pages/privacy-es.md index 1dfbc73..20d63d4 100644 --- a/assets/pages/privacy-es.md +++ b/assets/pages/privacy-es.md @@ -143,13 +143,13 @@ Podemos actualizar esta política de privacidad de vez en cuando. La versión ac Si tiene preguntas o comentarios sobre esta política, puede enviarnos un correo electrónico a info@comunes.org o por correo postal a: ASOCIACIÓN COMUNES -CL COLÓN, 21 PORTAL D 5ºD +C/ COLÓN 21, 5º DCHA, ESC DCHA 03001 ALICANTE ESPAÑA Si tiene más preguntas o comentarios sobre nosotras/os o nuestras políticas, envíenos un correo electrónico a info@comunes.org o por correo postal a: ASOCIACIÓN COMUNES -CL COLÓN, 21 PORTAL D 5ºD +C/ COLÓN 21, 5º DCHA, ESC DCHA 03001 ALICANTE ESPAÑA diff --git a/lib/activeFires.dart b/lib/activeFires.dart index 707767a..c6934f4 100644 --- a/lib/activeFires.dart +++ b/lib/activeFires.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:just_debounce_it/just_debounce_it.dart'; import 'package:comunes_flutter/comunes_flutter.dart'; import 'package:fires_flutter/models/yourLocation.dart'; import 'package:flutter/material.dart'; diff --git a/lib/fireAlert.dart b/lib/fireAlert.dart new file mode 100644 index 0000000..289c768 --- /dev/null +++ b/lib/fireAlert.dart @@ -0,0 +1,78 @@ +import 'package:community_material_icon/community_material_icon.dart'; +import 'package:comunes_flutter/comunes_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:share/share.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import 'generated/i18n.dart'; +import 'placesAutocompleteUtils.dart'; + +class FireAlert extends StatefulWidget { + static const String routeName = '/fireAlert'; + + @override + _FireAlertState createState() => _FireAlertState(); +} + +class _FireAlertState extends State { + final GlobalKey _scaffoldKey = new GlobalKey(); + + Widget buildCallButton() { + return new Align( + alignment: const Alignment(0.0, -0.2), + child: new FloatingActionButton( + heroTag: 'callAction', + child: const Icon(Icons.call), + onPressed: () { + launch("tel://112"); + }, + ), + ); + } + + Widget buildTweetButton() { + return new Align( + alignment: const Alignment(0.0, -0.2), + child: new FloatingActionButton( + heroTag: 'tweetAction', + child: const Icon(CommunityMaterialIcons.twitter), + onPressed: () { + // In Android you can choose with app to use with setPackage but seems it's not implemented here + // https://stackoverflow.com/questions/6814268/android-share-on-facebook-twitter-mail-ecc + openPlacesDialog(_scaffoldKey).then((yourLocation) { + String where = + yourLocation.description.replaceAll(' ', '').split(',')[0]; + print(where); + Share.share('#IF${where} FIXME'); + }).catchError((onError) { + _scaffoldKey.currentState.showSnackBar(new SnackBar( + content: new Text( + S.of(_scaffoldKey.currentContext).errorFirePlaceDialog))); + }); + }, + ), + ); + } + + @override + Widget build(BuildContext context) { + 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() + ], + )); + } +} diff --git a/lib/firesApp.dart b/lib/firesApp.dart index 84daf37..db84fc7 100644 --- a/lib/firesApp.dart +++ b/lib/firesApp.dart @@ -13,6 +13,7 @@ import 'redux/actions.dart'; import 'sandbox.dart'; import 'theme.dart'; import 'privacyPage.dart'; +import 'fireAlert.dart'; class FiresApp extends StatelessWidget { static final WidgetBuilder introWidget = (context) => new IntroPage(); @@ -24,6 +25,7 @@ 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() }; final Store store; diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index 001191f..38cef4c 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -37,9 +37,11 @@ class S implements WidgetsLocalizations { String get alertWhenThereIsAFire => "Alert when there is a fire"; 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 chooseAPlace => "Choose a place"; String get chooseAWatchRadio => "Choose a watch radio"; String get confirm => "Confirm"; + String get errorFirePlaceDialog => "We couldn't get the location of the fire"; String get firesInTheWorld => "Active fires in the world"; String get firesInYourPlaces => "Active fires in your places"; String get firesNearPlace => "Fires near other place"; @@ -51,6 +53,7 @@ class S implements WidgetsLocalizations { 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 typeTheNameOfAPlace => "Type the name of a place, region, etc"; String get unsubscribe => "Unsubscribe"; String get warningThisIsAVeryLargeArea => "Warning: this is a very large area"; @@ -83,36 +86,50 @@ class es extends S { @override String get addYourCurrentPosition => "Añade tu ubicación actual"; @override - String get UNDO => "DESHACER"; - @override String get alertWhenThereIsAFire => "Alerta cuando hay un fuego"; @override String get anHour => "una hora"; @override - String get aMinute => "un minuto"; - @override - String get firesInYourPlaces => "Fuegos en tus lugares"; - @override String get notifyAFire => "Notificar un fuego"; @override - String get isYourUbicationEnabled => "No podemos saber tu ubicación actual. ¿Están los servicios de ubicación en tu móvil activados?"; + String get callEmergencyServicesDescription => "Puedes llamar al 112 si no lo has hecho ya para avisar a los servicios de emergencia."; + @override + String get errorFirePlaceDialog => "No hemos podido obtener la ubicación del fuego"; @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)."; + @override String get AvoidThisStringsIfisNotPlural => "Zero One Two Few Many Other"; @override String get unsubscribe => "Desuscríbete"; @override - String get aDay => "un día"; - @override String get supportThisInitiative => "Apoya esta iniciativa"; @override - String get SAVE => "GUARDAR"; - @override String get toFiresNotifications => "Suscríbete a alertas de fuegos"; @override String get notPermsUbication => "No tenemos permisos para conocer tu ubicación"; @override + String get youDeletedThisPlace => "Has borrado este lugar"; + @override + String get chooseAPlace => "Elige un lugar"; + @override + String get firesNearPlace => "Fuegos cercanos a ti"; + @override + String get aYear => "un año"; + @override + String get UNDO => "DESHACER"; + @override + String get aMinute => "un minuto"; + @override + String get firesInYourPlaces => "Fuegos en tus lugares"; + @override + String get isYourUbicationEnabled => "No podemos saber tu ubicación actual. ¿Están los servicios de ubicación en tu móvil activados?"; + @override + String get aDay => "un día"; + @override + String get SAVE => "GUARDAR"; + @override String get addedThisLocation => "Ya has añadido este lugar antes"; @override String get typeTheNameOfAPlace => "Escribe el nombre de un lugar, zona, etc"; @@ -135,30 +152,18 @@ class es extends S { @override String get getAlertsOfFiresinThatArea => "Recibe alertas de fuegos en esa zona"; @override - String get youDeletedThisPlace => "Has borrado este lugar"; - @override String get warningThisIsAVeryLargeArea => "Cuidado: esta zona es muy grande"; @override String get chooseAWatchRadio => "Elige un radio de vigilancia"; @override String get CANCEL => "CANCELAR"; @override - String get chooseAPlace => "Elige un lugar"; - @override - String get firesNearPlace => "Fuegos cercanos a ti"; - @override - String get aYear => "un año"; - @override String inMonths(String value) => "$value meses"; @override - String inDays(String value) => "$value días"; - @override String inYears(String value) => "$value años"; @override String noFiresAroundThisArea(String kmAround) => "No hay fuegos a $kmAround км a la redonda"; @override - String activeFiresWorldWide(String activeFires) => "$activeFires fuegos activos en el mundo"; - @override String firesAroundThisArea(String numFires, String kmAround) => "$numFires fuegos a $kmAround км a la redonda"; @override String appLicense(String thisYear) => "(c) 2017-$thisYear Asociación Comunes bajo licencia GNU Affero GPL v3"; @@ -171,6 +176,10 @@ class es extends S { @override String updatedLastCheck(String lastCheck) => "Actualizado $lastCheck"; @override + String inDays(String value) => "$value días"; + @override + String activeFiresWorldWide(String activeFires) => "$activeFires fuegos activos en el mundo"; + @override String inSomething(String something) => "en $something"; @override String inMinutes(String value) => "$value minutos"; diff --git a/lib/homePage.dart b/lib/homePage.dart index 2f86100..2f9aa6e 100644 --- a/lib/homePage.dart +++ b/lib/homePage.dart @@ -2,6 +2,7 @@ import 'package:comunes_flutter/comunes_flutter.dart'; import 'package:flutter/material.dart'; import 'activeFires.dart'; +import 'fireAlert.dart'; import 'colors.dart'; import 'generated/i18n.dart'; import 'mainDrawer.dart'; @@ -45,7 +46,7 @@ class HomePage extends StatelessWidget { child: FloatingActionButton.extended( elevation: 0.0, onPressed: () { - Navigator.pushNamed(context, ActiveFiresPage.routeName); + Navigator.pushNamed(context, FireAlert.routeName); }, heroTag: 'notifyFire', backgroundColor: fires600, diff --git a/lib/mainDrawer.dart b/lib/mainDrawer.dart index 10f586e..5afd566 100644 --- a/lib/mainDrawer.dart +++ b/lib/mainDrawer.dart @@ -7,6 +7,7 @@ import 'globals.dart' as globals; import 'generated/i18n.dart'; import 'package:comunes_flutter/comunes_flutter.dart'; import 'privacyPage.dart'; +import 'fireAlert.dart'; class MainDrawer extends Drawer { MainDrawer(BuildContext context, {key}) @@ -58,7 +59,7 @@ Widget mainDrawer(BuildContext context) { onTap: () { // Then close the drawer Navigator.pop(context); - Navigator.pushNamed(context, Sandbox.routeName); + Navigator.pushNamed(context, FireAlert.routeName); }, ), new Divider(), diff --git a/pubspec.yaml b/pubspec.yaml index ce715eb..85b8361 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,11 +17,13 @@ dependencies: flutter_simple_dependency_injection: "^0.0.2" sentry: "^2.0.2" flutter_markdown: "^0.1.5" + url_launcher: "^3.0.2" # net http: "^0.11.3+16" jaguar_resty: "^2.5.5" connectivity: "^0.3.1" + share: "^0.5.2" # data json_annotation: ^0.2.3 @@ -56,12 +58,9 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: "^0.1.2" + community_material_icon: "^0.1.2" + # not using yet - - # community_material_icon: "^0.1.2" - # url_launcher: "^3.0.2" - # share: "^0.5.2" - # package_info: "^0.3.2" dev_dependencies: diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 4dc8c52..64a3437 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -45,5 +45,8 @@ "inSomething": "in $something", "SAVE": "SAVE", "CANCEL": "CANCEL", - "privacyPolicy": "Privacy Policy" + "privacyPolicy": "Privacy Policy", + "errorFirePlaceDialog": "We couldn't get the location of the fire", + "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)." } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 3ddeec3..0fb6768 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -45,5 +45,8 @@ "inSomething": "en $something", "SAVE": "GUARDAR", "CANCEL": "CANCELAR", - "privacyPolicy": "Política de Privacidad" + "privacyPolicy": "Política de Privacidad", + "errorFirePlaceDialog": "No hemos podido obtener la ubicación del fuego", + "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)." } \ No newline at end of file