From 23dce005b437d7e6084d82ece7800f3a21b8731c Mon Sep 17 00:00:00 2001 From: Admin Date: Thu, 5 Oct 2017 12:16:55 +0300 Subject: [PATCH] initial commit --- android/android.iml | 19 +++ android/app/app.iml | 148 ++++++++++++++++++ android/app/build.gradle | 8 + .../java/com/dinect/checker/MainActivity.java | 6 + lib/i18n/messages_en.dart | 1 + lib/i18n/messages_es.dart | 1 + lib/i18n/messages_ru.dart | 1 + lib/i18n/messages_ua.dart | 1 + lib/main.dart | 19 ++- lib/screens/purchase.dart | 53 +++++-- lib/strings.dart | 1 + 11 files changed, 238 insertions(+), 20 deletions(-) create mode 100644 android/android.iml create mode 100644 android/app/app.iml diff --git a/android/android.iml b/android/android.iml new file mode 100644 index 0000000..eec168d --- /dev/null +++ b/android/android.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/app.iml b/android/app/app.iml new file mode 100644 index 0000000..0204579 --- /dev/null +++ b/android/app/app.iml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index b155f44..3c1906a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -51,6 +51,8 @@ android { buildConfigField "String", "supportUrl", "\"http://www.dinect.com\"" buildConfigField "String", "endpoint", "\"https://pos-api.dinect.com/20130701/\"" buildConfigField "String", "appToken", "\"bdea0f3ba9034b688019a7cac753d1209e2b227f\"" + buildConfigField "String", "appTitle", "\"Dinect\"" + buildConfigField "boolean", "showBonus", "true" } @@ -63,6 +65,8 @@ android { buildConfigField "String", "supportUrl", "\"https://www.auto-club.biz\"" buildConfigField "String", "endpoint", "\"https://pos-api-autoclub.dinect.com/20130701/\"" buildConfigField "String", "appToken", "\"bdea0f3ba9034b688019a7cac753d1209e2b227f\"" + buildConfigField "String", "appTitle", "\"Autobonus\"" + buildConfigField "boolean", "showBonus", "false" } pip { @@ -74,6 +78,8 @@ android { buildConfigField "String", "supportUrl", "\"http://discount.kiev.ua/\"" buildConfigField "String", "endpoint", "\"https://pos-api.discount.kiev.ua/20130701/\"" buildConfigField "String", "appToken", "\"bdea0f3ba9034b688019a7cac753d1209e2b227f\"" + buildConfigField "String", "appTitle", "\"PIP\"" + buildConfigField "boolean", "showBonus", "true" } develop { @@ -85,6 +91,8 @@ android { buildConfigField "String", "supportUrl", "\"http://yandex.ru/\"" buildConfigField "String", "endpoint", "\"https://pos-api-int.dinect.com/20130701/\"" buildConfigField "String", "appToken", "\"9fec83cdca38c357e6b65dbb17514cdd36bf2a08\"" + buildConfigField "String", "appTitle", "\"Autobonus\"" + buildConfigField "boolean", "showBonus", "false" } } 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 66118fe..2e19649 100644 --- a/android/app/src/main/java/com/dinect/checker/MainActivity.java +++ b/android/app/src/main/java/com/dinect/checker/MainActivity.java @@ -82,6 +82,12 @@ public class MainActivity extends FlutterActivity { case "getAppToken": result.success(BuildConfig.appToken); break; + case "getAppTitle": + result.success(BuildConfig.appTitle); + break; + case "showBonus": + result.success(BuildConfig.showBonus); + break; default: result.notImplemented(); break; diff --git a/lib/i18n/messages_en.dart b/lib/i18n/messages_en.dart index 25512a5..93e5dc3 100644 --- a/lib/i18n/messages_en.dart +++ b/lib/i18n/messages_en.dart @@ -35,6 +35,7 @@ class MessageLookup extends MessageLookupByLibrary { "common" : MessageLookupByLibrary.simpleMessage("General information"), "request_sent_wait_activ" : MessageLookupByLibrary.simpleMessage("The activation request for the application has been sent, wait for confirm activation"), "reward" : MessageLookupByLibrary.simpleMessage("Reward"), + "bonus" : MessageLookupByLibrary.simpleMessage("Bonus on account"), "scan" : MessageLookupByLibrary.simpleMessage("Scan"), "sign_up" : MessageLookupByLibrary.simpleMessage("Sign Up"), "specify_din_store" : MessageLookupByLibrary.simpleMessage("Specify the DIN store"), diff --git a/lib/i18n/messages_es.dart b/lib/i18n/messages_es.dart index 936def0..fa7f656 100644 --- a/lib/i18n/messages_es.dart +++ b/lib/i18n/messages_es.dart @@ -32,6 +32,7 @@ class MessageLookup extends MessageLookupByLibrary { "registration" : MessageLookupByLibrary.simpleMessage("El registro"), "request_sent_wait_activ" : MessageLookupByLibrary.simpleMessage("El requieremento de activación de aplicación esta mandado, esperad la activación por el administrador."), "reward" : MessageLookupByLibrary.simpleMessage("Gratificación"), + "bonus" : MessageLookupByLibrary.simpleMessage("Bono por cuenta"), "scan" : MessageLookupByLibrary.simpleMessage("Escanear"), "sign_up" : MessageLookupByLibrary.simpleMessage("Registrarse"), "specify_din_store" : MessageLookupByLibrary.simpleMessage("Hay que dar DIN del negocio"), diff --git a/lib/i18n/messages_ru.dart b/lib/i18n/messages_ru.dart index 1981499..10e012e 100644 --- a/lib/i18n/messages_ru.dart +++ b/lib/i18n/messages_ru.dart @@ -35,6 +35,7 @@ class MessageLookup extends MessageLookupByLibrary { "common" : MessageLookupByLibrary.simpleMessage("Общая информация"), "request_sent_wait_activ" : MessageLookupByLibrary.simpleMessage("Запрос на активацию приложения отправлен, дождитесь подтверждения активации администратором"), "reward" : MessageLookupByLibrary.simpleMessage("Вознаграждение"), + "bonus" : MessageLookupByLibrary.simpleMessage("Бонусов на счету"), "scan" : MessageLookupByLibrary.simpleMessage("Сканировать"), "sign_up" : MessageLookupByLibrary.simpleMessage("Зарегистрироваться"), "specify_din_store" : MessageLookupByLibrary.simpleMessage("Необходимо указать DIN магазина"), diff --git a/lib/i18n/messages_ua.dart b/lib/i18n/messages_ua.dart index 1adc2db..a8fa4d3 100644 --- a/lib/i18n/messages_ua.dart +++ b/lib/i18n/messages_ua.dart @@ -35,6 +35,7 @@ class MessageLookup extends MessageLookupByLibrary { "common" : MessageLookupByLibrary.simpleMessage("Загальна інформація"), "request_sent_wait_activ" : MessageLookupByLibrary.simpleMessage("Запит на активацію додатку відправлений, дочекайтеся підтвердження активації адміністратором"), "reward" : MessageLookupByLibrary.simpleMessage("Винагорода"), + "bonus" : MessageLookupByLibrary.simpleMessage("Бонусів на рахунку"), "scan" : MessageLookupByLibrary.simpleMessage("Сканувати"), "sign_up" : MessageLookupByLibrary.simpleMessage("Зареєструватися"), "specify_din_store" : MessageLookupByLibrary.simpleMessage("Необхідно вказати DIN магазину"), diff --git a/lib/main.dart b/lib/main.dart index 5388001..ef43541 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,17 +1,30 @@ import 'package:flutter/material.dart'; import 'package:checker/screens/splash.dart'; import 'package:checker/consts.dart'; +import 'package:flutter/services.dart'; + +const platform = const MethodChannel('com.dinect.checker/instance_id'); /// Точка входа в приложение. + + +/// + void main() { - runApp(new Checker()); + platform.invokeMethod('getAppTitle').then((title) { + runApp(new Checker(appName: title)); + }); } class Checker extends StatelessWidget { + Checker({this.appName}); + final String appName; - @override Widget build(BuildContext context) { + @override Widget build (BuildContext context) { + print('app name = ${appName}'); return new MaterialApp( title: appName, - home: new SplashScreen()); + home: new SplashScreen() + ); } } \ No newline at end of file diff --git a/lib/screens/purchase.dart b/lib/screens/purchase.dart index d4512b9..dfc2ca1 100644 --- a/lib/screens/purchase.dart +++ b/lib/screens/purchase.dart @@ -50,24 +50,37 @@ class PurchaseScreenState extends BaseState { Map user; String card = ''; String loyalty = ''; + String bonus = ''; + bool dataLoaded = false; @override Widget getScreenContent() { + List widgets = []; + widgets.add(getValueWithDescription( + StringsLocalization.buyer(), + user['first_name'] == null ? '' : user['first_name'] + )); + widgets.add(getValueWithDescription(StringsLocalization.card(), card)); + + if (bonus.length > 0) { + widgets.add(getValueWithDescription(StringsLocalization.bonus(), bonus)); + } + + widgets.add(getValueWithDescription(StringsLocalization.reward(), loyalty)); + widgets.add(getHintLabel()); + widgets.add(getInputField()); + widgets.add(wrapButton(getScreenMargins(36.0), getCompleteButton())); + widgets.add(wrapButton( + getScreenMargins(24.0), + getScanButton( + context, + StringsLocalization.scan(), + Resources.getPrimaryColor(app) + ) + )); return new Column(children: [ new Expanded( - child: new ListView(children: [ - getValueWithDescription(StringsLocalization.buyer(), - user['first_name'] == null ? '' : user['first_name']), - getValueWithDescription(StringsLocalization.card(), card), - getValueWithDescription(StringsLocalization.reward(), loyalty), - getHintLabel(), - getInputField(), - wrapButton(getScreenMargins(36.0), getCompleteButton()), - wrapButton( - getScreenMargins(24.0), - getScanButton(context, StringsLocalization.scan(), - Resources.getPrimaryColor(app))) - ])) + child: new ListView(children: widgets)) ]); } @@ -122,12 +135,13 @@ class PurchaseScreenState extends BaseState { } requestLoyalty(String url) async { - print(url); - if (await platform.invokeMethod('isOnline')) { + bool showBonus = await platform.invokeMethod('showBonus'); + if (await platform.invokeMethod('isOnline') && !this.dataLoaded) { getLoyaltyRequest(url, helper).then((response) { print(response); + this.dataLoaded = true; setState(() { - setBonuses(JSON.decode(response.body)); + setBonuses(JSON.decode(response.body), showBonus ); }); }).catchError((error) { print(error.toString()); @@ -245,7 +259,7 @@ class PurchaseScreenState extends BaseState { } } - void setBonuses(Map bonuses) { + void setBonuses(Map bonuses, bool showBonus) { print('kifio ' + bonuses['type']); if (bonuses['type'] == 'amount') { this.loyalty = '${user['discount']}%'; @@ -254,6 +268,11 @@ class PurchaseScreenState extends BaseState { bonuses['amount_to_bonus'][0]) * 100; this.loyalty = '${loyaltyVal.toStringAsFixed(0)}%'; } + + if (showBonus && (bonuses['type'] == 'bonus')) { + this.bonus = '${user['bonus']}'; + } print('kifio ' + this.loyalty); + print('bonus ' + this.bonus); } } diff --git a/lib/strings.dart b/lib/strings.dart index eb27faf..1e25175 100644 --- a/lib/strings.dart +++ b/lib/strings.dart @@ -96,6 +96,7 @@ class StringsLocalization { static String card() => Intl.message('card', name: 'card', 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 bonus() => Intl.message('bonus', name: 'bonus', 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);