Purchase screen
This commit is contained in:
@@ -69,8 +69,8 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
Widget getScreenContent() {
|
||||
List<Widget> widgetList = [];
|
||||
widgetList.add(getValueWithDescription(
|
||||
StringsLocalization.buyer(),
|
||||
user['first_name'] == null ? '' : user['first_name']
|
||||
StringsLocalization.buyer(),
|
||||
user['first_name'] == null ? '' : user['first_name']
|
||||
));
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.card(), card));
|
||||
|
||||
@@ -115,14 +115,18 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
widgetList.add(wrapButton(getScreenMargins(36.0), getCompleteButton()));
|
||||
|
||||
widgetList.add(wrapButton(
|
||||
getScreenMargins(24.0),
|
||||
getScanButton(
|
||||
context,
|
||||
StringsLocalization.scan(),
|
||||
Resources.getPrimaryColor(app)
|
||||
)
|
||||
getScreenMargins(24.0),
|
||||
getScanButton(
|
||||
context,
|
||||
StringsLocalization.scan(),
|
||||
Resources.getPrimaryColor(app)
|
||||
)
|
||||
));
|
||||
|
||||
if (this.coupons.length == 0) {
|
||||
widgetList.add(new Container(height: 50.0,));
|
||||
}
|
||||
|
||||
listView = new ListView(children: widgetList, controller: scrollController);
|
||||
return listView;
|
||||
}
|
||||
@@ -178,19 +182,19 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
getCompleteButton() {
|
||||
return buildRaisedButton(
|
||||
StringsLocalization.completePurchase(), () => onPurchaseClick());
|
||||
StringsLocalization.completePurchase(), () => onPurchaseClick());
|
||||
}
|
||||
|
||||
Widget getScanButton(BuildContext context, String title, Color textColor) {
|
||||
return new Container(
|
||||
height: buttonHeight,
|
||||
child: new FlatButton(
|
||||
child: new Text(title, style: new TextStyle(color: textColor)),
|
||||
onPressed: () => restartScanner()),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border.all(
|
||||
color: Resources.getButtonColor(app), width: 1.0),
|
||||
borderRadius: new BorderRadius.all(new Radius.circular(4.0))));
|
||||
height: buttonHeight,
|
||||
child: new FlatButton(
|
||||
child: new Text(title, style: new TextStyle(color: textColor)),
|
||||
onPressed: () => restartScanner()),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border.all(
|
||||
color: Resources.getButtonColor(app), width: 1.0),
|
||||
borderRadius: new BorderRadius.all(new Radius.circular(4.0))));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -208,8 +212,8 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
return new TextField(
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: new InputDecoration.collapsed(
|
||||
hintText: getHintString(),
|
||||
hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)),
|
||||
hintText: getHintString(),
|
||||
hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)),
|
||||
controller: controller,
|
||||
focusNode: sumFocusNode,
|
||||
onSubmitted: (String text) {
|
||||
@@ -253,10 +257,10 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
// TODO: Переделать, если потребуется
|
||||
String _cleanupNumber(String text) {
|
||||
String tmp = text
|
||||
.replaceAll(' ', '')
|
||||
.replaceAll('-', '')
|
||||
.replaceAll(',', '.')
|
||||
.replaceAll('..', '.');
|
||||
.replaceAll(' ', '')
|
||||
.replaceAll('-', '')
|
||||
.replaceAll(',', '.')
|
||||
.replaceAll('..', '.');
|
||||
|
||||
while (tmp.indexOf('..') != -1) {
|
||||
tmp = tmp.replaceAll('..', '.');
|
||||
@@ -293,28 +297,28 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
helper.getCurrency().then((currency) {
|
||||
print(currency.toString());
|
||||
showDialog(
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
title: new Text(StringsLocalization.confirmation()),
|
||||
content:
|
||||
new Text(
|
||||
StringsLocalization.confirmPurchase(val, currency)
|
||||
),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
purchase(val);
|
||||
},
|
||||
)
|
||||
]));
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
title: new Text(StringsLocalization.confirmation()),
|
||||
content:
|
||||
new Text(
|
||||
StringsLocalization.confirmPurchase(val, currency)
|
||||
),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
purchase(val);
|
||||
},
|
||||
)
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -425,7 +429,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
this.loyalty = '${user['discount']}%';
|
||||
} else {
|
||||
double loyaltyVal = (double.parse(bonuses['amount_to_bonus'][1]) /
|
||||
bonuses['amount_to_bonus'][0]) * 100;
|
||||
bonuses['amount_to_bonus'][0]) * 100;
|
||||
this.loyalty = '${loyaltyVal.toStringAsFixed(0)}%';
|
||||
}
|
||||
|
||||
@@ -448,6 +452,8 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
// TODO: Удалить дублирующийся код.
|
||||
void buildFocusNode() {
|
||||
|
||||
var pos = this.coupons.length > 0 ? 150.0 : 100.0;
|
||||
|
||||
sumFocusNode.addListener(() {
|
||||
setState(() {
|
||||
|
||||
@@ -456,7 +462,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
}
|
||||
|
||||
if (sumFocusNode.hasFocus) {
|
||||
scrollController.animateTo(150.0, duration: new Duration(seconds: 1), curve: Curves.ease);
|
||||
scrollController.animateTo(pos, duration: new Duration(seconds: 1), curve: Curves.ease);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -470,7 +476,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
}
|
||||
|
||||
if (bonusFocusNode.hasFocus) {
|
||||
scrollController.animateTo(150.0, duration: new Duration(seconds: 1), curve: Curves.ease);
|
||||
scrollController.animateTo(pos, duration: new Duration(seconds: 1), curve: Curves.ease);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user