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