В бд добавлена таблица настроек, данные для настроек берутся из базы
This commit is contained in:
@@ -3,8 +3,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'common.dart';
|
||||
import 'consts.dart';
|
||||
import 'package:checker/common.dart';
|
||||
import 'package:checker/consts.dart';
|
||||
import 'package:checker/screens/settings.dart';
|
||||
import 'package:checker/screens/faq.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:checker/db.dart';
|
||||
|
||||
abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
@@ -21,24 +24,23 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
String error;
|
||||
|
||||
/// Введенное пользователем значение.
|
||||
String textFieldValue = '';
|
||||
String dinCode = '';
|
||||
|
||||
@override Widget build(BuildContext ctx) {
|
||||
|
||||
platform.invokeMethod('getLocale').then((locale) {
|
||||
Intl.defaultLocale = locale;
|
||||
if (app == null) {
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
setState(() {
|
||||
if (helper == null) {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
if (app == null) {
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
app = flavor;
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_){
|
||||
setState(() {
|
||||
onStart();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return getMainWidget();
|
||||
}
|
||||
@@ -67,7 +69,9 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
Widget getScreenContent();
|
||||
|
||||
/// Возвращает заголовок для AppBar
|
||||
String getTitle();
|
||||
String getTitle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
AppBar getAppBar() {
|
||||
return new AppBar(title: new Text(getTitle(), style: new TextStyle(fontSize: 18.0)),
|
||||
@@ -76,29 +80,44 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
|
||||
List<Widget> getMenuButtons() {
|
||||
return <Widget>[
|
||||
new PopupMenuButton(
|
||||
new PopupMenuButton<int>(
|
||||
onSelected: onOptionsItemClick,
|
||||
itemBuilder: (BuildContext context) {
|
||||
[
|
||||
new PopupMenuItem(
|
||||
child: new Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
new Image.asset(
|
||||
settings_png, width: 48.0, height: 48.0),
|
||||
new Image.asset(help_png, width: 48.0, height: 48.0),
|
||||
new Image.asset(logout_png, width: 48.0, height: 48.0),
|
||||
]))
|
||||
return [new PopupMenuItem(
|
||||
value: 0,
|
||||
child: getMenuItem(settings_png, StringsLocalization.settings())),
|
||||
new PopupMenuItem(
|
||||
value: 1,
|
||||
child: getMenuItem(help_png, StringsLocalization.help())),
|
||||
new PopupMenuItem(
|
||||
value: 2,
|
||||
child: getMenuItem(logout_png, StringsLocalization.logout()))
|
||||
];
|
||||
}
|
||||
)];
|
||||
}
|
||||
|
||||
Widget getFaqButton() {
|
||||
return new IconButton(icon: new Icon(Icons.help_outline), onPressed: () => faq(context, false));
|
||||
void onOptionsItemClick(int index) {
|
||||
switch (index) {
|
||||
case 0: {
|
||||
pushRoute(context, new SettingsScreen());
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
pushRoute(context, new FAQScreen(false));
|
||||
break;
|
||||
}
|
||||
case 0: {
|
||||
logout(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget getLogoutButton() {
|
||||
return new IconButton(icon: new Image.asset(logout_png, height: iconHeight, width: iconHeight), onPressed: () => logout(context));
|
||||
Widget getMenuItem(String image, String text) {
|
||||
return new Row(children: [
|
||||
new Image.asset(image, width: 28.0, height: 28.0),
|
||||
new Container(padding: new EdgeInsets.only(left: 8.0), child: new Text(text))
|
||||
]);
|
||||
}
|
||||
|
||||
/// Возврвщает контейнер, внутри которого Text с подсказкой.
|
||||
@@ -112,7 +131,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
|
||||
/// Возвращает подсказку, либо ошибку, если введенные в поле ввода данные неверны.
|
||||
String getHintString() {
|
||||
if (textFieldValue.length == 0 && error == null) {
|
||||
if (dinCode.length == 0 && error == null) {
|
||||
return ' ';
|
||||
} else if (error != null) {
|
||||
return error;
|
||||
@@ -130,7 +149,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
/// Смена состояния экрана при изменении текста в поле ввода.
|
||||
void handleUserInput(String text) {
|
||||
setState(() {
|
||||
textFieldValue = text;
|
||||
dinCode = text;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user