Skip to content

Commit

Permalink
Revert "refactor: Dialog BuildContext"
Browse files Browse the repository at this point in the history
This reverts commit 315a43c.
  • Loading branch information
krille-chan committed Jan 25, 2024
1 parent 81c354e commit 3fa9c65
Show file tree
Hide file tree
Showing 24 changed files with 68 additions and 30 deletions.
20 changes: 9 additions & 11 deletions lib/config/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
}
1 change: 1 addition & 0 deletions lib/pages/archive/archive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/pages/bootstrap/bootstrap_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/pages/chat/events/image_bubble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class ImageBubble extends StatelessWidget {
if (!tapToView) return;
showDialog(
context: context,
useRootNavigator: false,
builder: (_) => ImageViewer(event),
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/pages/chat/events/message_reactions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class _AdaptableReactorsDialog extends StatelessWidget {
context: context,
builder: (context) => this,
barrierDismissible: true,
useRootNavigator: false,
);

@override
Expand Down
1 change: 1 addition & 0 deletions lib/pages/chat/events/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/chat_list/chat_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class ChatListItem extends StatelessWidget {
shareFile != null) {
await showDialog(
context: context,
useRootNavigator: false,
builder: (c) => SendFileDialog(
files: [shareFile],
room: room,
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/pages/key_verification/key_verification_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
);
if (valid.error != null) {
await showOkAlertDialog(
useRootNavigator: false,
context: context,
message: L10n.of(context)!.incorrectPassphraseOrKey,
);
Expand Down
4 changes: 4 additions & 0 deletions lib/pages/login/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/settings_3pid/settings_3pid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/pages/settings_emotes/import_archive_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion lib/pages/settings_emotes/settings_emotes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions lib/pages/settings_security/settings_security.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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: [
Expand All @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion lib/pages/user_bottom_sheet/user_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/background_push.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class BackgroundPush {
}

Future<void> setupUp() async {
await UnifiedPush.registerAppWithDialog(matrix!.navigatorContext);
await UnifiedPush.registerAppWithDialog(matrix!.context);
}

Future<void> _newUpEndpoint(String newEndpoint, String i) async {
Expand Down
8 changes: 5 additions & 3 deletions lib/utils/uia_request_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
)) {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/url_launcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class UrlLauncher {
}
if (roomIdOrAlias.sigil == '!') {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: 'Join room $roomIdOrAlias',
) ==
Expand Down
1 change: 1 addition & 0 deletions lib/utils/voip/callkeep_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class CallKeepManager {
showDialog(
context: context,
barrierDismissible: true,
useRootNavigator: false,
builder: (_) => AlertDialog(
title: Text(L10n.of(context)!.callingPermissions),
content: Column(
Expand Down
Loading

0 comments on commit 3fa9c65

Please sign in to comment.