This commit is contained in:
Semyon Babushkin
2017-10-12 13:48:18 +03:00
parent 7b20747157
commit 1b98b320d2

View File

@@ -42,6 +42,7 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
int bonusMinus = 0; int bonusMinus = 0;
int currency; int currency;
bool showBonus; bool showBonus;
String flavor;
@override String getTitle() { @override String getTitle() {
return StringsLocalization.carryingPurchase(); return StringsLocalization.carryingPurchase();
@@ -59,26 +60,27 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
}); });
}); });
} }
if (showBonus == null) { if (this.flavor == null) {
platform.invokeMethod('showBonus').then((showBonus) { platform.invokeMethod('getFlavor').then((flavor) {
setState(() { setState(() {
this.showBonus = showBonus; this.flavor = flavor;
if (showBonus == true) { // if (showBonus == true) {
if (this.details['sum_bonus'] is String) { //
String regexString = r'(\d+) начислено, (\d+).*'; // }
RegExp regExp = new RegExp(regexString); if (this.details['sum_bonus'] is String) {
var matches = regExp.allMatches(this.details['sum_bonus']); String regexString = r'(\d+) начислено, (\d+).*';
if(matches.length != 0) { RegExp regExp = new RegExp(regexString);
var match = matches.elementAt(0); // => extract the first (and only) match var matches = regExp.allMatches(this.details['sum_bonus']);
this.bonusPlus = int.parse(match.group(1)); if(matches.length != 0) {
this.bonusMinus = int.parse(match.group(2)); var match = matches.elementAt(0); // => extract the first (and only) match
} this.bonusPlus = int.parse(match.group(1));
this.bonusMinus = int.parse(match.group(2));
} }
}
if (this.details['sum_bonus'] is int) { if (this.details['sum_bonus'] is int) {
this.bonusPlus = this.details['sum_bonus']; this.bonusPlus = this.details['sum_bonus'];
//bonusMinus = this.details['sum_bonus']; //bonusMinus = this.details['sum_bonus'];
}
} }
}); });
}); });
@@ -92,17 +94,19 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
List <Widget> widgetList = <Widget>[]; List <Widget> widgetList = <Widget>[];
widgetList.add(getValueWithDescription(StringsLocalization.buyer(), username)); widgetList.add(getValueWithDescription(StringsLocalization.buyer(), username));
widgetList.add(getSuccessMessage()); widgetList.add(getSuccessMessage());
if (showBonus == true) {
if (bonusPlus > 0) { if (bonusPlus > 0) {
widgetList.add(getValueWithDescription(StringsLocalization.bonusPlus(), bonusPlus.toString())); widgetList.add(getValueWithDescription(StringsLocalization.bonusPlus(), bonusPlus.toString()));
} }
if (bonusMinus > 0) { if (bonusMinus > 0) {
widgetList.add(getValueWithDescription(StringsLocalization.bonusMinus(), bonusMinus.toString())); widgetList.add(getValueWithDescription(StringsLocalization.bonusMinus(), bonusMinus.toString()));
} }
if (this.flavor != 'autobonus') {
widgetList.add(getValueWithDescription(StringsLocalization.discountRate(), '${details['discount']}%'));
widgetList.add(getValueWithDescription(StringsLocalization.discountSum(), '${details['sum_discount']}'));
} }
widgetList.add(getValueWithDescription(StringsLocalization.discountRate(), '${details['discount']}%'));
widgetList.add(getValueWithDescription(StringsLocalization.discountSum(), '${details['sum_discount']}'));
// widgetList.add( new Expanded(child: new Center())); // widgetList.add( new Expanded(child: new Center()));
this.coupons.forEach((couponItem) { this.coupons.forEach((couponItem) {
widgetList.add(getCoupons(couponItem)); widgetList.add(getCoupons(couponItem));