From 9f2bf1419903e0b6aa91e3842ac6f59092329ccf Mon Sep 17 00:00:00 2001 From: Ivan Murashov Date: Mon, 25 Sep 2017 19:16:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=20=D1=88=D0=B0=D0=BF=D0=BA=D0=B5=20=D0=BD=D0=B5?= =?UTF-8?q?=20null,=20=D0=BD=D0=B5=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=B0=D0=B4=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=BD=D0=B0=20=D1=8D=D0=BA=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=20=D1=81=D0=BA=D0=B0=D0=BD=D0=BD=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=20=D1=81=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=D0=B0=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common.dart | 35 ++++++++++++++++++++--------------- lib/consts.dart | 2 ++ lib/main.dart | 5 ++++- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/common.dart b/lib/common.dart index 7d63043..6d58d9c 100644 --- a/lib/common.dart +++ b/lib/common.dart @@ -86,7 +86,6 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async { }); } else { String token = await helper.getToken(); - helper.close(); // Канал ловит вызовы методов из "нативной" части приложения. // Могут быть вызваны либо logout либо faq, либо purchase. if (token != null) { @@ -96,10 +95,14 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async { } else if (call.method == 'faq') { faq(context, true); } else if(call.method == 'settings') { - helper = new SqliteHelper(); - helper.open().then((_) { + if (helper == null) { + helper = new SqliteHelper(); + helper.open().then((_) { + pushRoute(context, new SettingsScreen(helper, app, true)); + }); + } else { pushRoute(context, new SettingsScreen(helper, app, true)); - }); + } } else { String userString = call.arguments[0]; String card = call.arguments[1]; @@ -114,20 +117,22 @@ startScanner(BuildContext context, String app, SqliteHelper helper) async { } }); - platform.invokeMethod('getEndpoint').then((endpoint) { - platform.invokeMethod('getAppToken').then((appToken) async { - platform.invokeMethod('startScanner', { - 'token': token, - 'url': endpoint, - 'appToken': appToken, - 'locale': Intl.defaultLocale, - 'color': Resources - .getPrimaryColor(app) - .value + helper.close().then((_){ + helper = null; + platform.invokeMethod('getEndpoint').then((endpoint) { + platform.invokeMethod('getAppToken').then((appToken) async { + platform.invokeMethod('startScanner', { + 'token': token, + 'url': endpoint, + 'appToken': appToken, + 'locale': Intl.defaultLocale, + 'color': Resources + .getPrimaryColor(app) + .value + }); }); }); }); - } } } diff --git a/lib/consts.dart b/lib/consts.dart index da76715..074c52b 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +const String appName = "Autobonus"; + // Assets const String logout_png = 'assets/logout.png'; const String help_png = 'assets/help.png'; diff --git a/lib/main.dart b/lib/main.dart index 123bdf3..5388001 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:checker/screens/splash.dart'; +import 'package:checker/consts.dart'; /// Точка входа в приложение. void main() { @@ -9,6 +10,8 @@ void main() { class Checker extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp(home: new SplashScreen()); + return new MaterialApp( + title: appName, + home: new SplashScreen()); } } \ No newline at end of file