diff --git a/android/app/build.gradle b/android/app/build.gradle index 62a30d8..3dd508a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -138,12 +138,12 @@ android { crypto { applicationId 'com.dinect.checker.crypto' buildConfigField "String", "locale", "\"ru\"" - buildConfigField "String", "flavor", "\"cryptoq\"" + buildConfigField "String", "flavor", "\"crypto\"" buildConfigField "int", "currency", "643" buildConfigField "String", "supportPhone", "\"8-800-77-55-032\"" buildConfigField "String", "supportUrl", "\"http://www.dinect.com\"" - buildConfigField "String", "endpoint", "\"https://pos-api-crypto-int.dinect.com/20130701/\"" - buildConfigField "String", "appToken", "\"bdea0f3ba9034b688019a7cac753d1209e2b227f\"" + buildConfigField "String", "endpoint", "\"https://pos-api-int.dinect.com/20130701/\"" + buildConfigField "String", "appToken", "\"9fec83cdca38c357e6b65dbb17514cdd36bf2a08\"" buildConfigField "String", "appTitle", "\"Dinect Crypto\"" buildConfigField "boolean", "showBonus", "true" } diff --git a/android/app/src/main/java/com/dinect/checker/AbstractScannerActivity.java b/android/app/src/main/java/com/dinect/checker/AbstractScannerActivity.java index 054c5bd..4abd2cf 100644 --- a/android/app/src/main/java/com/dinect/checker/AbstractScannerActivity.java +++ b/android/app/src/main/java/com/dinect/checker/AbstractScannerActivity.java @@ -165,8 +165,8 @@ public abstract class AbstractScannerActivity extends AppCompatActivity impleme // для удобства, чтоб не вводить постоянно руками при разработке - manualInput.setText("9990010009012057060904229"); -// manualInput.setText("4620011139016337050236302"); + // manualInput.setText("9990010009012057060904229"); + manualInput.setText("4620011139016337050236302"); manualInput.setHint(getIntent().getStringExtra("enter_manual")); manualInput.setOnEditorActionListener(new TextView.OnEditorActionListener() { diff --git a/android/app/src/main/java/com/dinect/checker/MainActivity.java b/android/app/src/main/java/com/dinect/checker/MainActivity.java index 3788dd6..9081d14 100644 --- a/android/app/src/main/java/com/dinect/checker/MainActivity.java +++ b/android/app/src/main/java/com/dinect/checker/MainActivity.java @@ -14,6 +14,7 @@ import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugins.GeneratedPluginRegistrant; +import android.support.v4.app.Fragment; import java.util.*; diff --git a/lib/base/base_state.dart b/lib/base/base_state.dart index 48e7a80..ed6647f 100644 --- a/lib/base/base_state.dart +++ b/lib/base/base_state.dart @@ -253,7 +253,7 @@ abstract class BaseState extends State { EdgeInsets getInputFieldContainerPadding() { const double verticalPadding = 12.0; const double horizontalPadding = 16.0; - return new EdgeInsets.only(top: 256.0, + return new EdgeInsets.only(top: verticalPadding, bottom: verticalPadding, left: horizontalPadding, right: horizontalPadding); @@ -352,7 +352,7 @@ class EnsureVisibleWhenFocusedState extends State { // TODO: position doesn't seem to notify listeners when metrics change, // perhaps a NotificationListener around the scrollable could avoid // the need insert a delay here. - await new Future.delayed(const Duration(milliseconds: 300)); + await new Future.delayed(const Duration(milliseconds: 1000)); if (!widget.focusNode.hasFocus) return; diff --git a/lib/main.dart b/lib/main.dart index dcf05e3..b02e40a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -43,8 +43,9 @@ initWithSystemValue(String app, String name, SqliteHelper helper) { createSettingsTable(String app, String name, String locale, SqliteHelper helper) { platform.invokeMethod('getCurrency').then((currency) { - helper.createAppInfo(currency); - start(app, name, locale, helper); + helper.createAppInfo(currency).then(() { + start(app, name, locale, helper); + }); }); } diff --git a/lib/resources.dart b/lib/resources.dart index 90a57af..b1445a9 100644 --- a/lib/resources.dart +++ b/lib/resources.dart @@ -28,7 +28,7 @@ class Resources { case 'autobonus': return new Color(0xffeb0004); case 'dinect': return new Color(0xff33cc99); case 'dinect': return new Color(0xff33cc99); - case 'crypto': return new Color(0x0f3d87); + case 'crypto': return new Color(0xff0f3d87); default: return new Color(0xffffffff); } } diff --git a/lib/screens/finish_registration.dart b/lib/screens/finish_registration.dart index 9d9f2d8..8193b64 100644 --- a/lib/screens/finish_registration.dart +++ b/lib/screens/finish_registration.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:async'; import 'package:checker/base/base_screen.dart'; import 'package:checker/base/base_state.dart'; @@ -57,9 +58,11 @@ class RegistrationScreenState extends BaseState { // Если токен активирован, то открывается экран со сканером, // Если нет, то отправляется запрос на проверку статуса токена. handleTap() async { + print('tokenActive: $_tokenActive'); if (_tokenActive) { - Navigator.of(context).pop(); -// FIXME: startScanner(context, app, helper); + new Future.delayed(const Duration(milliseconds: 200), () { + Navigator.of(context).pop(); + }); } else { if (await platform.invokeMethod('isOnline')) { String token = await helper.getToken(); diff --git a/lib/screens/purchase.dart b/lib/screens/purchase.dart index a40d61f..411df05 100644 --- a/lib/screens/purchase.dart +++ b/lib/screens/purchase.dart @@ -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 extends BaseState { 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 extends BaseState { bool purchaseInProgress = false; Map user; String card = ''; - String flavor = ''; String loyalityType = ''; String loyalty = ''; String bonus = ''; @@ -72,17 +75,19 @@ class PurchaseScreenState extends BaseState { )); 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 extends BaseState { Resources.getPrimaryColor(app) ) )); + return new Column(children: [ new Expanded( child: new ListView(children: widgetList)) @@ -121,7 +127,11 @@ class PurchaseScreenState extends BaseState { } 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 extends BaseState { }); }, textAlign: TextAlign.center, - ); + )); return new Column( children: [ @@ -199,7 +209,10 @@ class PurchaseScreenState extends BaseState { @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 extends BaseState { }, 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 extends BaseState { }); setState(() { - this.flavor = flavor; this.coupons = coupons['results']; this.loyalityType = loyality['type']; setBonuses(loyality, showBonus); }); - } } @@ -321,7 +331,6 @@ class PurchaseScreenState extends BaseState { showDialog( context: context, child: new AlertDialog( - //title: new Text(StringsLocalization.()), content: new Text(errorText), actions: [ new FlatButton( @@ -395,17 +404,20 @@ class PurchaseScreenState extends BaseState { 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(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 extends BaseState { print('kifio ' + this.loyalty); print('bonus ' + this.bonus); } - -// onWillPop() { -// return startScanner(context, app, helper); -// } } diff --git a/lib/screens/purchase_success.dart b/lib/screens/purchase_success.dart index 1fa4cfe..ba84915 100644 --- a/lib/screens/purchase_success.dart +++ b/lib/screens/purchase_success.dart @@ -40,7 +40,6 @@ class PurchaseSuccessScreenState extends BaseState { int bonusMinus = 0; int currency; bool showBonus; - String flavor; @override String getTitle() { return StringsLocalization.carryingPurchase(); @@ -51,6 +50,7 @@ class PurchaseSuccessScreenState extends BaseState { } @override Widget build(BuildContext context) { + if (currency == null) { helper.getCurrency().then((currency) { setState(() { @@ -58,27 +58,20 @@ class PurchaseSuccessScreenState extends BaseState { }); }); } - if (this.flavor == null) { - platform.invokeMethod('getFlavor').then((flavor) { - setState(() { - this.flavor = flavor; + + 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 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']; - } - }); - }); + if (this.details['sum_bonus'] is int) { + this.bonusPlus = this.details['sum_bonus']; } return getMainWidget(); @@ -97,13 +90,13 @@ class PurchaseSuccessScreenState extends BaseState { widgetList.add(getValueWithDescription(StringsLocalization.bonusMinus(), bonusMinus.toString())); } - if (this.flavor != 'autobonus') { + if (app != 'autobonus') { widgetList.add(getValueWithDescription(StringsLocalization.discountRate(), '${details['discount']}%')); - widgetList.add(getValueWithDescription(StringsLocalization.discountSum(), '${details['sum_discount']}')); + if (app != 'crypto') { + widgetList.add(getValueWithDescription(StringsLocalization.discountSum(), '${details['sum_discount']}')); + } } - -// widgetList.add( new Expanded(child: new Center())); - if (this.coupons.length > 0) { + if (app != 'crypto' && this.coupons.length > 0) { widgetList.add(getItemTitle(StringsLocalization.couponsUsed())); this.coupons.forEach((couponItem) { widgetList.add(getItemToggle( @@ -140,8 +133,6 @@ class PurchaseSuccessScreenState extends BaseState { }; } - - getSuccessMessage() { return new Row( children: [ diff --git a/lib/screens/registration.dart b/lib/screens/registration.dart index 8521752..cfcab81 100644 --- a/lib/screens/registration.dart +++ b/lib/screens/registration.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:async'; import 'package:checker/base/base_screen.dart'; import 'package:checker/base/base_state.dart'; @@ -42,8 +43,7 @@ class RegistrationScreenState extends BaseState { /// Список виджетов, автоматически прокручиваемый вверх при открытии клавиатуры. @override Widget getScreenContent() { - return new Container( - child: new ListView(children: [ + return new Container(child: new ListView(children: [ new Column(children: [ getLogo(), getHintLabel(), @@ -88,12 +88,12 @@ class RegistrationScreenState extends BaseState { _registerShop() { setState(() { loading = true; - _register(); + register(); }); } /// Получение от платформы id установки, формирование запроса на получение токена, сохранение токена. - _register() async { + register() async { if (await platform.invokeMethod('isOnline')) { String posID = await helper.getPosID(); @@ -110,8 +110,12 @@ class RegistrationScreenState extends BaseState { if (response.statusCode == 201) { helper.createSession(merchantID, posID, parsedMap['token']).then((_) { - pushRouteReplacement( - context, new FinishRegistrationScreen(helper, app)); + new Future.delayed(const Duration(milliseconds: 200), () { + var route = new MaterialPageRoute(builder: (BuildContext context) => new FinishRegistrationScreen(helper, app), fullscreenDialog: true); + Navigator.of(context).pushReplacement(route).then((b) { + print('finish registration closed: $b'); + }); + }); }); } else { setState(() { diff --git a/lib/screens/splash.dart b/lib/screens/splash.dart index aba41c5..797794b 100644 --- a/lib/screens/splash.dart +++ b/lib/screens/splash.dart @@ -83,7 +83,16 @@ class _SplashScreenState extends BaseState { // В случае, если в приложении отсутствует токен, // необходимо запустить регистрацию кассы. if (token == null) { - pushRouteReplacement(context, new RegistrationScreen(helper, app)); + + new Future.delayed(const Duration(milliseconds: 200), () { + var route = new MaterialPageRoute( + builder: (BuildContext context) => new RegistrationScreen(helper, app), fullscreenDialog: true); + Navigator.of(context).push(route).then((b) { + _initAndStartScanner(context, app, token, helper); + }); + }); + + // pushRoute(context, new RegistrationScreen(helper, app)); } else { if (await platform.invokeMethod('isOnline')) { getCheckTokenStatusRequest(token).then((statusResponse) { @@ -100,7 +109,6 @@ class _SplashScreenState extends BaseState { /// Если токен не активен, попробовать создать его еще раз. handleStatusResponse(var statusResponse, SqliteHelper helper) async { int code = statusResponse.statusCode; - if (code == 404) { helper.clear().then((result) { pushRouteReplacement(context, new RegistrationScreen(helper, app)); @@ -191,7 +199,14 @@ class _SplashScreenState extends BaseState { } else if (call.method == 'faq') { faq(helper, app, context, true); } else if (call.method == 'settings') { - pushRoute(context, new SettingsScreen(helper, app, true)); + new Future.delayed(const Duration(milliseconds: 200), () { + var route = new MaterialPageRoute( + builder: (BuildContext context) => new SettingsScreen(helper, app, true), fullscreenDialog: true); + Navigator.of(context).push(route).then((b) { + print('purchase closed: $b'); + _initAndStartScanner(context, app, token, helper); + }); + }); } else { String userString; @@ -254,5 +269,4 @@ class _SplashScreenState extends BaseState { return null; } } -} - +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index db1daed..29adeb3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -152,4 +152,4 @@ packages: source: hosted version: "2.6.0" sdks: - dart: ">=2.0.0-dev.23.0 <=2.0.0-edge.0d5cf900b021bf5c9fa593ffa12b15bcd1cc5fe0" + dart: ">=2.0.0-dev.23.0 <=2.0.0-edge.fe96de2858f078e4ad04f8f30640184bf3d8102d"