diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index b9fc4155a..badf0e8c9 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -113,47 +113,6 @@ class ChatListController extends State void onChatTap(Room room) async { if (room.membership == Membership.invite) { - final inviterId = - room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId; - final inviteAction = await showModalActionSheet( - context: context, - message: room.isDirectChat - ? L10n.of(context).invitePrivateChat - : L10n.of(context).inviteGroupChat, - title: room.getLocalizedDisplayname(MatrixLocals(L10n.of(context))), - actions: [ - SheetAction( - key: InviteActions.accept, - label: L10n.of(context).accept, - icon: Icons.check_outlined, - isDefaultAction: true, - ), - SheetAction( - key: InviteActions.decline, - label: L10n.of(context).decline, - icon: Icons.close_outlined, - isDestructiveAction: true, - ), - SheetAction( - key: InviteActions.block, - label: L10n.of(context).block, - icon: Icons.block_outlined, - isDestructiveAction: true, - ), - ], - ); - if (inviteAction == null) return; - if (inviteAction == InviteActions.block) { - context.go('/rooms/settings/security/ignorelist', extra: inviterId); - return; - } - if (inviteAction == InviteActions.decline) { - await showFutureLoadingDialog( - context: context, - future: room.leave, - ); - return; - } final joinResult = await showFutureLoadingDialog( context: context, future: () async { @@ -486,10 +445,6 @@ class ChatListController extends State BuildContext posContext, [ Room? space, ]) async { - if (room.membership == Membership.invite) { - return onChatTap(room); - } - final overlay = Overlay.of(posContext).context.findRenderObject() as RenderBox; @@ -562,68 +517,90 @@ class ChatListController extends State ], ), ), - PopupMenuItem( - value: ChatContextAction.mute, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - room.pushRuleState == PushRuleState.notify - ? Icons.notifications_off_outlined - : Icons.notifications_off, - ), - const SizedBox(width: 12), - Text( - room.pushRuleState == PushRuleState.notify - ? L10n.of(context).muteChat - : L10n.of(context).unmuteChat, - ), - ], - ), - ), - PopupMenuItem( - value: ChatContextAction.markUnread, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - room.markedUnread - ? Icons.mark_as_unread - : Icons.mark_as_unread_outlined, - ), - const SizedBox(width: 12), - Text( - room.markedUnread - ? L10n.of(context).markAsRead - : L10n.of(context).markAsUnread, - ), - ], - ), - ), - PopupMenuItem( - value: ChatContextAction.favorite, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon(room.isFavourite ? Icons.push_pin : Icons.push_pin_outlined), - const SizedBox(width: 12), - Text( - room.isFavourite - ? L10n.of(context).unpin - : L10n.of(context).pin, - ), - ], - ), - ), - if (spacesWithPowerLevels.isNotEmpty) + if (room.membership == Membership.join) ...[ PopupMenuItem( - value: ChatContextAction.addToSpace, + value: ChatContextAction.mute, child: Row( mainAxisSize: MainAxisSize.min, children: [ - const Icon(Icons.group_work_outlined), + Icon( + room.pushRuleState == PushRuleState.notify + ? Icons.notifications_off_outlined + : Icons.notifications_off, + ), const SizedBox(width: 12), - Text(L10n.of(context).addToSpace), + Text( + room.pushRuleState == PushRuleState.notify + ? L10n.of(context).muteChat + : L10n.of(context).unmuteChat, + ), + ], + ), + ), + PopupMenuItem( + value: ChatContextAction.markUnread, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + room.markedUnread + ? Icons.mark_as_unread + : Icons.mark_as_unread_outlined, + ), + const SizedBox(width: 12), + Text( + room.markedUnread + ? L10n.of(context).markAsRead + : L10n.of(context).markAsUnread, + ), + ], + ), + ), + PopupMenuItem( + value: ChatContextAction.favorite, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + room.isFavourite ? Icons.push_pin : Icons.push_pin_outlined, + ), + const SizedBox(width: 12), + Text( + room.isFavourite + ? L10n.of(context).unpin + : L10n.of(context).pin, + ), + ], + ), + ), + if (spacesWithPowerLevels.isNotEmpty) + PopupMenuItem( + value: ChatContextAction.addToSpace, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.group_work_outlined), + const SizedBox(width: 12), + Text(L10n.of(context).addToSpace), + ], + ), + ), + ], + if (room.membership == Membership.invite) + PopupMenuItem( + value: ChatContextAction.block, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.block_outlined, + color: Theme.of(context).colorScheme.error, + ), + const SizedBox(width: 12), + Text( + L10n.of(context).block, + style: TextStyle(color: Theme.of(context).colorScheme.error), + ), ], ), ), @@ -632,9 +609,19 @@ class ChatListController extends State child: Row( mainAxisSize: MainAxisSize.min, children: [ - const Icon(Icons.delete_outlined), + Icon( + Icons.delete_outlined, + color: Theme.of(context).colorScheme.onErrorContainer, + ), const SizedBox(width: 12), - Text(L10n.of(context).leave), + Text( + room.membership == Membership.invite + ? L10n.of(context).delete + : L10n.of(context).leave, + style: TextStyle( + color: Theme.of(context).colorScheme.onErrorContainer, + ), + ), ], ), ), @@ -678,9 +665,9 @@ class ChatListController extends State useRootNavigator: false, context: context, title: L10n.of(context).areYouSure, - okLabel: L10n.of(context).leave, - cancelLabel: L10n.of(context).no, message: L10n.of(context).archiveRoomDescription, + okLabel: L10n.of(context).leave, + cancelLabel: L10n.of(context).cancel, isDestructiveAction: true, ); if (confirmed == OkCancelResult.cancel) return; @@ -708,6 +695,10 @@ class ChatListController extends State context: context, future: () => space.setSpaceChild(room.id), ); + case ChatContextAction.block: + final userId = + room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId; + context.go('/rooms/settings/security/ignorelist', extra: userId); } } @@ -935,4 +926,5 @@ enum ChatContextAction { mute, leave, addToSpace, + block } diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 639bd1b90..dfa6ff996 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -136,6 +136,7 @@ class _SpaceViewState extends State { okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, message: L10n.of(context).archiveRoomDescription, + isDestructiveAction: true, ); if (!mounted) return; if (confirmed != OkCancelResult.ok) return; diff --git a/lib/widgets/chat_settings_popup_menu.dart b/lib/widgets/chat_settings_popup_menu.dart index 398d606dd..8427ca40a 100644 --- a/lib/widgets/chat_settings_popup_menu.dart +++ b/lib/widgets/chat_settings_popup_menu.dart @@ -62,6 +62,7 @@ class ChatSettingsPopupMenuState extends State { 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(