diff --git a/lib/config/routes.dart b/lib/config/routes.dart index a2f6f09e4e..d525b94e6e 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -383,16 +383,14 @@ abstract class AppRoutes { static Page defaultPageBuilder(BuildContext context, Widget child) => CustomTransitionPage( child: child, - transitionsBuilder: (context, animation, secondaryAnimation, child) { - Matrix.of(context).navigatorContext = context; - return FluffyThemes.isColumnMode(context) - ? FadeTransition(opacity: animation, child: child) - : CupertinoPageTransition( - primaryRouteAnimation: animation, - secondaryRouteAnimation: secondaryAnimation, - linearTransition: false, - child: child, - ); - }, + transitionsBuilder: (context, animation, secondaryAnimation, child) => + FluffyThemes.isColumnMode(context) + ? FadeTransition(opacity: animation, child: child) + : CupertinoPageTransition( + primaryRouteAnimation: animation, + secondaryRouteAnimation: secondaryAnimation, + linearTransition: false, + child: child, + ), ); } diff --git a/lib/pages/archive/archive.dart b/lib/pages/archive/archive.dart index ad4241be41..a3c35c3470 100644 --- a/lib/pages/archive/archive.dart +++ b/lib/pages/archive/archive.dart @@ -40,6 +40,7 @@ class ArchiveController extends State { 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, diff --git a/lib/pages/bootstrap/bootstrap_dialog.dart b/lib/pages/bootstrap/bootstrap_dialog.dart index 531e1373f5..7aa27fa82b 100644 --- a/lib/pages/bootstrap/bootstrap_dialog.dart +++ b/lib/pages/bootstrap/bootstrap_dialog.dart @@ -388,6 +388,7 @@ class BootstrapDialogState extends State { : () async { if (OkCancelResult.ok == await showOkCancelAlertDialog( + useRootNavigator: false, context: context, title: L10n.of(context)!.recoveryKeyLost, message: L10n.of(context)!.wipeChatBackup, diff --git a/lib/pages/chat/events/image_bubble.dart b/lib/pages/chat/events/image_bubble.dart index b40c6355ea..71b03b6e38 100644 --- a/lib/pages/chat/events/image_bubble.dart +++ b/lib/pages/chat/events/image_bubble.dart @@ -77,6 +77,7 @@ class ImageBubble extends StatelessWidget { if (!tapToView) return; showDialog( context: context, + useRootNavigator: false, builder: (_) => ImageViewer(event), ); } diff --git a/lib/pages/chat/events/message_reactions.dart b/lib/pages/chat/events/message_reactions.dart index d358901760..755f8992a3 100644 --- a/lib/pages/chat/events/message_reactions.dart +++ b/lib/pages/chat/events/message_reactions.dart @@ -193,6 +193,7 @@ class _AdaptableReactorsDialog extends StatelessWidget { context: context, builder: (context) => this, barrierDismissible: true, + useRootNavigator: false, ); @override diff --git a/lib/pages/chat/events/video_player.dart b/lib/pages/chat/events/video_player.dart index 9f204a59e2..573e1eb145 100644 --- a/lib/pages/chat/events/video_player.dart +++ b/lib/pages/chat/events/video_player.dart @@ -59,6 +59,7 @@ class EventVideoPlayerState extends State { ); } else if (!kIsWeb && tmpFile != null && _chewieManager == null) { _chewieManager ??= ChewieController( + useRootNavigator: false, videoPlayerController: VideoPlayerController.file(tmpFile), autoPlay: true, autoInitialize: true, diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index e867833000..db0708ffba 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -176,6 +176,7 @@ class ChatListController extends State 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 Future 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 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, diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 226d64ebb0..fbaa13a91b 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -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( diff --git a/lib/pages/chat_permissions_settings/chat_permissions_settings.dart b/lib/pages/chat_permissions_settings/chat_permissions_settings.dart index f10fbf3880..a6cdcbef0f 100644 --- a/lib/pages/chat_permissions_settings/chat_permissions_settings.dart +++ b/lib/pages/chat_permissions_settings/chat_permissions_settings.dart @@ -94,6 +94,7 @@ class ChatPermissionsSettingsController extends State { if (newVersion == null || OkCancelResult.cancel == await showOkCancelAlertDialog( + useRootNavigator: false, context: context, okLabel: L10n.of(context)!.yes, cancelLabel: L10n.of(context)!.cancel, diff --git a/lib/pages/key_verification/key_verification_dialog.dart b/lib/pages/key_verification/key_verification_dialog.dart index 8d2f21c5a0..99d082a765 100644 --- a/lib/pages/key_verification/key_verification_dialog.dart +++ b/lib/pages/key_verification/key_verification_dialog.dart @@ -85,6 +85,7 @@ class KeyVerificationPageState extends State { ); if (valid.error != null) { await showOkAlertDialog( + useRootNavigator: false, context: context, message: L10n.of(context)!.incorrectPassphraseOrKey, ); diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 78a5353d2a..c62e2100bd 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -127,6 +127,7 @@ class LoginController extends State { ); 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 { 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 { ); 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 { ); if (password == null) return; final ok = await showOkAlertDialog( + useRootNavigator: false, context: context, title: L10n.of(context)!.weSentYouAnEmail, message: L10n.of(context)!.pleaseClickOnLink, diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index eb600ab10d..97bbec66d3 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -35,6 +35,7 @@ class SettingsController extends State { 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 { void logoutAction() async { final noBackup = showChatBackupBanner == true; if (await showOkCancelAlertDialog( + useRootNavigator: false, context: context, title: L10n.of(context)!.areYouSureYouWantToLogout, message: L10n.of(context)!.noBackupWarning, diff --git a/lib/pages/settings_3pid/settings_3pid.dart b/lib/pages/settings_3pid/settings_3pid.dart index 94b1d6f7d4..d46cac2a9b 100644 --- a/lib/pages/settings_3pid/settings_3pid.dart +++ b/lib/pages/settings_3pid/settings_3pid.dart @@ -20,6 +20,7 @@ class Settings3Pid extends StatefulWidget { class Settings3PidController extends State { 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 { ); 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 { void delete3Pid(ThirdPartyIdentifier identifier) async { if (await showOkCancelAlertDialog( + useRootNavigator: false, context: context, title: L10n.of(context)!.areYouSure, okLabel: L10n.of(context)!.yes, diff --git a/lib/pages/settings_emotes/import_archive_dialog.dart b/lib/pages/settings_emotes/import_archive_dialog.dart index 0ab00042eb..0ed5bb21f4 100644 --- a/lib/pages/settings_emotes/import_archive_dialog.dart +++ b/lib/pages/settings_emotes/import_archive_dialog.dart @@ -119,6 +119,7 @@ class _ImportEmoteArchiveDialogState extends State { final completer = Completer(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { final result = await showOkCancelAlertDialog( + useRootNavigator: false, context: context, title: L10n.of(context)!.emoteExists, message: imageCode, diff --git a/lib/pages/settings_emotes/settings_emotes.dart b/lib/pages/settings_emotes/settings_emotes.dart index ebdf10e2a2..2ef905b176 100644 --- a/lib/pages/settings_emotes/settings_emotes.dart +++ b/lib/pages/settings_emotes/settings_emotes.dart @@ -138,6 +138,7 @@ class EmotesSettingsController extends State { 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 { 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 { 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 { 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 { } 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 { await showDialog( context: context, // breaks [Matrix.of] calls otherwise - + useRootNavigator: false, builder: (context) => ImportEmoteArchiveDialog( controller: this, archive: archive, diff --git a/lib/pages/settings_security/settings_security.dart b/lib/pages/settings_security/settings_security.dart index 6c2ee953ab..4482f764ea 100644 --- a/lib/pages/settings_security/settings_security.dart +++ b/lib/pages/settings_security/settings_security.dart @@ -28,6 +28,7 @@ class SettingsSecurityController extends State { 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 { 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 { } 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 { return; } final input = await showTextInputDialog( + useRootNavigator: false, context: context, title: L10n.of(context)!.pleaseEnterYourPassword, okLabel: L10n.of(context)!.ok, diff --git a/lib/pages/user_bottom_sheet/user_bottom_sheet.dart b/lib/pages/user_bottom_sheet/user_bottom_sheet.dart index ac12798710..e2ae9c9ff2 100644 --- a/lib/pages/user_bottom_sheet/user_bottom_sheet.dart +++ b/lib/pages/user_bottom_sheet/user_bottom_sheet.dart @@ -120,6 +120,7 @@ class UserBottomSheetController extends State { ); 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 { 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 { 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 { 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 { if (newPermission != null) { if (newPermission == 100 && await showOkCancelAlertDialog( + useRootNavigator: false, context: context, title: L10n.of(context)!.areYouSure, okLabel: L10n.of(context)!.yes, diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index 9687be2c0d..ff2b432bea 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -324,7 +324,7 @@ class BackgroundPush { } Future setupUp() async { - await UnifiedPush.registerAppWithDialog(matrix!.navigatorContext); + await UnifiedPush.registerAppWithDialog(matrix!.context); } Future _newUpEndpoint(String newEndpoint, String i) async { diff --git a/lib/utils/uia_request_manager.dart b/lib/utils/uia_request_manager.dart index 0608300232..04c8b48448 100644 --- a/lib/utils/uia_request_manager.dart +++ b/lib/utils/uia_request_manager.dart @@ -22,7 +22,7 @@ extension UiaRequestManager on MatrixState { case AuthenticationTypes.password: final input = cachedPassword ?? (await showTextInputDialog( - context: navigatorContext, + context: context, title: l10n.pleaseEnterYourPassword, okLabel: l10n.ok, cancelLabel: l10n.cancel, @@ -62,7 +62,8 @@ extension UiaRequestManager on MatrixState { ); if (OkCancelResult.ok == await showOkCancelAlertDialog( - context: navigatorContext, + useRootNavigator: false, + context: context, title: l10n.weSentYouAnEmail, message: l10n.pleaseClickOnLink, okLabel: l10n.iHaveClickedOnLink, @@ -85,8 +86,9 @@ extension UiaRequestManager on MatrixState { launchUrlString(url.toString()); if (OkCancelResult.ok == await showOkCancelAlertDialog( + useRootNavigator: false, message: l10n.pleaseFollowInstructionsOnWeb, - context: navigatorContext, + context: context, okLabel: l10n.next, cancelLabel: l10n.cancel, )) { diff --git a/lib/utils/url_launcher.dart b/lib/utils/url_launcher.dart index fa724f405d..808f64f65b 100644 --- a/lib/utils/url_launcher.dart +++ b/lib/utils/url_launcher.dart @@ -189,6 +189,7 @@ class UrlLauncher { } if (roomIdOrAlias.sigil == '!') { if (await showOkCancelAlertDialog( + useRootNavigator: false, context: context, title: 'Join room $roomIdOrAlias', ) == diff --git a/lib/utils/voip/callkeep_manager.dart b/lib/utils/voip/callkeep_manager.dart index 7d9f98aa1a..6de7cb6e3a 100644 --- a/lib/utils/voip/callkeep_manager.dart +++ b/lib/utils/voip/callkeep_manager.dart @@ -247,6 +247,7 @@ class CallKeepManager { showDialog( context: context, barrierDismissible: true, + useRootNavigator: false, builder: (_) => AlertDialog( title: Text(L10n.of(context)!.callingPermissions), content: Column( diff --git a/lib/widgets/chat_settings_popup_menu.dart b/lib/widgets/chat_settings_popup_menu.dart index a79f441e6d..277e7170f8 100644 --- a/lib/widgets/chat_settings_popup_menu.dart +++ b/lib/widgets/chat_settings_popup_menu.dart @@ -106,12 +106,12 @@ class ChatSettingsPopupMenuState extends State { switch (choice) { case 'leave': final confirmed = await showOkCancelAlertDialog( + useRootNavigator: false, context: context, title: L10n.of(context)!.areYouSure, okLabel: L10n.of(context)!.ok, cancelLabel: L10n.of(context)!.cancel, message: L10n.of(context)!.archiveRoomDescription, - isDestructiveAction: true, ); if (confirmed == OkCancelResult.ok) { final success = await showFutureLoadingDialog( diff --git a/lib/widgets/fluffy_chat_app.dart b/lib/widgets/fluffy_chat_app.dart index b5838804ce..d9d2f042af 100644 --- a/lib/widgets/fluffy_chat_app.dart +++ b/lib/widgets/fluffy_chat_app.dart @@ -52,10 +52,16 @@ class FluffyChatApp extends StatelessWidget { builder: (context, child) => AppLockWidget( pincode: pincode, clients: clients, - child: Matrix( - clients: clients, - store: store, - child: testWidget ?? child, + // Need a navigator above the Matrix widget for + // displaying dialogs + child: Navigator( + onGenerateRoute: (_) => MaterialPageRoute( + builder: (_) => Matrix( + clients: clients, + store: store, + child: testWidget ?? child, + ), + ), ), ), ), diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 4d9d03368b..9f98931b35 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -71,8 +71,6 @@ class MatrixState extends State with WidgetsBindingObserver { BackgroundPush? backgroundPush; - late BuildContext navigatorContext; - Client get client { if (widget.clients.isEmpty) { widget.clients.add(getLoginClient()); @@ -313,8 +311,7 @@ class MatrixState extends State with WidgetsBindingObserver { }; request.onUpdate = null; hidPopup = true; - - await KeyVerificationDialog(request: request).show(navigatorContext); + await KeyVerificationDialog(request: request).show(context); }); onLoginStateChanged[name] ??= c.onLoginStateChanged.stream.listen((state) { final loggedInWithMultipleClients = widget.clients.length > 1; @@ -325,7 +322,7 @@ class MatrixState extends State with WidgetsBindingObserver { _cancelSubs(c.clientName); widget.clients.remove(c); ClientManager.removeClientNameFromStore(c.clientName, store); - ScaffoldMessenger.of(navigatorContext).showSnackBar( + ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(L10n.of(context)!.oneClientLoggedOut), ), @@ -385,7 +382,7 @@ class MatrixState extends State with WidgetsBindingObserver { onFcmError: (errorMsg, {Uri? link}) async { final result = await showOkCancelAlertDialog( barrierDismissible: true, - context: navigatorContext, + context: context, title: L10n.of(context)!.pushNotificationsNotAvailable, message: errorMsg, fullyCapitalizedForMaterial: false,