refactor: Switch to loading dialog

This commit is contained in:
Christian Pauly 2020-12-25 09:58:34 +01:00
commit 75797a62b9
36 changed files with 461 additions and 350 deletions

View file

@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import '../avatar.dart';
import 'adaptive_flat_button.dart';
import 'simple_dialogs.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import '../../utils/string_color.dart';
class KeyVerificationDialog extends StatefulWidget {
@ -70,25 +70,26 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
if (input == null) {
return;
}
final valid = await SimpleDialogs(context)
.tryRequestWithLoadingDialog(Future.microtask(() async {
// make sure the loading spinner shows before we test the keys
await Future.delayed(Duration(milliseconds: 100));
var valid = false;
try {
await widget.request.openSSSS(recoveryKey: input);
valid = true;
} catch (_) {
try {
await widget.request.openSSSS(passphrase: input);
valid = true;
} catch (_) {
valid = false;
}
}
return valid;
}));
if (valid == false) {
final valid = await showFutureLoadingDialog(
context: context,
future: () async {
// make sure the loading spinner shows before we test the keys
await Future.delayed(Duration(milliseconds: 100));
var valid = false;
try {
await widget.request.openSSSS(recoveryKey: input);
valid = true;
} catch (_) {
try {
await widget.request.openSSSS(passphrase: input);
valid = true;
} catch (_) {
valid = false;
}
}
return valid;
});
if (valid.error != null) {
await showOkAlertDialog(
context: context,
message: L10n.of(context).incorrectPassphraseOrKey,