Перенес хранение информации о сессии (токен, din, posid) в базу данных
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:checker/db.dart';
|
||||
import 'dart:convert'; // Пакет для обработки json с ответом от сервера.
|
||||
|
||||
import 'package:checker/common.dart';
|
||||
@@ -14,12 +15,22 @@ class FinishRegistrationScreen extends StatefulWidget {
|
||||
|
||||
class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
|
||||
SqliteHelper helper;
|
||||
|
||||
bool _tokenActive = false;
|
||||
String _merchantID = '';
|
||||
|
||||
_RegistrationScreenState() {
|
||||
helper = new SqliteHelper();
|
||||
if (textFieldValue == "") {
|
||||
getSavedMerchantID();
|
||||
helper.open().then((_){
|
||||
helper.getMerchantID().then((result) {
|
||||
setState(() {
|
||||
_merchantID = result;
|
||||
print('merchanID: ${_merchantID}');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +58,11 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
// Если нет, то отправляется запрос на проверку статуса токена.
|
||||
handleTap() async {
|
||||
if (_tokenActive) {
|
||||
helper.close();
|
||||
startScanner(context);
|
||||
} else {
|
||||
if (await platform.invokeMethod('isOnline')) {
|
||||
String token = await platform.invokeMethod('getToken');
|
||||
String token = await helper.getToken();
|
||||
checkTokenStatus(token).then((response) {
|
||||
|
||||
print(response.body);
|
||||
@@ -74,16 +86,6 @@ class _RegistrationScreenState extends BaseState<FinishRegistrationScreen> {
|
||||
style: new TextStyle(color: Colors.black, fontSize: 16.0))]);
|
||||
}
|
||||
|
||||
/// Достаем сохраненный в SharedPreferences merchantID.
|
||||
getSavedMerchantID() {
|
||||
platform.invokeMethod('getMerchantID').then((result) {
|
||||
setState(() {
|
||||
_merchantID = result;
|
||||
print('merchanID: ${_merchantID}');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Метод возвращает контейнер с текстом сообщения и бэкграундом.
|
||||
getMessage() {
|
||||
return new Container(height: _tokenActive ? 72.0 : 108.0, decoration: _getDecorationForMessageField(),
|
||||
|
||||
Reference in New Issue
Block a user