mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
fix: Naming
This commit is contained in:
parent
76e51ef315
commit
20c9627b23
@ -1,18 +1,14 @@
|
|||||||
import 'package:fluffychat/widgets/matrix.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
||||||
|
|
||||||
class UiaRequestManager {
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
final MatrixState matrix;
|
|
||||||
final String cachedPassword;
|
|
||||||
|
|
||||||
UiaRequestManager(this.matrix, [this.cachedPassword]);
|
extension UiaRequestManager on MatrixState {
|
||||||
|
Future uiaRequestHandler(UiaRequest uiaRequest) async {
|
||||||
Future onUiaRequest(UiaRequest uiaRequest) async {
|
|
||||||
try {
|
try {
|
||||||
if (uiaRequest.state != UiaRequestState.waitForUser ||
|
if (uiaRequest.state != UiaRequestState.waitForUser ||
|
||||||
uiaRequest.nextStages.isEmpty) return;
|
uiaRequest.nextStages.isEmpty) return;
|
||||||
@ -21,10 +17,10 @@ class UiaRequestManager {
|
|||||||
case AuthenticationTypes.password:
|
case AuthenticationTypes.password:
|
||||||
final input = cachedPassword ??
|
final input = cachedPassword ??
|
||||||
(await showTextInputDialog(
|
(await showTextInputDialog(
|
||||||
context: matrix.navigatorContext,
|
context: navigatorContext,
|
||||||
title: L10n.of(matrix.context).pleaseEnterYourPassword,
|
title: L10n.of(context).pleaseEnterYourPassword,
|
||||||
okLabel: L10n.of(matrix.context).ok,
|
okLabel: L10n.of(context).ok,
|
||||||
cancelLabel: L10n.of(matrix.context).cancel,
|
cancelLabel: L10n.of(context).cancel,
|
||||||
textFields: [
|
textFields: [
|
||||||
const DialogTextField(
|
const DialogTextField(
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
@ -40,30 +36,28 @@ class UiaRequestManager {
|
|||||||
AuthenticationPassword(
|
AuthenticationPassword(
|
||||||
session: uiaRequest.session,
|
session: uiaRequest.session,
|
||||||
password: input,
|
password: input,
|
||||||
identifier:
|
identifier: AuthenticationUserIdentifier(user: client.userID),
|
||||||
AuthenticationUserIdentifier(user: matrix.client.userID),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case AuthenticationTypes.emailIdentity:
|
case AuthenticationTypes.emailIdentity:
|
||||||
final emailInput = await showTextInputDialog(
|
final emailInput = await showTextInputDialog(
|
||||||
context: matrix.navigatorContext,
|
context: navigatorContext,
|
||||||
message: L10n.of(matrix.context).serverRequiresEmail,
|
message: L10n.of(context).serverRequiresEmail,
|
||||||
okLabel: L10n.of(matrix.context).next,
|
okLabel: L10n.of(context).next,
|
||||||
cancelLabel: L10n.of(matrix.context).cancel,
|
cancelLabel: L10n.of(context).cancel,
|
||||||
textFields: [
|
textFields: [
|
||||||
DialogTextField(
|
DialogTextField(
|
||||||
hintText: L10n.of(matrix.context).addEmail,
|
hintText: L10n.of(context).addEmail,
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (emailInput == null || emailInput.isEmpty) {
|
if (emailInput == null || emailInput.isEmpty) {
|
||||||
return uiaRequest
|
return uiaRequest
|
||||||
.cancel(Exception(L10n.of(matrix.context).serverRequiresEmail));
|
.cancel(Exception(L10n.of(context).serverRequiresEmail));
|
||||||
}
|
}
|
||||||
final clientSecret = DateTime.now().millisecondsSinceEpoch.toString();
|
final clientSecret = DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
final currentThreepidCreds =
|
final currentThreepidCreds = await client.requestTokenToRegisterEmail(
|
||||||
await matrix.client.requestTokenToRegisterEmail(
|
|
||||||
clientSecret,
|
clientSecret,
|
||||||
emailInput.single,
|
emailInput.single,
|
||||||
0,
|
0,
|
||||||
@ -81,11 +75,11 @@ class UiaRequestManager {
|
|||||||
if (OkCancelResult.ok ==
|
if (OkCancelResult.ok ==
|
||||||
await showOkCancelAlertDialog(
|
await showOkCancelAlertDialog(
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
context: matrix.navigatorContext,
|
context: navigatorContext,
|
||||||
title: L10n.of(matrix.context).weSentYouAnEmail,
|
title: L10n.of(context).weSentYouAnEmail,
|
||||||
message: L10n.of(matrix.context).pleaseClickOnLink,
|
message: L10n.of(context).pleaseClickOnLink,
|
||||||
okLabel: L10n.of(matrix.context).iHaveClickedOnLink,
|
okLabel: L10n.of(context).iHaveClickedOnLink,
|
||||||
cancelLabel: L10n.of(matrix.context).cancel,
|
cancelLabel: L10n.of(context).cancel,
|
||||||
)) {
|
)) {
|
||||||
return uiaRequest.completeStage(auth);
|
return uiaRequest.completeStage(auth);
|
||||||
}
|
}
|
||||||
@ -99,16 +93,16 @@ class UiaRequestManager {
|
|||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
await launch(
|
await launch(
|
||||||
matrix.client.homeserver.toString() +
|
client.homeserver.toString() +
|
||||||
'/_matrix/client/r0/auth/$stage/fallback/web?session=${uiaRequest.session}',
|
'/_matrix/client/r0/auth/$stage/fallback/web?session=${uiaRequest.session}',
|
||||||
);
|
);
|
||||||
if (OkCancelResult.ok ==
|
if (OkCancelResult.ok ==
|
||||||
await showOkCancelAlertDialog(
|
await showOkCancelAlertDialog(
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
message: L10n.of(matrix.context).pleaseFollowInstructionsOnWeb,
|
message: L10n.of(context).pleaseFollowInstructionsOnWeb,
|
||||||
context: matrix.navigatorContext,
|
context: navigatorContext,
|
||||||
okLabel: L10n.of(matrix.context).next,
|
okLabel: L10n.of(context).next,
|
||||||
cancelLabel: L10n.of(matrix.context).cancel,
|
cancelLabel: L10n.of(context).cancel,
|
||||||
)) {
|
)) {
|
||||||
return uiaRequest.completeStage(
|
return uiaRequest.completeStage(
|
||||||
AuthenticationData(session: uiaRequest.session),
|
AuthenticationData(session: uiaRequest.session),
|
||||||
|
Loading…
Reference in New Issue
Block a user