refactor: Switch to loading dialog
This commit is contained in:
parent
9521a93622
commit
75797a62b9
36 changed files with 461 additions and 350 deletions
|
|
@ -3,7 +3,7 @@ import 'dart:math';
|
|||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/firebase_controller.dart';
|
||||
|
|
@ -87,8 +87,10 @@ class _LoginState extends State<Login> {
|
|||
final newDomain = wellKnownInformations.mHomeserver?.baseUrl;
|
||||
if ((newDomain?.isNotEmpty ?? false) &&
|
||||
newDomain != Matrix.of(context).client.homeserver.toString()) {
|
||||
await SimpleDialogs(context).tryRequestWithErrorToast(
|
||||
Matrix.of(context).client.checkHomeserver(newDomain));
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.checkHomeserver(newDomain),
|
||||
);
|
||||
setState(() => usernameError = null);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -109,14 +111,15 @@ class _LoginState extends State<Login> {
|
|||
);
|
||||
if (input == null) return;
|
||||
final clientSecret = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
final response = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.resetPasswordUsingEmail(
|
||||
final response = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.resetPasswordUsingEmail(
|
||||
input.single,
|
||||
clientSecret,
|
||||
sendAttempt++,
|
||||
),
|
||||
);
|
||||
if (response == false) return;
|
||||
if (response.error != null) return;
|
||||
final ok = await showOkAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).weSentYouAnEmail,
|
||||
|
|
@ -137,8 +140,9 @@ class _LoginState extends State<Login> {
|
|||
],
|
||||
);
|
||||
if (password == null) return;
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.changePassword(
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.changePassword(
|
||||
password.single,
|
||||
auth: AuthenticationThreePidCreds(
|
||||
type: AuthenticationTypes.emailIdentity,
|
||||
|
|
@ -151,7 +155,7 @@ class _LoginState extends State<Login> {
|
|||
),
|
||||
),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
FlushbarHelper.createSuccess(
|
||||
message: L10n.of(context).passwordHasBeenChanged);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue