From 67a4bc71ab5bef8043437f001066b3d2301eec10 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sat, 28 Oct 2023 10:54:41 +0200 Subject: [PATCH] chore: Add descriptions in the areYouSure dialogs for better UX --- assets/l10n/intl_en.arb | 9 ++- lib/pages/chat_list/chat_list.dart | 1 + lib/pages/chat_list/chat_list_item.dart | 1 + .../chat_permissions_settings.dart | 1 + .../device_settings/device_settings.dart | 1 + .../user_bottom_sheet/user_bottom_sheet.dart | 60 ++++++++++++------- lib/widgets/chat_settings_popup_menu.dart | 1 + 7 files changed, 52 insertions(+), 22 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index cb1dcbe5..088f7802 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2534,5 +2534,12 @@ "seconds": {} } }, - "pleaseEnterANumber": "Please enter a number greater than 0" + "pleaseEnterANumber": "Please enter a number greater than 0", + "archiveRoomDescription": "The chat will be moved to the archive. Other users will be able to see that you have left the chat.", + "roomUpgradeDescription": "The chat will then be recreated with the new room version. All participants will be notified that they need to switch to the new chat. You can find out more about room versions at https://spec.matrix.org/latest/rooms/", + "removeDevicesDescription": "You will be logged out of this device and will no longer be able to receive messages.", + "banUserDescription": "The user will be banned from the chat and will not be able to enter the chat again until they are unbanned.", + "unbanUserDescription": "The user will be able to enter the chat again if they try.", + "kickUserDescription": "The user is kicked out of the chat but not banned. In public chats, the user can rejoin at any time.", + "makeAdminDescription": "Once you make this user admin, you may not be able to undo this as they will then have the same permissions as you." } diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index b972847f..79542fd8 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -471,6 +471,7 @@ class ChatListController extends State title: L10n.of(context)!.areYouSure, okLabel: L10n.of(context)!.yes, cancelLabel: L10n.of(context)!.cancel, + message: L10n.of(context)!.archiveRoomDescription, ) == OkCancelResult.ok; if (!confirmed) return; diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 9475b8a4..41a4aec3 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -132,6 +132,7 @@ class ChatListItem extends StatelessWidget { title: L10n.of(context)!.areYouSure, okLabel: L10n.of(context)!.yes, cancelLabel: L10n.of(context)!.no, + message: L10n.of(context)!.archiveRoomDescription, ); 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 394206f1..45983574 100644 --- a/lib/pages/chat_permissions_settings/chat_permissions_settings.dart +++ b/lib/pages/chat_permissions_settings/chat_permissions_settings.dart @@ -99,6 +99,7 @@ class ChatPermissionsSettingsController extends State { okLabel: L10n.of(context)!.yes, cancelLabel: L10n.of(context)!.cancel, title: L10n.of(context)!.areYouSure, + message: L10n.of(context)!.roomUpgradeDescription, )) { return; } diff --git a/lib/pages/device_settings/device_settings.dart b/lib/pages/device_settings/device_settings.dart index 59e9e658..25011c5f 100644 --- a/lib/pages/device_settings/device_settings.dart +++ b/lib/pages/device_settings/device_settings.dart @@ -38,6 +38,7 @@ class DevicesSettingsController extends State { title: L10n.of(context)!.areYouSure, okLabel: L10n.of(context)!.yes, cancelLabel: L10n.of(context)!.cancel, + message: L10n.of(context)!.removeDevicesDescription, ) == OkCancelResult.cancel) return; final matrix = Matrix.of(context); diff --git a/lib/pages/user_bottom_sheet/user_bottom_sheet.dart b/lib/pages/user_bottom_sheet/user_bottom_sheet.dart index b38efa21..7234317a 100644 --- a/lib/pages/user_bottom_sheet/user_bottom_sheet.dart +++ b/lib/pages/user_bottom_sheet/user_bottom_sheet.dart @@ -92,15 +92,7 @@ class UserBottomSheetController extends State { final user = widget.user; final userId = user?.id ?? widget.profile?.userId; if (userId == null) throw ('user or profile must not be null!'); - // ignore: prefer_function_declarations_over_variables - final Function askConfirmation = () async => (await showOkCancelAlertDialog( - useRootNavigator: false, - context: context, - title: L10n.of(context)!.areYouSure, - okLabel: L10n.of(context)!.yes, - cancelLabel: L10n.of(context)!.no, - ) == - OkCancelResult.ok); + switch (action) { case UserBottomSheetAction.report: if (user == null) throw ('User must not be null for this action!'); @@ -157,7 +149,15 @@ class UserBottomSheetController extends State { break; case UserBottomSheetAction.ban: if (user == null) throw ('User must not be null for this action!'); - if (await askConfirmation()) { + 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, + ) == + OkCancelResult.ok) { await showFutureLoadingDialog( context: context, future: () => user.ban(), @@ -167,7 +167,15 @@ class UserBottomSheetController extends State { break; case UserBottomSheetAction.unban: if (user == null) throw ('User must not be null for this action!'); - if (await askConfirmation()) { + 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)!.unbanUserDescription, + ) == + OkCancelResult.ok) { await showFutureLoadingDialog( context: context, future: () => user.unban(), @@ -177,7 +185,15 @@ class UserBottomSheetController extends State { break; case UserBottomSheetAction.kick: if (user == null) throw ('User must not be null for this action!'); - if (await askConfirmation()) { + 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)!.kickUserDescription, + ) == + OkCancelResult.ok) { await showFutureLoadingDialog( context: context, future: () => user.kick(), @@ -192,7 +208,16 @@ class UserBottomSheetController extends State { currentLevel: user.powerLevel, ); if (newPermission != null) { - if (newPermission == 100 && await askConfirmation() == false) break; + if (newPermission == 100 && + 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)!.makeAdminDescription, + ) == + OkCancelResult.ok) break; await showFutureLoadingDialog( context: context, future: () => user.setPower(newPermission), @@ -212,14 +237,7 @@ class UserBottomSheetController extends State { Navigator.of(context, rootNavigator: false).pop(); break; case UserBottomSheetAction.ignore: - if (await askConfirmation()) { - await showFutureLoadingDialog( - context: context, - future: () => Matrix.of(widget.outerContext) - .client - .ignoreUser(user?.id ?? widget.profile!.userId), - ); - } + context.go('/rooms/settings/security/ignorelist'); } } diff --git a/lib/widgets/chat_settings_popup_menu.dart b/lib/widgets/chat_settings_popup_menu.dart index fbbb4978..bc7e929a 100644 --- a/lib/widgets/chat_settings_popup_menu.dart +++ b/lib/widgets/chat_settings_popup_menu.dart @@ -112,6 +112,7 @@ class ChatSettingsPopupMenuState extends State { title: L10n.of(context)!.areYouSure, okLabel: L10n.of(context)!.ok, cancelLabel: L10n.of(context)!.cancel, + message: L10n.of(context)!.archiveRoomDescription, ); if (confirmed == OkCancelResult.ok) { final success = await showFutureLoadingDialog(