Need fix error on purchase success showung.

This commit is contained in:
Ivan Murashov
2018-03-11 18:12:10 +03:00
parent 0c5645c059
commit 3bc43724c6
7 changed files with 47 additions and 56 deletions

View File

@@ -160,38 +160,14 @@ 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();
}
}
};
logout(BuildContext context, SqliteHelper helper) {
showYesNoDialog(context, StringsLocalization.confirmation(),
StringsLocalization.askChangeStore(), positiveCallback);
StringsLocalization.askChangeStore());
}
// Запуск диалога с двумя кнопками
showYesNoDialog(BuildContext context, String title, String content,
VoidCallback positiveCallback) {
showDialog(
showYesNoDialog(BuildContext context, String title, String content) {
showDialog<bool>(
context: context,
child: new AlertDialog(
title: new Text(title),
@@ -200,12 +176,27 @@ class SettingsState extends BaseState<SettingsScreen> {
new FlatButton(
child: new Text(StringsLocalization.no()),
onPressed: () {
Navigator.of(context).pop();
Navigator.of(context).pop(false);
}),
new FlatButton(
child: new Text(StringsLocalization.yes()),
onPressed: positiveCallback)
]));
onPressed: () {
Navigator.of(context).pop(true);
})
])).then((b) {
if (b) {
helper.getToken().then((token) {
getDeleteTokenRequest(token).then((response) {
helper.clear().then((result) {
Navigator.of(context).pop(null);
});
}).catchError((error) {
print(error.toString());
Navigator.of(context).pop(null);
});
});
}
});
}
Widget getArrow() {