refactor: Implement own adaptive dialogs and remove package
This commit is contained in:
parent
dea29161c8
commit
8819c40ebd
42 changed files with 597 additions and 439 deletions
|
|
@ -2,11 +2,12 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../utils/platform_infos.dart';
|
||||
|
|
@ -128,7 +129,7 @@ class LoginController extends State<Login> {
|
|||
final dialogResult = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
message: L10n.of(context).noMatrixServer(newDomain, oldHomeserver!),
|
||||
title: L10n.of(context).noMatrixServer(newDomain, oldHomeserver!),
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
);
|
||||
|
|
@ -162,15 +163,10 @@ class LoginController extends State<Login> {
|
|||
message: L10n.of(context).enterAnEmailAddress,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
fullyCapitalizedForMaterial: false,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
initialText:
|
||||
usernameController.text.isEmail ? usernameController.text : '',
|
||||
hintText: L10n.of(context).enterAnEmailAddress,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
),
|
||||
],
|
||||
initialText:
|
||||
usernameController.text.isEmail ? usernameController.text : '',
|
||||
hintText: L10n.of(context).enterAnEmailAddress,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
);
|
||||
if (input == null) return;
|
||||
final clientSecret = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
|
|
@ -179,7 +175,7 @@ class LoginController extends State<Login> {
|
|||
future: () =>
|
||||
Matrix.of(context).getLoginClient().requestTokenToResetPasswordEmail(
|
||||
clientSecret,
|
||||
input.single,
|
||||
input,
|
||||
sendAttempt++,
|
||||
),
|
||||
);
|
||||
|
|
@ -191,15 +187,10 @@ class LoginController extends State<Login> {
|
|||
message: L10n.of(context).chooseAStrongPassword,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
fullyCapitalizedForMaterial: false,
|
||||
textFields: [
|
||||
const DialogTextField(
|
||||
hintText: '******',
|
||||
obscureText: true,
|
||||
minLines: 1,
|
||||
maxLines: 1,
|
||||
),
|
||||
],
|
||||
hintText: '******',
|
||||
obscureText: true,
|
||||
minLines: 1,
|
||||
maxLines: 1,
|
||||
);
|
||||
if (password == null) return;
|
||||
final ok = await showOkAlertDialog(
|
||||
|
|
@ -208,11 +199,10 @@ class LoginController extends State<Login> {
|
|||
title: L10n.of(context).weSentYouAnEmail,
|
||||
message: L10n.of(context).pleaseClickOnLink,
|
||||
okLabel: L10n.of(context).iHaveClickedOnLink,
|
||||
fullyCapitalizedForMaterial: false,
|
||||
);
|
||||
if (ok != OkCancelResult.ok) return;
|
||||
final data = <String, dynamic>{
|
||||
'new_password': password.single,
|
||||
'new_password': password,
|
||||
'logout_devices': false,
|
||||
"auth": AuthenticationThreePidCreds(
|
||||
type: AuthenticationTypes.emailIdentity,
|
||||
|
|
@ -234,8 +224,8 @@ class LoginController extends State<Login> {
|
|||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(L10n.of(context).passwordHasBeenChanged)),
|
||||
);
|
||||
usernameController.text = input.single;
|
||||
passwordController.text = password.single;
|
||||
usernameController.text = input;
|
||||
passwordController.text = password;
|
||||
login();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue