Поправил много неприятных косяков

This commit is contained in:
Ivan Murashov
2017-07-27 18:47:42 +03:00
parent 303f3e2ff3
commit 311d532898
9 changed files with 116 additions and 69 deletions

View File

@@ -35,17 +35,16 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
String loyality = '';
@override Widget getScreenContent() {
return new Container(height: 412.0,
child: new ListView(reverse: true, children: <Widget>[
new Column(children: <Widget>[
getValueWithTitle('ФИО', user['first_name']),
return new Column(
children: <Widget>[new Expanded(child: new ListView(children: <Widget>[
getValueWithTitle('ФИО', user['first_name'] == null ? '' : user['first_name']),
getValueWithTitle('Карта', card),
getValueWithTitle('Вознаграждение', loyality),
getHintLabel(),
getDecoratedTextWidget(),
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildRaisedButton(context, 'ЗАВЕРШИТЬ ПОКУПКУ', () => onPurchaseClick(context))),
buildButton(new EdgeInsets.only(top: 24.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildFlatButton(context, 'СКАНИРОВАТЬ', primaryColor))])
].reversed.toList()));
buildButton(new EdgeInsets.only(top: 24.0, left: buttonVerticalMargin, right: buttonVerticalMargin), buildFlatButton(context, 'СКАНИРОВАТЬ', primaryColor))
]))]);
}
@override String getTitle() {
@@ -68,7 +67,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
@override handleUserInput(String tmpString) {
setState(() {
tmpString = tmpString.replaceAll('-', '');
tmpString = tmpString.replaceAll(', ', '');
tmpString = tmpString.replaceAll(',', '');
print(tmpString);
if (tmpString.contains('.')) {
int dotIndex = tmpString.indexOf('.');
@@ -88,10 +87,13 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
getLoyality(String url) {
var headers = {
'DM-Authorization': 'dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08',
'Authorization': 'dmtoken ${token}'
};
print(url);
print(token);
var headers = {
'DM-Authorization': 'dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08',
'Authorization': 'dmtoken ${token}'
};
httpClient.get(url, headers: headers).then((response) {
@@ -102,11 +104,15 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
setState(() {
if (type == 'amount') {
this.loyality = user['discount'];
this.loyality = '${user['discount']}%';
} else {
List bonusToAmount = bonuses['bonus_to_amount'];
this.loyality = (bonusToAmount[1].toInt() / bonusToAmount[0].toInt() ).toString();
List amountToBonus = bonuses['amount_to_bonus'];
// print(amountToBonus[0]);
// print(amountToBonus[1]);
this.loyality = '${(amountToBonus[0] / double.parse(amountToBonus[1])).toStringAsFixed(0)}%';
}
});
}).catchError((error) {
@@ -170,7 +176,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
print(response.body);
Navigator.of(context).pop();
pushRoute(context, new PurchaseSuccessScreen(sum_total, user['first_name']));
pushRoute(context, new PurchaseSuccessScreen(sum_total, user['first_name'] == null ? '' : user['first_name']));
}).catchError((error) {
print(error.toString());