issue 10305, final
This commit is contained in:
@@ -136,6 +136,10 @@ public abstract class AbstractScannerActivity extends AppCompatActivity {
|
||||
private void initManualInput() {
|
||||
EditText manualInput = (EditText) findViewById(R.id.manual_input);
|
||||
|
||||
//if (BuildConfig.applicationId == "com.dinect.develop") {
|
||||
// для удобства, чтоб не вводить постоянно руками при разработке
|
||||
//manualInput.setText("4620011139016317023320337");
|
||||
//}
|
||||
|
||||
manualInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
|
||||
@@ -143,6 +143,25 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Метод возвращает контейнер только с названием элемента
|
||||
Widget getItemTitle(String title) {
|
||||
return new Container(
|
||||
padding: new EdgeInsets.only(
|
||||
left: verticalMargin,
|
||||
right: verticalMargin,
|
||||
top: 18.0
|
||||
),
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: getDescriptionWidget(title)
|
||||
),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/// Возвращает поле ввода.
|
||||
/// Переопределяется для использования на экранах регистрации и проведения покупки.
|
||||
Widget getTextWidget() {
|
||||
@@ -181,6 +200,8 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
|
||||
return new Container(height: containerHeight, child: new Image.asset(Resources.getLogo(app), width: imageWidth));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Возвращает текстовое поле, с однострочным пояснением над ним.
|
||||
Widget getValueWithDescription(String title, String value) {
|
||||
return new Container(padding: new EdgeInsets.only(left: verticalMargin, right: verticalMargin, top: 18.0),
|
||||
|
||||
@@ -41,6 +41,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"bonus_plus" : MessageLookupByLibrary.simpleMessage("Bonus points"),
|
||||
"bonus_minus" : MessageLookupByLibrary.simpleMessage("Bonus was charged"),
|
||||
"bonus_hint" : MessageLookupByLibrary.simpleMessage("Points to charge"),
|
||||
"coupons_used" : MessageLookupByLibrary.simpleMessage("Coupons were used"),
|
||||
"bonus_explanation" : MessageLookupByLibrary.simpleMessage("If not set, points will be added"),
|
||||
"scan" : MessageLookupByLibrary.simpleMessage("Scan"),
|
||||
"sign_up" : MessageLookupByLibrary.simpleMessage("Sign Up"),
|
||||
|
||||
@@ -41,6 +41,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"bonus_plus" : MessageLookupByLibrary.simpleMessage("Бонусов начислено"),
|
||||
"bonus_minus" : MessageLookupByLibrary.simpleMessage("Бонусов списано"),
|
||||
"bonus_hint" : MessageLookupByLibrary.simpleMessage("Сколько баллов списать?"),
|
||||
"coupons_used" : MessageLookupByLibrary.simpleMessage("Были погашены купоны"),
|
||||
"bonus_explanation" : MessageLookupByLibrary.simpleMessage("Если не указано сколько баллов списать, баллы будут начислены"),
|
||||
"scan" : MessageLookupByLibrary.simpleMessage("Сканировать"),
|
||||
"sign_up" : MessageLookupByLibrary.simpleMessage("Зарегистрироваться"),
|
||||
|
||||
@@ -51,6 +51,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
bool purchaseInProgress = false;
|
||||
Map user;
|
||||
String card = '';
|
||||
String flavor = '';
|
||||
String loyalty = '';
|
||||
String bonus = '';
|
||||
bool dataLoaded = false;
|
||||
@@ -74,8 +75,9 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
widgets.add(getInputField()); // Нельзя добавить еще одно поле таким же способом
|
||||
|
||||
if (this.flavor != 'autobonus') {
|
||||
widgets.add(getBonusInputField());
|
||||
|
||||
}
|
||||
|
||||
widgets.add(wrapButton(getScreenMargins(36.0), getCompleteButton()));
|
||||
widgets.add(wrapButton(
|
||||
@@ -155,6 +157,8 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
borderRadius: new BorderRadius.all(new Radius.circular(4.0))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
String getTitle() {
|
||||
return StringsLocalization.carryingPurchase();
|
||||
@@ -186,11 +190,13 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
requestLoyalty(String url) async {
|
||||
bool showBonus = await platform.invokeMethod('showBonus');
|
||||
String flavor = await platform.invokeMethod('getFlavor');
|
||||
if (await platform.invokeMethod('isOnline') && !this.dataLoaded) {
|
||||
getLoyaltyRequest(url, helper).then((response) {
|
||||
print(response);
|
||||
this.dataLoaded = true;
|
||||
setState(() {
|
||||
this.flavor = flavor;
|
||||
setBonuses(JSON.decode(response.body), showBonus );
|
||||
});
|
||||
}).catchError((error) {
|
||||
@@ -258,6 +264,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
purchase(val);
|
||||
},
|
||||
)
|
||||
@@ -303,32 +310,21 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
body['bonus_payment'] = bonusController.text;
|
||||
}
|
||||
|
||||
print(body['bonus_payment']);
|
||||
|
||||
var purchaseResponse;
|
||||
Map purchase;
|
||||
|
||||
try {
|
||||
purchaseResponse = await getPurchaseRequest(user['purchases_url'], body, token);
|
||||
purchase = JSON.decode(purchaseResponse.body);
|
||||
if (purchase['errors'] is List && purchase['errors'].length > 0) {
|
||||
print(purchase['errors'][0]);
|
||||
//Navigator.of(context).pop();
|
||||
apiErrorAlert(purchase['errors'][0]);
|
||||
}
|
||||
} catch(error) {
|
||||
purchaseInProgress = false;
|
||||
print(error.toString());
|
||||
|
||||
}
|
||||
|
||||
Navigator.of(context).pop();
|
||||
|
||||
if (purchase.containsKey('errors')) {
|
||||
List<String> errors = purchase['errors'];
|
||||
Scaffold
|
||||
.of(context)
|
||||
.showSnackBar(new SnackBar(content: new Text(errors[0])));
|
||||
purchaseInProgress = false;
|
||||
apiErrorAlert(errors[0]);
|
||||
} else {
|
||||
var couponsResponse;
|
||||
|
||||
|
||||
@@ -64,9 +64,7 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
platform.invokeMethod('getFlavor').then((flavor) {
|
||||
setState(() {
|
||||
this.flavor = flavor;
|
||||
// if (showBonus == true) {
|
||||
//
|
||||
// }
|
||||
|
||||
if (this.details['sum_bonus'] is String) {
|
||||
String regexString = r'(\d+) начислено, (\d+).*';
|
||||
RegExp regExp = new RegExp(regexString);
|
||||
@@ -80,7 +78,6 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
|
||||
if (this.details['sum_bonus'] is int) {
|
||||
this.bonusPlus = this.details['sum_bonus'];
|
||||
//bonusMinus = this.details['sum_bonus'];
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -108,11 +105,16 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
}
|
||||
|
||||
// widgetList.add( new Expanded(child: new Center()));
|
||||
if (this.coupons.length > 0) {
|
||||
widgetList.add(getItemTitle(StringsLocalization.couponsUsed()));
|
||||
this.coupons.forEach((couponItem) {
|
||||
widgetList.add(getCoupons(couponItem));
|
||||
});
|
||||
}
|
||||
|
||||
widgetList.add(wrapButton(getScreenMargins(74.0), getScanButton()));
|
||||
|
||||
|
||||
widgetList.add(wrapButton(getScreenMargins(174.0), getScanButton()));
|
||||
|
||||
return new ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) => widgetList[index],
|
||||
@@ -139,12 +141,16 @@ class PurchaseSuccessScreenState<T> extends BaseState<PurchaseSuccessScreen> {
|
||||
}
|
||||
|
||||
getCoupons(couponItem) {
|
||||
String title = couponItem['offer_name'];
|
||||
if (title.length == 0) {
|
||||
title = couponItem['coupon_condition'].substring(0,30) + " ...";
|
||||
}
|
||||
return new Container(
|
||||
margin: new EdgeInsets.only(left: 5.0, right: 5.0, top: 5.0),
|
||||
child: new Card(
|
||||
child: new ExpansionTile(
|
||||
title: new Text(
|
||||
couponItem['offer_name'],
|
||||
title,
|
||||
style: Theme.of(context).textTheme.button.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: faqTitlesColor
|
||||
|
||||
@@ -97,6 +97,7 @@ class StringsLocalization {
|
||||
static String reward() => Intl.message('reward', name: 'reward', locale: Intl.defaultLocale);
|
||||
static String sum() => Intl.message('sum', name: 'sum', locale: Intl.defaultLocale);
|
||||
static String bonus() => Intl.message('bonus', name: 'bonus', locale: Intl.defaultLocale);
|
||||
static String couponsUsed() => Intl.message('coupons_used', name: 'coupons_used', locale: Intl.defaultLocale);
|
||||
static String carryingPurchase() => Intl.message('carry_purchase', name: 'carry_purchase', locale: Intl.defaultLocale);
|
||||
static String completePurchase() => Intl.message('complite_purchase', name: 'complite_purchase', locale: Intl.defaultLocale);
|
||||
static String scan() => Intl.message('scan', name: 'scan', locale: Intl.defaultLocale);
|
||||
|
||||
Reference in New Issue
Block a user