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