Hide discount widgets for crypto flavor
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:convert';
|
||||
import 'dart:core';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:checker/resources.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
@@ -33,6 +34,9 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
TextEditingController bonusController = new TextEditingController();
|
||||
|
||||
FocusNode _focusNodeSum = new FocusNode();
|
||||
FocusNode _focusNodeBonus = new FocusNode();
|
||||
|
||||
PurchaseScreenState(SqliteHelper helper, String app, String userString, String card) : super(helper, app) {
|
||||
this.user = JSON.decode(userString);
|
||||
this.card = card;
|
||||
@@ -56,7 +60,6 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
bool purchaseInProgress = false;
|
||||
Map user;
|
||||
String card = '';
|
||||
String flavor = '';
|
||||
String loyalityType = '';
|
||||
String loyalty = '';
|
||||
String bonus = '';
|
||||
@@ -72,17 +75,19 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
));
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.card(), card));
|
||||
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.reward(), loyalty));
|
||||
if (app != 'crypto') { // FIXME Заменить на crypto
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.reward(), loyalty));
|
||||
}
|
||||
|
||||
if (bonus.length > 0) {
|
||||
widgetList.add(getValueWithDescription(StringsLocalization.bonus(), bonus));
|
||||
}
|
||||
|
||||
widgetList.add(getHintLabel());
|
||||
|
||||
widgetList.add(getInputField()); // Нельзя добавить еще одно поле таким же способом
|
||||
|
||||
if (this.flavor != 'autobonus') {
|
||||
if (app != 'autobonus') {
|
||||
|
||||
if (this.loyalityType == 'bonus') {
|
||||
widgetList.add(getBonusInputField());
|
||||
}
|
||||
@@ -114,6 +119,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
Resources.getPrimaryColor(app)
|
||||
)
|
||||
));
|
||||
|
||||
return new Column(children: <Widget>[
|
||||
new Expanded(
|
||||
child: new ListView(children: widgetList))
|
||||
@@ -121,7 +127,11 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
}
|
||||
|
||||
getBonusInputField() {
|
||||
TextField bonusTextField = new TextField(
|
||||
|
||||
var bonusTextField = new EnsureVisibleWhenFocused(
|
||||
focusNode: _focusNodeBonus,
|
||||
child: new TextField(
|
||||
focusNode: _focusNodeBonus,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: new InputDecoration.collapsed(
|
||||
hintText: StringsLocalization.bonusHint(),
|
||||
@@ -134,7 +144,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
});
|
||||
},
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
));
|
||||
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
@@ -199,7 +209,10 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
@override
|
||||
getTextWidget() {
|
||||
// ?? TODO переделать, т.к. позволяет иметь только одно поле ввода на странице
|
||||
return new TextField(
|
||||
return new EnsureVisibleWhenFocused(
|
||||
focusNode: _focusNodeSum,
|
||||
child: new TextField(
|
||||
focusNode: _focusNodeSum,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: new InputDecoration.collapsed(
|
||||
hintText: getHintString(),
|
||||
@@ -212,12 +225,11 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
},
|
||||
textAlign: TextAlign.center,
|
||||
autofocus: true
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
requestAsyncData(Map user) async {
|
||||
bool showBonus = await platform.invokeMethod('showBonus');
|
||||
String flavor = await platform.invokeMethod('getFlavor');
|
||||
if (await platform.invokeMethod('isOnline') && !this.dataRequested) {
|
||||
this.dataRequested = true;
|
||||
var response, couponResponse;
|
||||
@@ -240,12 +252,10 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
});
|
||||
|
||||
setState(() {
|
||||
this.flavor = flavor;
|
||||
this.coupons = coupons['results'];
|
||||
this.loyalityType = loyality['type'];
|
||||
setBonuses(loyality, showBonus);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +331,6 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
showDialog(
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
//title: new Text(StringsLocalization.()),
|
||||
content: new Text(errorText),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
@@ -395,17 +404,20 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
|
||||
Map coupons = JSON.decode(couponsResponse.body);
|
||||
|
||||
pushRouteReplacement(
|
||||
context,
|
||||
new PurchaseSuccessScreen(
|
||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||
print('show purchase success!');
|
||||
var route = new MaterialPageRoute<bool>(builder: (BuildContext context) => new PurchaseSuccessScreen(
|
||||
sumTotal,
|
||||
user['first_name'] == null ? '' : user['first_name'],
|
||||
helper,
|
||||
app,
|
||||
purchase,
|
||||
coupons['results']
|
||||
)
|
||||
);
|
||||
), fullscreenDialog: true);
|
||||
Navigator.of(context).push(route).then((b) {
|
||||
print('finish registration closed: $b');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -427,8 +439,4 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
print('kifio ' + this.loyalty);
|
||||
print('bonus ' + this.bonus);
|
||||
}
|
||||
|
||||
// onWillPop() {
|
||||
// return startScanner(context, app, helper);
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user