i18n (wip)

This commit is contained in:
vjrj 2018-06-26 16:50:05 +02:00
parent cee04a3d12
commit 6488957148
17 changed files with 368 additions and 191 deletions

View file

@ -1,17 +1,20 @@
import 'package:flutter/material.dart';
import 'mainDrawer.dart';
import 'genericMap.dart';
import 'dart:async';
import 'package:comunes_flutter/comunes_flutter.dart';
import 'colors.dart';
import 'placesAutocompleteUtils.dart';
import 'basicLocation.dart';
import 'locationUtils.dart';
import 'globals.dart' as globals;
import 'basicLocationPersist.dart';
import 'globalFiresBottomStats.dart';
import 'package:flutter/material.dart';
import 'package:flutter_fab_dialer/flutter_fab_dialer.dart';
import 'basicLocation.dart';
import 'basicLocationPersist.dart';
import 'colors.dart';
import 'generated/i18n.dart';
import 'genericMap.dart';
import 'globalFiresBottomStats.dart';
import 'globals.dart' as globals;
import 'locationUtils.dart';
import 'mainDrawer.dart';
import 'placesAutocompleteUtils.dart';
class ActiveFiresPage extends StatefulWidget {
static const String routeName = '/fires';
@ -24,25 +27,24 @@ class ActiveFiresPage extends StatefulWidget {
class _ActiveFiresPageState extends State<ActiveFiresPage> {
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
List<FabMiniMenuItem> _fabMiniMenuItemList(BuildContext context) {
List<FabMiniMenuItem> _fabMiniMenuItemList() {
return [
new FabMiniMenuItem.withText(
new Icon(Icons.location_searching),
fires600,
8.0,
"Add your current position",
S.of(context).addYourCurrentPosition,
() {
onAddYourLocation();
},
"Add your current position",
S.of(context).addYourCurrentPosition,
Colors.black38,
Colors.white,
),
new FabMiniMenuItem.withText(
new Icon(Icons.edit_location), fires600, 8.0, "Add some other place",
() {
onAddOtherLocation(context);
}, "Add some other place", Colors.black38, Colors.white)
new FabMiniMenuItem.withText(new Icon(Icons.edit_location), fires600, 8.0,
S.of(context).addSomePlace, () {
onAddOtherLocation();
}, S.of(context).addSomePlace, Colors.black38, Colors.white)
];
}
@ -63,7 +65,7 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
}),
title: new Text(loc.description),
onLongPress: () {
showSnackMsg('Slide horizontally to delete this location');
showSnackMsg(S.of(context).toDeleteThisPlace);
},
onTap: () {
showLocationMap(loc);
@ -127,11 +129,11 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
globals.yourLocations.remove(item);
persistYourLocations();
});
final String action = 'deleted';
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('You $action this position'),
content: new Text(S.of(context).youDeletedThisPlace),
action: new SnackBarAction(
label: 'UNDO',
label: S.of(context).UNDO,
onPressed: () {
handleUndo(item);
})));
@ -158,8 +160,8 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
Widget build(BuildContext context) {
var hasLocations = globals.yourLocations.length > 0;
final title = hasLocations
? 'Active fires in your places'
: 'Active fires in the world';
? S.of(context).firesInYourPlaces
: S.of(context).firesInTheWorld;
print('Building Active Fires');
return Scaffold(
key: _scaffoldKey,
@ -180,7 +182,7 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
? new Stack(children: <Widget>[
_buildSavedLocations(),
new FabDialer(
_fabMiniMenuItemList(context), fires600, new Icon(Icons.add))
_fabMiniMenuItemList(), fires600, new Icon(Icons.add))
])
: new Center(
child: new CenteredColumn(children: <Widget>[
@ -192,35 +194,12 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
const SizedBox(height: 26.0),
new RoundedBtn(
icon: Icons.edit_location,
text: 'Fires near other place',
text: S.of(context).firesNearPlace,
onPressed: () {
onAddOtherLocation(context);
onAddOtherLocation();
},
backColor: fires600),
])),
floatingActionButton: hasLocations
? Column(mainAxisAlignment: MainAxisAlignment.end,
// crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
/* FloatingActionButton.extended(
onPressed: onAddYourLocation,
heroTag: 'yourposition',
label: const Text('Add your position'),
icon: const Icon(Icons.location_searching),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton.extended(
onPressed: () {
onAddOtherLocation(context);
},
heroTag: 'otherplace',
label: new Text('Add some other place'),
icon: const Icon(Icons.edit_location),
),
), */
])
: null,
);
}
@ -229,8 +208,8 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
_saveLocation(location);
}
void onAddOtherLocation(BuildContext context) {
Future<BasicLocation> location = openPlacesDialog(context);
void onAddOtherLocation() {
Future<BasicLocation> location = openPlacesDialog(_scaffoldKey);
_saveLocation(location);
}
@ -238,7 +217,7 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
location.then((newLocation) {
if (newLocation != BasicLocation.noLocation) {
if (globals.yourLocations.contains(newLocation)) {
showSnackMsg('You have already added this location');
showSnackMsg(S.of(context).addedThisLocation);
} else
this.setState(() {
globals.yourLocations.add(newLocation);

View file

@ -1,55 +0,0 @@
import 'package:flutter/material.dart';
class HomePage extends StatelessWidget {
static const String routeName = '/home';
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: const Text('Add area'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.edit),
onPressed: () {
print('Filter button');
},
),
],
),
// https://flutter.io/widgets/scrolling/
floatingActionButton:
Column(mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[
FloatingActionButton(
onPressed: () {
//
},
heroTag: 'image0',
tooltip: 'Pick Image from gallery',
child: const Icon(Icons.photo_library),
),
]),
body: new SingleChildScrollView(
child: new Column(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(16.0),
child: new Column(
children: <Widget>[
SizedBox(height: 10.0),
new TextFormField(
decoration: new InputDecoration(
border: const OutlineInputBorder(),
helperText: "Write a place to center the map",
hintText: 'Write here a place',
labelText: 'Your location')),
SizedBox(height: 20.0),
],
),
)
],
)),
);
}
}

View file

@ -1,10 +1,13 @@
import 'package:flutter/material.dart';
import 'package:comunes_flutter/comunes_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'activeFires.dart';
import 'generated/i18n.dart';
import 'homePage.dart';
import 'theme.dart';
import 'introPage.dart';
import 'sandbox.dart';
import 'activeFires.dart';
import 'theme.dart';
class FiresApp extends StatelessWidget {
static final WidgetBuilder introWidget = (context) => new IntroPage();
@ -23,8 +26,17 @@ class FiresApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new MaterialAppWithIntroHome(introWidget, continueWidget, 'showInitialWizard234'),
title: 'All Against The Fire!',
localizationsDelegates: [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
localeResolutionCallback:
S.delegate.resolution(fallback: new Locale("en", "")),
home: new MaterialAppWithIntroHome(
introWidget, continueWidget, 'showInitialWizard234'),
onGenerateTitle: (context) => S.of(context).appName,
theme: firesTheme,
routes: routes);
}

182
lib/generated/i18n.dart Normal file
View file

@ -0,0 +1,182 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: camel_case_types
// ignore_for_file: prefer_single_quotes
//This file is automatically generated. DO NOT EDIT, all your changes would be lost.
class S implements WidgetsLocalizations {
const S();
static const GeneratedLocalizationsDelegate delegate =
const GeneratedLocalizationsDelegate();
static S of(BuildContext context) =>
Localizations.of<S>(context, WidgetsLocalizations);
@override
TextDirection get textDirection => TextDirection.ltr;
String get AvoidThisStringsIfisNotPlural => "Zero One Two Few Many Other";
String get UNDO => "UNDO";
String get activeFires => "Active fires";
String get addSomePlace => "Add some other place";
String get addYourCurrentPosition => "Add your current position";
String get addedThisLocation => "You have already added this location";
String get alertWhenThereIsAFire => "Alert when there is a fire";
String get appName => "All Against The Fire!";
String get chooseAPlace => "Choose a place";
String get chooseAWatchRadio => "Choose a watch radio";
String get confirm => "Confirm";
String get firesInTheWorld => "Active fires in the world";
String get firesInYourPlaces => "Active fires in your places";
String get firesNearPlace => "Fires near other place";
String get getAlertsOfFiresinThatArea => "Get alerts of fires in that area";
String get isYourUbicationEnabled => "I cannot get your current location. It's your ubication enabled?";
String get notPermsUbication => "We don't have permission to get your location";
String get notifyAFire => "Notify a fire";
String get supportThisInitiative => "Support this initiative";
String get toDeleteThisPlace => "Slide horizontally to delete this place";
String get toFiresNotifications => "Subscribe to fires notifications";
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";
String get youDeletedThisPlace => "You deleted this place";
String activeFiresWorldWide(String activeFires) => "$activeFires active fires worldwide";
String appLicense(String thisYear) => "(c) 2017-$thisYear Comunes Association under the GNU Affero GPL v3";
String firesAroundThisArea(String numFires, String kmAround) => "$numFires fires at $kmAround км around this area";
String noFiresAroundThisArea(String kmAround) => "There is no fires at $kmAround км around this area";
String subscribeToValueAroundThisArea(String sliderValue) => "Subscribe to $sliderValue км around this area";
String updatedLastCheck(String lastCheck) => "Updated $lastCheck";
}
class en extends S {
const en();
}
class es extends S {
const es();
@override
TextDirection get textDirection => TextDirection.ltr;
@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 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?";
@override
String get toDeleteThisPlace => "Desliza horizontalmente para borrar este lugar";
@override
String get AvoidThisStringsIfisNotPlural => "Zero One Two Few Many Other";
@override
String get unsubscribe => "Desuscríbete";
@override
String get supportThisInitiative => "Apoya esta iniciativa";
@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 addedThisLocation => "Ya has añadido este lugar antes";
@override
String get typeTheNameOfAPlace => "Escribe el nombre de un lugar, zona, etc";
@override
String get appName => "¡Tod@s contra el Fuego!";
@override
String get activeFires => "Fuegos activos";
@override
String get firesInTheWorld => "Fuegos en el mundo";
@override
String get addSomePlace => "Añade otro lugar";
@override
String get confirm => "Confirmar";
@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 chooseAPlace => "Elige un lugar";
@override
String get firesNearPlace => "Fuegos cercanos a ti";
@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";
@override
String subscribeToValueAroundThisArea(String sliderValue) => "Suscríbete a $sliderValue км a la redonda";
@override
String updatedLastCheck(String lastCheck) => "Actualizado $lastCheck";
}
class GeneratedLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocalizations> {
const GeneratedLocalizationsDelegate();
List<Locale> get supportedLocales {
return const <Locale>[
const Locale("en", ""),
const Locale("es", ""),
];
}
LocaleResolutionCallback resolution({Locale fallback}) {
return (Locale locale, Iterable<Locale> supported) {
final Locale languageLocale = new Locale(locale.languageCode, "");
if (supported.contains(locale))
return locale;
else if (supported.contains(languageLocale))
return languageLocale;
else {
final Locale fallbackLocale = fallback ?? supported.first;
return fallbackLocale;
}
};
}
@override
Future<WidgetsLocalizations> load(Locale locale) {
final String lang = getLang(locale);
switch (lang) {
case "en":
return new SynchronousFuture<WidgetsLocalizations>(const en());
case "es":
return new SynchronousFuture<WidgetsLocalizations>(const es());
default:
return new SynchronousFuture<WidgetsLocalizations>(const S());
}
}
@override
bool isSupported(Locale locale) => supportedLocales.contains(locale);
@override
bool shouldReload(GeneratedLocalizationsDelegate old) => false;
}
String getLang(Locale l) => l.countryCode != null && l.countryCode.isEmpty
? l.languageCode
: l.toString();

View file

@ -16,6 +16,7 @@ import 'customBottomAppBar.dart';
import 'dummyMapPlugin.dart';
import 'fireMarkType.dart';
import 'fireMarker.dart';
import 'generated/i18n.dart';
import 'globals.dart' as globals;
import 'slider.dart';
import 'zoomMapPlugin.dart';
@ -130,7 +131,6 @@ class _GenericMapState extends State<GenericMap> {
),
],
));
return new Scaffold(
key: _scaffoldKey,
// drawer: new MainDrawer(context),
@ -164,10 +164,10 @@ class _GenericMapState extends State<GenericMap> {
color: fires600),
label: new Text(
operation == MapOperation.view
? 'Subscribe to fires notifications'
? S.of(context).toFiresNotifications
: operation == MapOperation.subscriptionConfirm
? 'Confirm'
: 'Unsubscribe',
? S.of(context).confirm
: S.of(context).unsubscribe,
style: const TextStyle(color: fires600),
),
backgroundColor: Colors.white,
@ -182,11 +182,12 @@ class _GenericMapState extends State<GenericMap> {
actions: listWithoutNulls(<Widget>[
operation == MapOperation.subscriptionConfirm || numFires == null
? null
: numFires > 0
? new Text('${numFires.toString()} fires at ${kmAround
.toString()} км around this area')
: new Text(
'There is no fires at ${kmAround.toString()} км around this area'),
: new Text(numFires > 0
? S.of(context).firesAroundThisArea(
numFires.toString(), kmAround.toString())
: S
.of(context)
.noFiresAroundThisArea(kmAround.toString())),
SizedBox(width: 10.0)
])),
body: LayoutBuilder(

View file

@ -6,6 +6,7 @@ import 'package:http/http.dart' as http;
import 'package:comunes_flutter/comunes_flutter.dart';
import 'customBottomAppBar.dart';
import 'colors.dart';
import 'generated/i18n.dart';
class GlobalFiresBottomStats extends StatefulWidget {
@override
@ -55,8 +56,8 @@ class _GlobalFiresBottomStatsState extends State<GlobalFiresBottomStats> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
new Text('$activeFires active fires worldwide'),
new Text('Updated $lastCheck')
new Text(S.of(context).activeFiresWorldWide(activeFires.toString())),
new Text(S.of(context).updatedLastCheck(lastCheck))
])
: null,
SizedBox(width: 10.0)

View file

@ -8,9 +8,8 @@ import 'package:flutter/material.dart';
String gmapKey;
String firesApiKey;
String firesApiUrl;
final String appName = 'All Against The Fire!';
final String appVersion = '0.0.1';
final String appLicense = "(c) 2017-2018 Comunes Association under the GNU Affero GPL v3";
final Widget appMediumIcon = Image.asset('images/logo-200.png', width: 60.0, height: 60.0);
final Widget appIcon = Image.asset('images/logo-200.png', width: 24.0, height: 24.0);
final Future<SharedPreferences> prefs = SharedPreferences.getInstance();

View file

@ -4,7 +4,7 @@ import 'colors.dart';
import 'package:comunes_flutter/comunes_flutter.dart';
import 'mainDrawer.dart';
import 'activeFires.dart';
import 'globals.dart' as globals;
import 'generated/i18n.dart';
class HomePage extends StatelessWidget {
static const String routeName = '/home';
@ -49,21 +49,21 @@ class HomePage extends StatelessWidget {
new Padding(
padding: const EdgeInsets.all(10.0),
child: new Text(
globals.appName,
S.of(context).appName,
textAlign: TextAlign.center,
softWrap: true, style: _homeFont),
),
new SizedBox(height: 20.0),
new RoundedBtn.nav(
icon: Icons.whatshot,
text: 'Active fires',
text: S.of(context).activeFires,
context: context,
route: ActiveFiresPage.routeName,
backColor: fires600),
new SizedBox(height: 20.0),
new RoundedBtn.nav(
icon: Icons.notifications_active,
text: 'Notify a fire',
text: S.of(context).notifyAFire,
context: context,
route: ActiveFiresPage.routeName,
backColor: fires600),

View file

@ -1,18 +1,24 @@
import 'package:comunes_flutter/comunes_flutter.dart';
import 'package:flutter/material.dart';
import 'homePage.dart';
import 'generated/i18n.dart';
class IntroPage extends AppIntroPage {
static const String routeName = '/intro';
static final List<AppIntroItem> fireItems = <AppIntroItem>[
AppIntroItem(icon: Icons.location_on, title: 'Choose a place'),
AppIntroItem(icon: Icons.panorama_fish_eye, title: 'Choose a watch radio'),
AppIntroItem(
icon: Icons.whatshot, title: 'Get alerts of fires in that area'),
AppIntroItem(
icon: Icons.notifications_active, title: 'Alert when there is a fire'),
];
static final fireItems = (context) =>
<AppIntroItem>[
AppIntroItem(icon: Icons.location_on, title: S.of(context).chooseAPlace),
AppIntroItem(
icon: Icons.panorama_fish_eye, title: S.of(context).chooseAWatchRadio),
AppIntroItem(
icon: Icons.whatshot, title: S.of(context).getAlertsOfFiresinThatArea),
AppIntroItem(
icon: Icons.notifications_active,
title: S.of(context).alertWhenThereIsAFire)
];
/*
static final OnIntroFinish onFinish =

View file

@ -5,6 +5,7 @@ import 'basicLocation.dart';
import 'package:flutter/material.dart';
import 'package:geocoder/geocoder.dart';
import 'globals.dart' as globals;
import 'generated/i18n.dart';
Future<BasicLocation> getUserLocation(
GlobalKey<ScaffoldState> scaffoldKey) async {
@ -32,12 +33,12 @@ Future<BasicLocation> getUserLocation(
} on PlatformException catch (e) {
if (e.code == 'PERMISSION_DENIED') {
scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('We don\'t have permission to get your location'),
content: new Text(S.of(scaffoldKey.currentContext).notPermsUbication),
));
} else if (e.code == 'PERMISSION_DENIED_NEVER_ASK') {}
scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text(
'I cannot get your current location. It\'s your ubication enabled?'),
content: new Text(S.of(scaffoldKey.currentContext).isYourUbicationEnabled
),
));
return BasicLocation.noLocation;
}

View file

@ -15,7 +15,7 @@ void mainCommon() {
loadSecrets().then((secrets) {
globals.gmapKey = secrets['gmapKey'];
globals.firesApiKey = secrets['firesApiKey'];
globals.firesApiUrl = secrets['firesApiUrl'];
globals.firesApiUrl = secrets['firesApiUrl'] + "api/v1/";
globals.prefs.then((prefs) {
loadYourLocationsWithPrefs(prefs);
firebaseConfig();

View file

@ -4,6 +4,8 @@ import 'colors.dart';
import 'sandbox.dart';
import 'activeFires.dart';
import 'globals.dart' as globals;
import 'generated/i18n.dart';
import 'package:comunes_flutter/comunes_flutter.dart';
class MainDrawer extends Drawer {
MainDrawer(BuildContext context, {key})
@ -14,7 +16,7 @@ Widget mainDrawer(BuildContext context) {
return new ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
children: listWithoutNulls(<Widget>[
new GestureDetector(
onTap: () {
Navigator.pushNamed(context, '/');
@ -28,7 +30,7 @@ Widget mainDrawer(BuildContext context) {
height: 80.0,
),
const SizedBox(height: 20.0),
new Text(globals.appName,
new Text(S.of(context).appName,
style: new TextStyle(
fontSize: 24.0,
color: Colors.white,
@ -40,28 +42,16 @@ Widget mainDrawer(BuildContext context) {
),
),
),
/* new ListTile(
// https://docs.flutter.io/flutter/material/CircleAvatar-class.html
leading: new CircleAvatar(
backgroundColor: Colors.brown.shade800,
child: new Text('VR'),
),
title: new Text('Your profile'),
onTap: () {
Navigator.pushNamed(context, IntroPage.routeName);
},
),
new Divider(), */
new ListTile(
leading: const Icon(Icons.whatshot),
title: new Text('Active fires'),
title: new Text(S.of(context).activeFires),
onTap: () {
Navigator.pushNamed(context, ActiveFiresPage.routeName);
},
),
new ListTile(
leading: const Icon(Icons.notifications_active),
title: new Text('Notify a fire'),
title: new Text(S.of(context).notifyAFire),
onTap: () {
// Then close the drawer
Navigator.pushNamed(context, Sandbox.routeName);
@ -70,41 +60,31 @@ Widget mainDrawer(BuildContext context) {
new Divider(),
new ListTile(
leading: const Icon(Icons.favorite),
title: new Text('Support this initiative'),
title: new Text(S.of(context).supportThisInitiative),
onTap: () {
// Then close the drawer
Navigator.pushNamed(context, '/subscriptions');
},
),
globals.isDevelopment ?
new ListTile(
leading: const Icon(Icons.bug_report),
title: new Text('Sandbox'),
onTap: () {
Navigator.pushNamed(context, Sandbox.routeName);
},
),
new ListTile(
// https://material.io/tools/icons/?style=baseline
leading: const Icon(Icons.settings),
title: new Text('Settings'),
onTap: () {
// Update the state of the app
// ...
// Then close the drawer
Navigator.pop(context);
},
),
): null,
new AboutListTile(
icon: globals.appIcon,
applicationName: globals.appName,
applicationName: S.of(context).appName,
applicationVersion: globals.appVersion,
applicationIcon: globals.appMediumIcon,
applicationLegalese: globals.appLicense,
applicationLegalese: S.of(context).appLicense(DateTime.now().year.toString()),
aboutBoxChildren: <Widget> [
// new Text('What?')
]
// FIXME
)
],
])
);
}

View file

@ -3,22 +3,22 @@ import 'package:flutter/material.dart';
import 'dart:async';
import 'basicLocation.dart';
import 'globals.dart' as globals;
import 'generated/i18n.dart';
Future<BasicLocation> openPlacesDialog(BuildContext context) async {
Future<BasicLocation> openPlacesDialog(GlobalKey<ScaffoldState> sc) async {
Mode _mode = Mode.overlay;
GoogleMapsPlaces _places = new GoogleMapsPlaces(globals.gmapKey);
Prediction p = await showGooglePlacesAutocomplete(
context: context,
hint: 'Type the name of a place, region, etc',
context: sc.currentContext,
hint: S.of(sc.currentContext).typeTheNameOfAPlace,
apiKey: globals.gmapKey,
onError: (res) {
/* homeScaffoldKey.currentState.showSnackBar(
/* sc.currentState.showSnackBar(
new SnackBar(content: new Text(res.errorMessage))); */
print('Error $res');
},
mode: _mode,
// FIXME
language: "es",
language: Localizations.localeOf(sc.currentContext).languageCode,
components: [
// This limit the search too much
// new Component(Component.country, "es")

View file

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'colors.dart';
import 'package:comunes_flutter/comunes_flutter.dart';
import 'package:padder/padding.dart';
import 'package:fluttery/framing.dart';
import 'package:flutter/material.dart';
import 'colors.dart';
import 'generated/i18n.dart';
typedef void SlideCallback(int distance);
@ -25,12 +25,12 @@ class _FireDistanceSliderState extends State<FireDistanceSlider> {
this._sliderValue = initialValue;
}
sizeText(_sliderValue) =>
new Text('Subscribe to $_sliderValue км around this area',
sizeText(sliderValue) =>
new Text(S.of(context).subscribeToValueAroundThisArea(sliderValue.toString()),
style: new TextStyle(color: Colors.black87));
warningText(_sliderValue) => _sliderValue >= 50
? new Text('Warning: this is a very large area',
warningText(sliderValue) => _sliderValue >= 50
? new Text(S.of(context).warningThisIsAVeryLargeArea,
style: new TextStyle(color: fires900))
: new Text('');

View file

@ -4,16 +4,21 @@ description: All Against Fire
dependencies:
flutter:
sdk: flutter
# https://pub.dartlang.org/packages/flutter
# utils
# i18n
flutter_localizations:
sdk: flutter
intl: "^0.15.6"
# https://pub.dartlang.org/packages/flutter
# utils
shared_preferences: "^0.4.2"
http: "^0.11.3+16"
simple_moment: "^0.0.3"
just_debounce_it: "^1.0.4"
comunes_flutter:
path: /home/vjrj/dev/comunes_flutter
version: "^0.0.9"
version: "^0.0.10"
# maps, geo, etc
flutter_map: "^0.0.1"
flutter_google_places_autocomplete: "^0.0.4"

33
res/values/strings_en.arb Normal file
View file

@ -0,0 +1,33 @@
{
"AvoidThisStringsIfisNotPlural": "Zero One Two Few Many Other",
"appName": "All Against The Fire!",
"addYourCurrentPosition": "Add your current position",
"addSomePlace": "Add some other place",
"addedThisLocation": "You have already added this location",
"firesNearPlace": "Fires near other place",
"firesInTheWorld": "Active fires in the world",
"firesInYourPlaces": "Active fires in your places",
"youDeletedThisPlace": "You deleted this place",
"UNDO": "UNDO",
"toDeleteThisPlace": "Slide horizontally to delete this place",
"toFiresNotifications": "Subscribe to fires notifications",
"confirm": "Confirm",
"unsubscribe": "Unsubscribe",
"firesAroundThisArea": "$numFires fires at $kmAround км around this area",
"noFiresAroundThisArea": "There is no fires at $kmAround км around this area",
"activeFiresWorldWide": "$activeFires active fires worldwide",
"updatedLastCheck": "Updated $lastCheck",
"appLicense": "(c) 2017-$thisYear Comunes Association under the GNU Affero GPL v3",
"activeFires": "Active fires",
"notifyAFire": "Notify a fire",
"supportThisInitiative": "Support this initiative",
"chooseAPlace": "Choose a place",
"chooseAWatchRadio": "Choose a watch radio",
"getAlertsOfFiresinThatArea": "Get alerts of fires in that area",
"alertWhenThereIsAFire": "Alert when there is a fire",
"notPermsUbication": "We don't have permission to get your location",
"isYourUbicationEnabled": "I cannot get your current location. It's your ubication enabled?",
"typeTheNameOfAPlace": "Type the name of a place, region, etc",
"subscribeToValueAroundThisArea": "Subscribe to $sliderValue км around this area",
"warningThisIsAVeryLargeArea": "Warning: this is a very large area"
}

33
res/values/strings_es.arb Normal file
View file

@ -0,0 +1,33 @@
{
"AvoidThisStringsIfisNotPlural": "Zero One Two Few Many Other",
"appName": "¡Tod@s contra el Fuego!",
"addYourCurrentPosition": "Añade tu ubicación actual",
"addSomePlace": "Añade otro lugar",
"addedThisLocation": "Ya has añadido este lugar antes",
"firesNearPlace": "Fuegos cercanos a ti",
"firesInTheWorld": "Fuegos en el mundo",
"firesInYourPlaces": "Fuegos en tus lugares",
"youDeletedThisPlace": "Has borrado este lugar",
"UNDO": "DESHACER",
"toDeleteThisPlace": "Desliza horizontalmente para borrar este lugar",
"toFiresNotifications": "Suscríbete a alertas de fuegos",
"confirm": "Confirmar",
"unsubscribe": "Desuscríbete",
"firesAroundThisArea": "$numFires fuegos a $kmAround км a la redonda",
"noFiresAroundThisArea": "No hay fuegos a $kmAround км a la redonda",
"activeFiresWorldWide": "$activeFires fuegos activos en el mundo",
"updatedLastCheck": "Actualizado $lastCheck",
"appLicense": "(c) 2017-$thisYear Asociación Comunes bajo licencia GNU Affero GPL v3",
"activeFires": "Fuegos activos",
"notifyAFire": "Notificar un fuego",
"supportThisInitiative": "Apoya esta iniciativa",
"chooseAPlace": "Elige un lugar",
"chooseAWatchRadio": "Elige un radio de vigilancia",
"getAlertsOfFiresinThatArea": "Recibe alertas de fuegos en esa zona",
"alertWhenThereIsAFire": "Alerta cuando hay un fuego",
"notPermsUbication": "No tenemos permisos para conocer tu ubicación",
"isYourUbicationEnabled": "No podemos saber tu ubicación actual. ¿Están los servicios de ubicación en tu móvil activados?",
"typeTheNameOfAPlace": "Escribe el nombre de un lugar, zona, etc",
"subscribeToValueAroundThisArea": "Suscríbete a $sliderValue км a la redonda",
"warningThisIsAVeryLargeArea": "Cuidado: esta zona es muy grande"
}