mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 12:25:11 +00:00
chore: Add descriptions in the areYouSure dialogs for better UX
This commit is contained in:
parent
969dbef09a
commit
67a4bc71ab
7 changed files with 52 additions and 22 deletions
|
@ -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."
|
||||
}
|
||||
|
|
|
@ -471,6 +471,7 @@ class ChatListController extends State<ChatList>
|
|||
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;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -99,6 +99,7 @@ class ChatPermissionsSettingsController extends State<ChatPermissionsSettings> {
|
|||
okLabel: L10n.of(context)!.yes,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
message: L10n.of(context)!.roomUpgradeDescription,
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
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);
|
||||
|
|
|
@ -92,15 +92,7 @@ class UserBottomSheetController extends State<UserBottomSheet> {
|
|||
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<UserBottomSheet> {
|
|||
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<UserBottomSheet> {
|
|||
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<UserBottomSheet> {
|
|||
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<UserBottomSheet> {
|
|||
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<UserBottomSheet> {
|
|||
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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
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(
|
||||
|
|
Loading…
Reference in a new issue