Fire press dialog
This commit is contained in:
parent
97add52865
commit
29df8c44db
6 changed files with 62 additions and 31 deletions
|
|
@ -43,6 +43,8 @@ class S implements WidgetsLocalizations {
|
|||
String get appMoto => "Strengthening neighborhoods against wildfires";
|
||||
String get appName => "All Against The Fire!";
|
||||
String get areYouSureTitle => "Are you sure?";
|
||||
String get byNASAsatellites => "by NASA satellites";
|
||||
String get byOurUsers => "by one of our users";
|
||||
String get callEmergencyServicesDescription => "You should 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";
|
||||
|
|
@ -95,6 +97,7 @@ class S implements WidgetsLocalizations {
|
|||
String get youDeletedThisNotification => "You deleted this notification";
|
||||
String get youDeletedThisPlace => "You deleted this place";
|
||||
String activeFiresWorldWide(String activeFires) => "$activeFires active fires worldwide";
|
||||
String additionalInfoAboutFire(String where, String when, String by) => "Fire detected in $where $when $by";
|
||||
String appLicense(String thisYear) => "(c) 2017-$thisYear Comunes Association under the GNU Affero GPL v3";
|
||||
String fireAroundThisArea(String kmAround) => "A fire at $kmAround км around this area";
|
||||
String firesAroundThisArea(String numFires, String kmAround) => "$numFires fires at $kmAround км around this area";
|
||||
|
|
@ -142,6 +145,8 @@ class es extends S {
|
|||
@override
|
||||
String get fireNotificationsDescription => "Aquí recibirás las notificaciones de fuegos en los lugares a los que te subscribas";
|
||||
@override
|
||||
String get byOurUsers => "por uno de nuestros usuarios/as";
|
||||
@override
|
||||
String get anHour => "una hora";
|
||||
@override
|
||||
String get areYouSureTitle => "¿Seguro?";
|
||||
|
|
@ -274,6 +279,8 @@ class es extends S {
|
|||
@override
|
||||
String get appMoto => "Fortaleciendo vecindarios contra incendios forestales";
|
||||
@override
|
||||
String get byNASAsatellites => "por satélites de la NASA";
|
||||
@override
|
||||
String get chooseAWatchRadio => "Elige un radio de vigilancia";
|
||||
@override
|
||||
String get CANCEL => "CANCELAR";
|
||||
|
|
@ -292,6 +299,8 @@ class es extends S {
|
|||
@override
|
||||
String somethingAgo(String something) => "hace $something";
|
||||
@override
|
||||
String additionalInfoAboutFire(String where, String when, String by) => "Información adicional sobre fuego detectado en $where $when $by";
|
||||
@override
|
||||
String tweetAboutSelf(String location, String hash) => "Fuego en $location $hash";
|
||||
@override
|
||||
String subscribeToValueAroundThisArea(String sliderValue) => "Suscríbete a $sliderValue км a la redonda";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'dart:core';
|
||||
|
||||
import 'locationUtils.dart';
|
||||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'package:fires_flutter/models/yourLocation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -24,10 +24,12 @@ import 'redux/actions.dart';
|
|||
import 'sentryReport.dart';
|
||||
import 'slider.dart';
|
||||
import 'zoomMapPlugin.dart';
|
||||
import 'customMoment.dart';
|
||||
|
||||
@immutable
|
||||
class _ViewModel {
|
||||
final String serverUrl;
|
||||
final String lang;
|
||||
final FireMapState mapState;
|
||||
final OnSubscribeFunction onSubs;
|
||||
final OnSubscribeConfirmedFunction onSubsConfirmed;
|
||||
|
|
@ -43,6 +45,7 @@ class _ViewModel {
|
|||
_ViewModel(
|
||||
{@required this.mapState,
|
||||
@required this.serverUrl,
|
||||
@required this.lang,
|
||||
@required this.onSubs,
|
||||
@required this.onSubsConfirmed,
|
||||
@required this.onUnSubs,
|
||||
|
|
@ -59,10 +62,12 @@ class _ViewModel {
|
|||
identical(this, other) ||
|
||||
other is _ViewModel &&
|
||||
runtimeType == other.runtimeType &&
|
||||
serverUrl == other.serverUrl &&
|
||||
lang == other.lang &&
|
||||
mapState == other.mapState;
|
||||
|
||||
@override
|
||||
int get hashCode => mapState.hashCode;
|
||||
int get hashCode => serverUrl.hashCode ^ lang.hashCode ^ mapState.hashCode;
|
||||
}
|
||||
|
||||
class genericMap extends StatefulWidget {
|
||||
|
|
@ -115,10 +120,12 @@ class _genericMapState extends State<genericMap> {
|
|||
},
|
||||
onFalsePositive: (notif, type) => store
|
||||
.dispatch(new MarkFireAsFalsePositiveAction(notif, type)),
|
||||
onFirePressed: (LatLng latLng, DateTime when) {
|
||||
// _showFireDialog(latLng, when);
|
||||
onFirePressed: (LatLng latLng, DateTime when, type) {
|
||||
_showFireDialog(latLng, when, type);
|
||||
},
|
||||
serverUrl: store.state.serverUrl,
|
||||
// Not used yet, but maybe in the future for date format
|
||||
lang: store.state.user.lang,
|
||||
mapState: store.state.fireMapState);
|
||||
},
|
||||
builder: (context, view) {
|
||||
|
|
@ -429,7 +436,7 @@ class _genericMapState extends State<genericMap> {
|
|||
try {
|
||||
var loc = new LatLng(fire['lat'], fire['lon']);
|
||||
markers.add(FireMarker(loc, FireMarkType.fire, () {
|
||||
onFirePressed(loc, DateTime.parse(fire['when']));
|
||||
onFirePressed(loc, DateTime.parse(fire['when']), fire['type']);
|
||||
print('fire $fire pressed');
|
||||
}));
|
||||
markers.add(FireMarker(loc, FireMarkType.pixel));
|
||||
|
|
@ -444,19 +451,28 @@ class _genericMapState extends State<genericMap> {
|
|||
return markers;
|
||||
}
|
||||
|
||||
void _showFireDialog(LatLng latLng, DateTime when) {
|
||||
showDialog<bool>(
|
||||
context: _scaffoldKey.currentContext,
|
||||
builder: (_) => new AlertDialog(
|
||||
content: new Text('FIXME'),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: Text(S.of(_scaffoldKey.currentContext).CLOSE),
|
||||
onPressed: () {
|
||||
Navigator.pop(_scaffoldKey.currentContext);
|
||||
},
|
||||
),
|
||||
],
|
||||
));
|
||||
void _showFireDialog(LatLng pos, DateTime date, String type) {
|
||||
var when = Moment.fromDate(date).fromNow(context);
|
||||
getReverseLocation(lat: pos.latitude, lon: pos.longitude)
|
||||
.then((reverseLoc) {
|
||||
String by = type == 'vecinal'
|
||||
? S.of(context).byOurUsers
|
||||
: S.of(context).byNASAsatellites;
|
||||
String fireDesc =
|
||||
S.of(context).additionalInfoAboutFire(reverseLoc, when, by);
|
||||
showDialog<bool>(
|
||||
context: _scaffoldKey.currentContext,
|
||||
builder: (_) => new AlertDialog(
|
||||
content: new Text(fireDesc),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: Text(S.of(context).CLOSE),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,21 +15,21 @@ Future<YourLocation> getUserLocation(
|
|||
Map<String, double> location = await _location.getLocation;
|
||||
|
||||
// It seems that the lib fails with lat/lon values
|
||||
var yourLocation = new YourLocation(
|
||||
var yl = new YourLocation(
|
||||
lat: location['latitude'], lon: location['longitude']);
|
||||
var address;
|
||||
try {
|
||||
address = await getReverseLocation(yourLocation);
|
||||
yourLocation.description = address;
|
||||
address = await getReverseLocation(lat: yl.lat, lon: yl.lon);
|
||||
yl.description = address;
|
||||
} catch (e) {
|
||||
try {
|
||||
address = await getReverseLocation(yourLocation, true);
|
||||
yourLocation.description = address;
|
||||
address = await getReverseLocation(lat: yl.lat, lon: yl.lon, external: true);
|
||||
yl.description = address;
|
||||
} catch (e) {
|
||||
print('We cannot reverse geolocate');
|
||||
}
|
||||
}
|
||||
return yourLocation;
|
||||
return yl;
|
||||
} on PlatformException catch (e) {
|
||||
if (e.code == 'PERMISSION_DENIED') {
|
||||
scaffoldKey.currentState.showSnackBar(new SnackBar(
|
||||
|
|
@ -44,9 +44,9 @@ Future<YourLocation> getUserLocation(
|
|||
}
|
||||
}
|
||||
|
||||
Future<String> getReverseLocation(YourLocation loc,
|
||||
[bool external = false]) async {
|
||||
final coordinates = new Coordinates(loc.lat, loc.lon);
|
||||
Future<String> getReverseLocation({@required lat, @required lon,
|
||||
bool external = false}) async {
|
||||
final coordinates = new Coordinates(lat, lon);
|
||||
var geoCoder = external ? Geocoder.google(Injector.getInjector().get<String>(key: "gmapKey")) : Geocoder.local;
|
||||
var addresses = await geoCoder.findAddressesFromCoordinates(coordinates);
|
||||
var first = addresses.first;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ typedef void OnLocationEditing(YourLocation loc);
|
|||
typedef void OnLocationEditConfirm(YourLocation loc);
|
||||
typedef void OnLocationEditCancel(YourLocation loc);
|
||||
typedef void TapFireNotificationFunction(FireNotification notif);
|
||||
typedef void OnFirePressedInMap(LatLng latLng, DateTime when);
|
||||
typedef void OnFirePressedInMap(LatLng latLng, DateTime when, String source);
|
||||
// typedef void OnReceivedFireNotificationFunction(FireNotification notif);
|
||||
typedef void DeleteFireNotificationFunction(FireNotification notif);
|
||||
typedef void DeleteAllFireNotificationFunction();
|
||||
|
|
|
|||
|
|
@ -86,5 +86,8 @@
|
|||
"unsubscribedToFires": "Unsubscribed to fires notifications",
|
||||
"subscribedToFires": "Subscribed to fires notifications",
|
||||
"inDevelopment": "In development",
|
||||
"translateBtn": "Help with translations"
|
||||
"translateBtn": "Help with translations",
|
||||
"additionalInfoAboutFire": "Fire detected in $where $when $by",
|
||||
"byNASAsatellites": "by NASA satellites",
|
||||
"byOurUsers": "by one of our users"
|
||||
}
|
||||
|
|
@ -86,5 +86,8 @@
|
|||
"unsubscribedToFires": "Desuscrito a notificaciones de fuegos",
|
||||
"subscribedToFires": "Suscrito a notificaciones de fuegos",
|
||||
"inDevelopment": "En desarrollo",
|
||||
"translateBtn": "Ayuda con las traducciones"
|
||||
"translateBtn": "Ayuda con las traducciones",
|
||||
"additionalInfoAboutFire": "Información adicional sobre fuego detectado en $where $when $by",
|
||||
"byNASAsatellites": "por satélites de la NASA",
|
||||
"byOurUsers": "por uno de nuestros usuarios/as"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue