RG-3443 Экран настроек локализации
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:checker/common.dart';
|
||||
import 'package:checker/consts.dart';
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:checker/screens/currencies.dart';
|
||||
import 'package:checker/screens/languages.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -28,7 +29,10 @@ class MenuItem {
|
||||
|
||||
class SettingsState extends BaseState<SettingsScreen> {
|
||||
|
||||
List<MenuItem> menuItems = [new MenuItem(StringsLocalization.currency(), '')];
|
||||
List<MenuItem> menuItems = [
|
||||
new MenuItem(StringsLocalization.currency(), ''),
|
||||
new MenuItem(StringsLocalization.locale(), '')
|
||||
];
|
||||
|
||||
bool returnToScanner;
|
||||
|
||||
@@ -44,6 +48,7 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
if (menuItems[0].selectedValue != info['currency'].toString()) {
|
||||
setState(() {
|
||||
menuItems[0].selectedValue = info['currency'].toString();
|
||||
menuItems[1].selectedValue = info['locale'].toString();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -67,26 +72,28 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
|
||||
List<Widget> getSettings() {
|
||||
List<Widget> widgets = new List();
|
||||
for (MenuItem item in menuItems) {
|
||||
if (item.selectedValue != '') {
|
||||
widgets.add(getSettingsItem(item));
|
||||
for (int i = 0; i < menuItems.length; i++) {
|
||||
if (menuItems[i].selectedValue != '') {
|
||||
widgets.add(getSettingsItem(() => onPressed(menuItems.indexOf(menuItems[i])),
|
||||
menuItems[i].title,
|
||||
i == 0 ? getCurrencyTitle(int.parse(menuItems[i].selectedValue)) : getLocaleTitle(menuItems[i].selectedValue)));
|
||||
}
|
||||
}
|
||||
return widgets;
|
||||
}
|
||||
|
||||
Widget getSettingsItem(MenuItem item) {
|
||||
Widget getSettingsItem(VoidCallback onPressed, String title, String value) {
|
||||
return new Container(
|
||||
height: 56.0,
|
||||
padding: new EdgeInsets.only(left: 8.0),
|
||||
child: (new FlatButton(
|
||||
onPressed: () => onPressed(menuItems.indexOf(item)),
|
||||
onPressed: onPressed,
|
||||
child: new Row(children: <Widget>[
|
||||
new Expanded(child: new Text(item.title, style: new TextStyle(
|
||||
new Expanded(child: new Text(title, style: new TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: faqGrey,
|
||||
fontSize: 14.0))),
|
||||
new Text(getCurrencyTitle(int.parse(item.selectedValue)),
|
||||
new Text(value,
|
||||
style: new TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: faqGrey,
|
||||
@@ -99,6 +106,8 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
switch (position) {
|
||||
case 0 :
|
||||
return pushRoute(context, new CurrenciesScreen(helper, app));
|
||||
case 1 :
|
||||
return pushRoute(context, new LanguagesScreen(helper, app));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user