Локализация экрана настроек, удалил лишние конфигурации сборки

This commit is contained in:
Ivan Murashov
2017-09-11 11:41:20 +03:00
parent 0dc8ab5da0
commit 0dde204dcd
12 changed files with 131 additions and 57 deletions

View File

@@ -220,7 +220,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
print(response.body);
helper.close().then((_) {
Navigator.of(context).pop();
pushRoute(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name']));
pushRouteReplacement(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name']));
});
}).catchError((error) {

View File

@@ -87,7 +87,7 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
if (response.statusCode == 201) {
helper.createSession(dinCode, posID, parsedMap['token']).then((_) {
helper.close();
pushRoute(context, new FinishRegistrationScreen());
pushRouteReplacement(context, new FinishRegistrationScreen());
});
} else {
setState(() {

View File

@@ -17,10 +17,10 @@ class SettingsScreen extends StatefulWidget {
class MenuItem {
MenuItem();
// Заголовок пункта меню и выбранное значение.
String title, selectedValue;
String title;
String selectedValue;
MenuItem(this.title, this.selectedValue);
}
class _SettingsState extends BaseState<SettingsScreen> {
@@ -31,16 +31,11 @@ class _SettingsState extends BaseState<SettingsScreen> {
if (menuItems == null) {
helper.getSettings().then((info) {
setState(() {
print("load settings");
menuItems = [new MenuItem(), new MenuItem()];
menuItems[0].title = StringsLocalization.locale();
menuItems[0].selectedValue = info["locale"];
menuItems[1].title = StringsLocalization.currency();
menuItems[1].selectedValue = info["currency"].toString();
menuItems = [
new MenuItem(StringsLocalization.locale(), getLocaleTitle(info["locale"])),
new MenuItem(StringsLocalization.currency(), getCurrencyTitle(info["currency"]))
];
});
});
}
@@ -53,17 +48,35 @@ class _SettingsState extends BaseState<SettingsScreen> {
: new ListView(children: getSettings());
}
@override
List<Widget> getMenuButtons() {
return null;
}
List<Widget> getSettings() {
List<Widget> widgets = new List();
for (MenuItem item in menuItems) {
widgets.add(new Row(children: [
new Text(item.title, textAlign: TextAlign.left),
new Text(item.selectedValue,textAlign: TextAlign.right),
new Image.asset(settings_arrow_png, width: 28.0, height: 28.0, alignment: FractionalOffset.centerRight)]));
widgets.add(getSettingsItem(item));
}
return widgets;
}
Widget getSettingsItem(MenuItem item) {
return new Container(
margin: const EdgeInsets.all(16.0),
child: new Row(children: <Widget>[
new Expanded(child: new Text(item.title)),
new Text(item.selectedValue),
getArrow()])
);
}
Widget getArrow() {
return new Image.asset(settings_arrow_png,
width: 28.0,
height: 28.0);
}
@override
String getTitle() {
return StringsLocalization.settings();

View File

@@ -1,3 +1,4 @@
import 'package:checker/strings.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:intl/intl.dart';
@@ -26,7 +27,6 @@ class _SplashScreenState extends BaseState<SplashScreen> {
helper.getSettings().then((info) {
if (info == null) {
platform.invokeMethod('getLocale').then((locale) {
Intl.defaultLocale = locale;
platform.invokeMethod('getCurrency').then((currency) {
helper.createAppInfo(locale, currency).then((_) {
showNext();
@@ -34,7 +34,12 @@ class _SplashScreenState extends BaseState<SplashScreen> {
});
});
} else {
showNext();
helper.getLocale().then((locale) {
Intl.defaultLocale = locale;
StringsLocalization.load(locale).then((l) {
showNext();
});
});
}
});
}
@@ -90,7 +95,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
// необходимо запустить регистрацию кассы.
if (token == null) {
await helper.close();
pushRoute(context, new RegistrationScreen());
pushRouteReplacement(context, new RegistrationScreen());
} else {
if (await platform.invokeMethod('isOnline')) {
checkTokenStatus(token).then((statusResponse) {
@@ -115,7 +120,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
if (code == 404) {
helper.clear().then((result) {
helper.close().then((_) {
pushRoute(context, new RegistrationScreen());
pushRouteReplacement(context, new RegistrationScreen());
});
});
} else {
@@ -148,7 +153,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
createToken(merchantID, posID).then((response) {
if (response.statusCode == 409) {
helper.close();
pushRoute(context, new FinishRegistrationScreen());
pushRouteReplacement(context, new FinishRegistrationScreen());
} else if (response.statusCode == 201) {
clearToken(response, helper);
}
@@ -163,7 +168,7 @@ class _SplashScreenState extends BaseState<SplashScreen> {
deleteToken(parsedMap['token']).then((_) {
helper.close();
Navigator.of(context).pop(); // Убираем текущий route
pushRoute(context, new RegistrationScreen()); // Запускаем регистрацию
pushRouteReplacement(context, new RegistrationScreen()); // Запускаем регистрацию
}).catchError((error) {
helper.close();
print(error.toString());