iOS crypto target
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:checker/base/base_screen.dart';
|
||||
import 'package:checker/base/base_state.dart';
|
||||
import 'package:checker/common.dart';
|
||||
import 'package:checker/consts.dart';
|
||||
import 'package:checker/db.dart';
|
||||
import 'package:checker/network.dart';
|
||||
import 'package:checker/screens/currencies.dart';
|
||||
import 'package:checker/screens/languages.dart';
|
||||
import 'package:checker/screens/splash.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -42,12 +46,18 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
this.returnToScanner = returnToScanner;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
print('init state!');
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext ctx) {
|
||||
helper.getSettings(true).then((info) {
|
||||
setState(() {
|
||||
print('currency: ${info['currency']}');
|
||||
print('locale: ${info['locale']}');
|
||||
print('token: ${info['token']}');
|
||||
// print('currency: ${info['currency']}');
|
||||
// print('locale: ${info['locale']}');
|
||||
// print('token: ${info['token']}');
|
||||
menuItems[0].title = StringsLocalization.currency();
|
||||
menuItems[1].title = StringsLocalization.locale();
|
||||
menuItems[2].title = StringsLocalization.logout();
|
||||
@@ -152,6 +162,55 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
// В методе отправляется запрос на удаление токена кассы, очищаются SharedPreferences приложения.
|
||||
logout(BuildContext context, SqliteHelper helper) async {
|
||||
String token = await helper.getToken();
|
||||
VoidCallback positiveCallback = () {
|
||||
if (token != null) {
|
||||
getDeleteTokenRequest(token).then((response) {
|
||||
helper.clear().then((result) {
|
||||
while (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
var route = new MaterialPageRoute<Null>(builder: (BuildContext context) => new SplashScreen(helper, app));
|
||||
new Future.delayed(const Duration(milliseconds: 200), () {
|
||||
Navigator.of(context).pushReplacement(route);
|
||||
});
|
||||
});
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
});
|
||||
} else {
|
||||
while (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
showYesNoDialog(context, StringsLocalization.confirmation(),
|
||||
StringsLocalization.askChangeStore(), positiveCallback);
|
||||
}
|
||||
|
||||
// Запуск диалога с двумя кнопками
|
||||
showYesNoDialog(BuildContext context, String title, String content,
|
||||
VoidCallback positiveCallback) {
|
||||
showDialog(
|
||||
context: context,
|
||||
child: new AlertDialog(
|
||||
title: new Text(title),
|
||||
content: new Text(content),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.no()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
new FlatButton(
|
||||
child: new Text(StringsLocalization.yes()),
|
||||
onPressed: positiveCallback)
|
||||
]));
|
||||
}
|
||||
|
||||
Widget getArrow() {
|
||||
return new Container(margin: new EdgeInsets.only(left: 8.0),
|
||||
child: new Image.asset(settings_arrow_png, height: 42.0));
|
||||
@@ -161,12 +220,4 @@ class SettingsState extends BaseState<SettingsScreen> {
|
||||
String getTitle() {
|
||||
return StringsLocalization.settings();
|
||||
}
|
||||
|
||||
// onWillPop() {
|
||||
// if (returnToScanner) {
|
||||
// return startScanner(context, app, helper);
|
||||
// } else {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user