Поправил отзывчивость кнопок валют на экране валюты, исправил отображение названий валюты на экранах проведения покупки (рубль, рубля, рублей) для русской локали
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:convert';
|
||||
@@ -34,8 +35,21 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
@override void onStart() {
|
||||
getLoyalty(user['loyalty_url']);
|
||||
@override Widget build(BuildContext ctx) {
|
||||
if (helper == null) {
|
||||
helper = new SqliteHelper();
|
||||
helper.open().then((_) {
|
||||
if (app == null) {
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
app = flavor;
|
||||
setState(() {
|
||||
getLoyalty(user['loyalty_url']);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return getMainWidget();
|
||||
}
|
||||
|
||||
bool purchaseInProgress = false;
|
||||
@@ -126,8 +140,8 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
this.loyalty = '${user['discount']}%';
|
||||
} else {
|
||||
List amountToBonus = bonuses['amount_to_bonus'];
|
||||
double loyalityVal = (double.parse(amountToBonus[1]) / amountToBonus[0]) * 100;
|
||||
this.loyalty = '${loyalityVal.toStringAsFixed(0)}%';
|
||||
double loyaltyVal = (double.parse(amountToBonus[1]) / amountToBonus[0]) * 100;
|
||||
this.loyalty = '${loyaltyVal.toStringAsFixed(0)}%';
|
||||
}
|
||||
});
|
||||
}).catchError((error) {
|
||||
@@ -136,6 +150,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Переделать? чтобы работало хорошо
|
||||
String _cleanupNumber(String text){
|
||||
String tmp = text
|
||||
.replaceAll(' ', '')
|
||||
@@ -174,23 +189,25 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
onPurchaseClick() {
|
||||
String val = _parseSum(controller.text);
|
||||
showDialog(context: context, child: new AlertDialog(
|
||||
title: new Text(StringsLocalization.confirmation()),
|
||||
content: new Text(StringsLocalization.confirmPurchase(val)),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: () {
|
||||
purchase(val);
|
||||
},
|
||||
)
|
||||
]));
|
||||
helper.getCurrency().then((currency) {
|
||||
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: () {
|
||||
purchase(val);
|
||||
},
|
||||
)
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
purchase(String sumTotal) async {
|
||||
@@ -221,14 +238,13 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
print(response.body);
|
||||
Map parsedMap = JSON.decode(response.body);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
|
||||
if (parsedMap.containsKey('errors')) {
|
||||
List<String> errors = parsedMap['errors'];
|
||||
// TODO: ПОказывать сообщение с ошибкой!
|
||||
Scaffold.of(context).showSnackBar(new SnackBar(content: new Text(errors[0])));
|
||||
} else {
|
||||
helper.close().then((_) {
|
||||
Navigator.of(context).pop();
|
||||
pushRouteReplacement(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name']));
|
||||
});
|
||||
pushRouteReplacement(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name'], helper, app));
|
||||
}
|
||||
|
||||
}).catchError((error) {
|
||||
|
||||
Reference in New Issue
Block a user