Исправлены баги
This commit is contained in:
@@ -28,7 +28,10 @@ class MenuItem {
|
||||
|
||||
class SettingsState extends BaseState<SettingsScreen> {
|
||||
|
||||
List<MenuItem> menuItems;
|
||||
List<MenuItem> menuItems = [
|
||||
new MenuItem('', ''),
|
||||
new MenuItem('', '')
|
||||
];
|
||||
|
||||
bool returnToScanner;
|
||||
|
||||
@@ -39,22 +42,14 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext ctx) {
|
||||
if (menuItems == null) {
|
||||
menuItems = [
|
||||
new MenuItem('', ''),
|
||||
new MenuItem('', '')
|
||||
];
|
||||
helper.getSettings().then((info) {
|
||||
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();
|
||||
});
|
||||
helper.getSettings().then((info) {
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -77,16 +72,11 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
|
||||
List<Widget> getSettings() {
|
||||
List<Widget> widgets = new List();
|
||||
if (menuItems != null) {
|
||||
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)));
|
||||
}
|
||||
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;
|
||||
@@ -115,10 +105,8 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
void onPressed(int position) {
|
||||
switch (position) {
|
||||
case 0 :
|
||||
menuItems = null;
|
||||
return pushRoute(context, new CurrenciesScreen(helper, app));
|
||||
case 1 :
|
||||
menuItems = null;
|
||||
return pushRoute(context, new LanguagesScreen(helper, app));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user