Локаль можно задать на этапе сборки
This commit is contained in:
@@ -18,28 +18,26 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
/// Введенное пользователем значение.
|
||||
String textFieldValue = '';
|
||||
|
||||
Strings s;
|
||||
|
||||
@override Widget build(BuildContext ctx) {
|
||||
return new Scaffold(appBar: getAppBar(ctx),
|
||||
return new Scaffold(appBar: getAppBar(),
|
||||
body: new Stack(children: <Widget>[
|
||||
getScreenContent(ctx),
|
||||
getScreenContent(),
|
||||
new Center(child: loading ? new CircularProgressIndicator() : null)
|
||||
]));
|
||||
}
|
||||
|
||||
/// Возвращает контейнер с всеми виджетами экрана.
|
||||
Widget getScreenContent(BuildContext ctx);
|
||||
Widget getScreenContent();
|
||||
|
||||
/// Возвращает заголовок для AppBar
|
||||
String getTitle(BuildContext ctx);
|
||||
String getTitle();
|
||||
|
||||
AppBar getAppBar(BuildContext ctx) {
|
||||
return new AppBar(title: new Text(getTitle(ctx), style: new TextStyle(fontSize: 18.0)),
|
||||
backgroundColor: primaryColor, actions: getMenuButtons(ctx));
|
||||
AppBar getAppBar() {
|
||||
return new AppBar(title: new Text(getTitle(), style: new TextStyle(fontSize: 18.0)),
|
||||
backgroundColor: primaryColor, actions: getMenuButtons());
|
||||
}
|
||||
|
||||
List<Widget> getMenuButtons(BuildContext context) {
|
||||
List<Widget> getMenuButtons() {
|
||||
return <Widget>[getFaqButton()];
|
||||
}
|
||||
|
||||
@@ -52,28 +50,28 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
}
|
||||
|
||||
/// Возврвщает контейнер, внутри которого Text с подсказкой.
|
||||
Widget getHintLabel(BuildContext ctx) {
|
||||
Widget getHintLabel() {
|
||||
double horizontalMargin = 8.0;
|
||||
return new Container(margin: new EdgeInsets.only(top: horizontalMargin, bottom: horizontalMargin, left: verticalMargin, right: verticalMargin),
|
||||
child: new Row(crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[new Text(getHintString(ctx), textAlign: TextAlign.left,
|
||||
children: <Widget>[new Text(getHintString(), textAlign: TextAlign.left,
|
||||
style: new TextStyle(fontWeight: FontWeight.w300, color: error == null ? greyTextColor : primaryColor, fontSize: 14.0))]));
|
||||
}
|
||||
|
||||
/// Возвращает подсказку, либо ошибку, если введенные в поле ввода данные неверны.
|
||||
String getHintString(BuildContext ctx) {
|
||||
String getHintString() {
|
||||
if (textFieldValue.length == 0 && error == null) {
|
||||
return ' ';
|
||||
} else if (error != null) {
|
||||
return error;
|
||||
} else {
|
||||
return getHint(ctx);
|
||||
return getHint();
|
||||
}
|
||||
}
|
||||
|
||||
/// Возвращает текст подсказки для поля ввода.
|
||||
/// Должен быть переопределен на экранах, на которых есть поле ввода.
|
||||
String getHint(BuildContext ctx) {
|
||||
String getHint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -85,14 +83,17 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
}
|
||||
|
||||
/// Метод возвращает контейнер с полем ввода внутри.
|
||||
Widget getInputField(BuildContext ctx) {
|
||||
Widget getInputField() {
|
||||
return new Container(margin: new EdgeInsets.only(left: verticalMargin, right: verticalMargin),
|
||||
padding: getInputFieldContainerPadding(),
|
||||
decoration: getInputFieldContainerDecoration(),
|
||||
child: new TextField(keyboardType: TextInputType.number,
|
||||
decoration: new InputDecoration.collapsed(hintText: getHint(ctx),
|
||||
hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)),
|
||||
onChanged: (text) => handleUserInput(text)));
|
||||
child: getTextWidget());
|
||||
}
|
||||
|
||||
/// Возвращает поле ввода.
|
||||
/// Переопределяется для использования на экранах регистрации и проведения покупки.
|
||||
Widget getTextWidget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Возвращат паддинги для поля ввода.
|
||||
@@ -113,7 +114,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
}
|
||||
|
||||
/// Возвращает выпуклую залитую фирменным цветом кнопку
|
||||
Widget buildRaisedButton(BuildContext context, String text, VoidCallback onPressed) {
|
||||
Widget buildRaisedButton(String text, VoidCallback onPressed) {
|
||||
return new RaisedButton(child: new Text(text,
|
||||
style: new TextStyle(color: Colors.white)),
|
||||
onPressed: onPressed,
|
||||
@@ -138,7 +139,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
|
||||
/// Возвращает список, единственный элемент которого - Text с заголовком для текстового поля.
|
||||
List<Widget> getDescriptionWidget(String title) {
|
||||
return <Widget>[new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))]
|
||||
return <Widget>[new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))];
|
||||
}
|
||||
|
||||
/// Возвращает список, единственный элемент которого - Text с информацией (размер скидки, сумма проведенной покупки).
|
||||
@@ -147,7 +148,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
}
|
||||
|
||||
/// Возвращает кнопку, обернутую набором специфичных контейнеров.
|
||||
Widget buildButton(EdgeInsets margin, Widget widget) {
|
||||
Widget wrapButton(EdgeInsets margin, Widget widget) {
|
||||
return new Container(margin: margin, height: buttonHeight, child: new Row(children: <Widget>[new Expanded(child: widget)]));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user