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 currency;
bool showBonus;
String flavor;
@override String getTitle() {
return StringsLocalization.carryingPurchase();
@@ -59,26 +60,27 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
});
});
}
if (showBonus == null) {
platform.invokeMethod('showBonus').then((showBonus) {
if (this.flavor == null) {
platform.invokeMethod('getFlavor').then((flavor) {
setState(() {
this.showBonus = showBonus;
if (showBonus == true) {
if (this.details['sum_bonus'] is String) {
String regexString = r'(\d+) начислено, (\d+).*';
RegExp regExp = new RegExp(regexString);
var matches = regExp.allMatches(this.details['sum_bonus']);
if(matches.length != 0) {
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));
}
this.flavor = flavor;
// if (showBonus == true) {
//
// }
if (this.details['sum_bonus'] is String) {
String regexString = r'(\d+) начислено, (\d+).*';
RegExp regExp = new RegExp(regexString);
var matches = regExp.allMatches(this.details['sum_bonus']);
if(matches.length != 0) {
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) {
this.bonusPlus = this.details['sum_bonus'];
//bonusMinus = this.details['sum_bonus'];
}
if (this.details['sum_bonus'] is int) {
this.bonusPlus = this.details['sum_bonus'];
//bonusMinus = this.details['sum_bonus'];
}
});
});
@@ -92,17 +94,19 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
List <Widget> widgetList = <Widget>[];
widgetList.add(getValueWithDescription(StringsLocalization.buyer(), username));
widgetList.add(getSuccessMessage());
if (showBonus == true) {
if (bonusPlus > 0) {
widgetList.add(getValueWithDescription(StringsLocalization.bonusPlus(), bonusPlus.toString()));
}
if (bonusMinus > 0) {
widgetList.add(getValueWithDescription(StringsLocalization.bonusMinus(), bonusMinus.toString()));
}
if (bonusPlus > 0) {
widgetList.add(getValueWithDescription(StringsLocalization.bonusPlus(), bonusPlus.toString()));
}
if (bonusMinus > 0) {
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()));
this.coupons.forEach((couponItem) {
widgetList.add(getCoupons(couponItem));