Revert "refactor: Dialog BuildContext"

This reverts commit 315a43c1a4.
This commit is contained in:
Krille 2024-01-25 09:13:08 +01:00
commit 3fa9c65a2b
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
24 changed files with 68 additions and 30 deletions

View file

@ -40,6 +40,7 @@ class ArchiveController extends State<Archive> {
final client = Matrix.of(context).client;
if (archive.isEmpty) return;
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,

View file

@ -388,6 +388,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
: () async {
if (OkCancelResult.ok ==
await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.recoveryKeyLost,
message: L10n.of(context)!.wipeChatBackup,

View file

@ -77,6 +77,7 @@ class ImageBubble extends StatelessWidget {
if (!tapToView) return;
showDialog(
context: context,
useRootNavigator: false,
builder: (_) => ImageViewer(event),
);
}

View file

@ -193,6 +193,7 @@ class _AdaptableReactorsDialog extends StatelessWidget {
context: context,
builder: (context) => this,
barrierDismissible: true,
useRootNavigator: false,
);
@override

View file

@ -59,6 +59,7 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
);
} else if (!kIsWeb && tmpFile != null && _chewieManager == null) {
_chewieManager ??= ChewieController(
useRootNavigator: false,
videoPlayerController: VideoPlayerController.file(tmpFile),
autoPlay: true,
autoInitialize: true,

View file

@ -176,6 +176,7 @@ class ChatListController extends State<ChatList>
void setServer() async {
final newServer = await showTextInputDialog(
useRootNavigator: false,
title: L10n.of(context)!.changeTheHomeserver,
context: context,
okLabel: L10n.of(context)!.ok,
@ -494,12 +495,12 @@ class ChatListController extends State<ChatList>
Future<void> archiveAction() async {
final confirmed = await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.cancel,
message: L10n.of(context)!.archiveRoomDescription,
isDestructiveAction: true,
) ==
OkCancelResult.ok;
if (!confirmed) return;
@ -514,6 +515,7 @@ class ChatListController extends State<ChatList>
final client = Matrix.of(context).client;
final currentPresence = await client.fetchCurrentPresence(client.userID!);
final input = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.setStatus,
message: L10n.of(context)!.leaveEmptyToClearStatus,

View file

@ -118,6 +118,7 @@ class ChatListItem extends StatelessWidget {
shareFile != null) {
await showDialog(
context: context,
useRootNavigator: false,
builder: (c) => SendFileDialog(
files: [shareFile],
room: room,
@ -159,12 +160,12 @@ class ChatListItem extends StatelessWidget {
return;
}
final confirmed = await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.no,
message: L10n.of(context)!.archiveRoomDescription,
isDestructiveAction: true,
);
if (confirmed == OkCancelResult.cancel) return;
await showFutureLoadingDialog(

View file

@ -94,6 +94,7 @@ class ChatPermissionsSettingsController extends State<ChatPermissionsSettings> {
if (newVersion == null ||
OkCancelResult.cancel ==
await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.cancel,

View file

@ -85,6 +85,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
);
if (valid.error != null) {
await showOkAlertDialog(
useRootNavigator: false,
context: context,
message: L10n.of(context)!.incorrectPassphraseOrKey,
);

View file

@ -127,6 +127,7 @@ class LoginController extends State<Login> {
);
final dialogResult = await showOkCancelAlertDialog(
context: context,
useRootNavigator: false,
message:
L10n.of(context)!.noMatrixServer(newDomain, oldHomeserver!),
okLabel: L10n.of(context)!.ok,
@ -156,6 +157,7 @@ class LoginController extends State<Login> {
void passwordForgotten() async {
final input = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.passwordForgotten,
message: L10n.of(context)!.enterAnEmailAddress,
@ -184,6 +186,7 @@ class LoginController extends State<Login> {
);
if (response.error != null) return;
final password = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.passwordForgotten,
message: L10n.of(context)!.chooseAStrongPassword,
@ -201,6 +204,7 @@ class LoginController extends State<Login> {
);
if (password == null) return;
final ok = await showOkAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.weSentYouAnEmail,
message: L10n.of(context)!.pleaseClickOnLink,

View file

@ -35,6 +35,7 @@ class SettingsController extends State<Settings> {
void setDisplaynameAction() async {
final profile = await profileFuture;
final input = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.editDisplayname,
okLabel: L10n.of(context)!.ok,
@ -61,6 +62,7 @@ class SettingsController extends State<Settings> {
void logoutAction() async {
final noBackup = showChatBackupBanner == true;
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSureYouWantToLogout,
message: L10n.of(context)!.noBackupWarning,

View file

@ -20,6 +20,7 @@ class Settings3Pid extends StatefulWidget {
class Settings3PidController extends State<Settings3Pid> {
void add3PidAction() async {
final input = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.enterAnEmailAddress,
okLabel: L10n.of(context)!.ok,
@ -43,6 +44,7 @@ class Settings3PidController extends State<Settings3Pid> {
);
if (response.error != null) return;
final ok = await showOkAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.weSentYouAnEmail,
message: L10n.of(context)!.pleaseClickOnLink,
@ -67,6 +69,7 @@ class Settings3PidController extends State<Settings3Pid> {
void delete3Pid(ThirdPartyIdentifier identifier) async {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,

View file

@ -119,6 +119,7 @@ class _ImportEmoteArchiveDialogState extends State<ImportEmoteArchiveDialog> {
final completer = Completer<OkCancelResult>();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
final result = await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.emoteExists,
message: imageCode,

View file

@ -138,6 +138,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
if (pack!.images.keys.any((k) => k == imageCode && k != oldImageCode)) {
controller.text = oldImageCode;
showOkAlertDialog(
useRootNavigator: false,
context: context,
message: L10n.of(context)!.emoteExists,
okLabel: L10n.of(context)!.ok,
@ -147,6 +148,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
if (!RegExp(r'^[-\w]+$').hasMatch(imageCode)) {
controller.text = oldImageCode;
showOkAlertDialog(
useRootNavigator: false,
context: context,
message: L10n.of(context)!.emoteInvalid,
okLabel: L10n.of(context)!.ok,
@ -182,6 +184,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
if (newImageCodeController.text.isEmpty ||
newImageController.value == null) {
await showOkAlertDialog(
useRootNavigator: false,
context: context,
message: L10n.of(context)!.emoteWarnNeedToPick,
okLabel: L10n.of(context)!.ok,
@ -191,6 +194,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
final imageCode = newImageCodeController.text;
if (pack!.images.containsKey(imageCode)) {
await showOkAlertDialog(
useRootNavigator: false,
context: context,
message: L10n.of(context)!.emoteExists,
okLabel: L10n.of(context)!.ok,
@ -199,6 +203,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
}
if (!RegExp(r'^[-\w]+$').hasMatch(imageCode)) {
await showOkAlertDialog(
useRootNavigator: false,
context: context,
message: L10n.of(context)!.emoteInvalid,
okLabel: L10n.of(context)!.ok,
@ -305,7 +310,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
await showDialog(
context: context,
// breaks [Matrix.of] calls otherwise
useRootNavigator: false,
builder: (context) => ImportEmoteArchiveDialog(
controller: this,
archive: archive,

View file

@ -28,6 +28,7 @@ class SettingsSecurityController extends State<SettingsSecurity> {
AppLock.of(context).showLockScreen();
}
final newLock = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.pleaseChooseAPasscode,
message: L10n.of(context)!.pleaseEnter4Digits,
@ -56,6 +57,7 @@ class SettingsSecurityController extends State<SettingsSecurity> {
void deleteAccountAction() async {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.warning,
message: L10n.of(context)!.deactivateAccountWarning,
@ -67,6 +69,7 @@ class SettingsSecurityController extends State<SettingsSecurity> {
}
final supposedMxid = Matrix.of(context).client.userID!;
final mxids = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.confirmMatrixId,
textFields: [
@ -83,6 +86,7 @@ class SettingsSecurityController extends State<SettingsSecurity> {
return;
}
final input = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.pleaseEnterYourPassword,
okLabel: L10n.of(context)!.ok,

View file

@ -120,6 +120,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
);
if (score == null) return;
final reason = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.whyDoYouWantToReportThis,
okLabel: L10n.of(context)!.ok,
@ -149,12 +150,12 @@ class UserBottomSheetController extends State<UserBottomSheet> {
case UserBottomSheetAction.ban:
if (user == null) throw ('User must not be null for this action!');
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.no,
message: L10n.of(context)!.banUserDescription,
isDestructiveAction: true,
) ==
OkCancelResult.ok) {
await showFutureLoadingDialog(
@ -167,6 +168,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
case UserBottomSheetAction.unban:
if (user == null) throw ('User must not be null for this action!');
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
@ -184,6 +186,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
case UserBottomSheetAction.kick:
if (user == null) throw ('User must not be null for this action!');
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
@ -207,6 +210,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
if (newPermission != null) {
if (newPermission == 100 &&
await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,