Открытие сканнера, логаут
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'db.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -25,7 +26,11 @@ faq(BuildContext context, bool returnToScanner) {
|
||||
|
||||
// В методе отправляется запрос на удаление токена кассы, очищаются SharedPreferences приложения.
|
||||
logout(BuildContext context) async {
|
||||
String token = await sqliteHelper.getToken();
|
||||
|
||||
SqliteHelper helper = new SqliteHelper();
|
||||
await helper.open();
|
||||
String token = await helper.getToken();
|
||||
|
||||
VoidCallback positiveCalback = () {
|
||||
if (token != null) {
|
||||
deleteToken(token).then((response) {
|
||||
@@ -47,8 +52,8 @@ logout(BuildContext context) async {
|
||||
showYesNoDialog(context, StringsLocalization.confirmation(), StringsLocalization.askChangeStore(), positiveCalback);
|
||||
}
|
||||
|
||||
forceLogout(BuildContext context) async {
|
||||
String token = await sqliteHelper.getToken();
|
||||
forceLogout(SqliteHelper helper, BuildContext context) async {
|
||||
String token = await helper.getToken();
|
||||
deleteToken(token).then((response) {
|
||||
print(response.body);
|
||||
platform.invokeMethod('removeKeys').then((result) {
|
||||
@@ -62,9 +67,9 @@ forceLogout(BuildContext context) async {
|
||||
|
||||
/// Запуск спецефичной для каждой платформы части приложения - сканера.
|
||||
/// Может производиться с нескольких экранов (splash, finish_registration).
|
||||
startScanner(BuildContext context) async {
|
||||
startScanner(SqliteHelper helper, BuildContext context) async {
|
||||
|
||||
String token = await sqliteHelper.getToken();
|
||||
String token = await helper.getToken();
|
||||
// Канал ловит вызовы методов из "нативной" части приложения.
|
||||
// Могут быть вызваны либо logout либо faq, либо purchase.
|
||||
if (token != null) {
|
||||
@@ -72,7 +77,7 @@ startScanner(BuildContext context) async {
|
||||
|
||||
print('call.method: ${call.method}');
|
||||
if (call.method == 'logout') {
|
||||
forceLogout(context);
|
||||
forceLogout(helper, context);
|
||||
} else if (call.method == 'faq') {
|
||||
faq(context, true);
|
||||
} else {
|
||||
@@ -84,6 +89,7 @@ startScanner(BuildContext context) async {
|
||||
Navigator.of(context).pushReplacement(route);
|
||||
}
|
||||
});
|
||||
|
||||
await platform.invokeMethod('startScanner', {
|
||||
'token' : token,
|
||||
'url': url,
|
||||
|
||||
Reference in New Issue
Block a user