Исправлено переключение локали на экране сканера

This commit is contained in:
Ivan Murashov
2017-09-21 13:09:38 +03:00
parent eba8c9e642
commit afc9cde20d
12 changed files with 85 additions and 49 deletions

View File

@@ -7,6 +7,7 @@ import 'package:checker/screens/currencies.dart';
import 'package:checker/screens/languages.dart';
import 'package:checker/strings.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class SettingsScreen extends BaseScreen {
@@ -28,8 +29,8 @@ class MenuItem {
class SettingsState extends BaseState<SettingsScreen> {
List<MenuItem> menuItems = [
new MenuItem(StringsLocalization.currency(), ''),
new MenuItem(StringsLocalization.locale(), '')
new MenuItem('', ''),
new MenuItem('', '')
];
bool returnToScanner;
@@ -42,23 +43,24 @@ class SettingsState extends BaseState<SettingsScreen> {
@override Widget build(BuildContext ctx) {
helper.getSettings().then((info) {
if (menuItems != null) {
if (menuItems[0].selectedValue != info['currency'].toString()) {
setState(() {
menuItems[0].selectedValue = info['currency'].toString();
menuItems[1].selectedValue = info['locale'].toString();
});
}
}
setState(() {
menuItems[0].title = StringsLocalization.currency();
menuItems[1].title = StringsLocalization.locale();
menuItems[0].selectedValue = info['currency'].toString();
menuItems[1].selectedValue = info['locale'] == null ? Intl.defaultLocale : info['locale'].toString();
});
});
return new WillPopScope(onWillPop: onWillPop, child: getMainWidget());
}
Widget getMainWidget() {
return new Scaffold(appBar: getAppBar(),
body: getScreenContent());
}
@override
Widget getScreenContent() {
return menuItems == null
? getBackground()
: new Container(
return new Container(
margin: new EdgeInsets.only(top: 16.0),
child: new ListView(children: getSettings()));
}