На экране проведения покупки правильно обрабатывается сумма покупки, передается на экран подтверждения

This commit is contained in:
Ivan Murashov
2017-07-24 18:07:30 +03:00
parent 355c05cf06
commit 080c7ec471
9 changed files with 200 additions and 140 deletions

View File

@@ -11,6 +11,8 @@ abstract class BaseState<T> extends State<T> {
String error = null;
String textFieldValue = "";
TextEditingController controller = new TextEditingController();
@override Widget build(BuildContext context) {
return new Scaffold(appBar: getAppBar(context), body: getBody(context));
}
@@ -57,6 +59,13 @@ abstract class BaseState<T> extends State<T> {
}
}
/// Смена состояния экрана при изменении текста в поле ввода.
handleUserInput(String text) {
setState(() {
textFieldValue = text;
});
}
/// Метод возвращает контейнер с установленными отступами, в котором размещен TextField обернутый в BoxDecoration.
getDecoratedTextWidget() {
return new Container(margin: new EdgeInsets.only(left: verticalMargin, right: verticalMargin),
@@ -76,16 +85,21 @@ abstract class BaseState<T> extends State<T> {
/// Метод возвращает BoxDecoration для _getDecoratedInputField
getDecoraionForTextWidget() {
return new BoxDecoration(color: textFieldBackground,
return new BoxDecoration(color: getTextFilledBackground(),
border: new Border.all(color: textBorderColor, width: 1.0,),
borderRadius: new BorderRadius.all(new Radius.circular(4.0)));
}
Color getTextFilledBackground() {
return const Color(0xffefefef);
}
Widget getTextWidget() {
return new TextField(keyboardType: TextInputType.number,
decoration: new InputDecoration.collapsed(hintText: getHint(),
hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)),
onChanged: (text) => _handleUserInput(text));
controller: controller,
onChanged: (text) => handleUserInput(text));
}
/// Индикация ...
@@ -93,5 +107,35 @@ abstract class BaseState<T> extends State<T> {
return new Center(child: loading ? new CircularProgressIndicator() : null);
}
Widget getValueWithTitle(String title, String value) {
return new Container(padding: new EdgeInsets.only(left: verticalMargin, right: verticalMargin, top: 18.0),
child: new Column(children: <Widget>[
new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[new Text(title, textAlign: TextAlign.left, style: new TextStyle(color: greyTextColor, fontSize: 14.0))]),
new Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[new Text(value, textAlign: TextAlign.left, style: new TextStyle(color: Colors.black, fontSize: 20.0))])
]));
}
Widget buildButton(EdgeInsets margin, Widget widget) {
return new Container(margin: margin, height: buttonHeight, child: new Row(children: <Widget>[new Expanded(child: widget)]));
}
Widget buildRaisedButton(BuildContext context, String text, VoidCallback onPressed) {
return new RaisedButton(child: new Text(text,
style: new TextStyle(color: Colors.white)),
onPressed: onPressed,
color: primaryColor);
}
Widget buildFlatButton(BuildContext context, String title, Color textColor) {
return new Container(height: buttonHeight, child: new FlatButton(child: new Text(title,
style: new TextStyle(color: textColor)),
onPressed: () => startScanner(context)),
decoration: _getDecoraionForScanButton());
}
_getDecoraionForScanButton() {
return new BoxDecoration(
border: new Border.all(color: primaryColor, width: 1.0),
borderRadius: new BorderRadius.all(new Radius.circular(4.0)));
}
}