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