From ca27d50fe7b042bf1b9b09d8a0f62f339dfdd5e7 Mon Sep 17 00:00:00 2001 From: Julian KOUNE Date: Mon, 9 Oct 2023 11:12:54 +0200 Subject: [PATCH] TW-727: close selection mode after action in messages list --- lib/pages/chat/chat.dart | 12 ++++++++---- lib/pages/chat/chat_event_list.dart | 2 +- lib/pages/chat/chat_view.dart | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index fc7a73e02b..bbace50d3a 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -1221,7 +1221,7 @@ class ChatController extends State } } - void pinEvent() { + void pinEventAction() { final room = this.room; if (room == null) return; final pinnedEventIds = room.pinnedEventIds; @@ -1233,7 +1233,6 @@ class ChatController extends State } else { pinnedEventIds.addAll(selectedEventIds); } - clearSelectedEvents(); showFutureLoadingDialog( context: context, future: () => room.setPinnedEvents(pinnedEventIds), @@ -1286,7 +1285,7 @@ class ChatController extends State bool get isArchived => {Membership.leave, Membership.ban}.contains(room?.membership); - void showEventInfo([Event? event]) => + void showEventInfoAction([Event? event]) => (event ?? selectedEvents.single).showInfoDialog(context); void onPhoneButtonTap() async { @@ -1472,7 +1471,7 @@ class ChatController extends State break; case ChatContextMenuActions.pinMessage: onSelectMessage(event); - pinEvent(); + pinEventAction(); break; case ChatContextMenuActions.forward: onSelectMessage(event); @@ -1544,6 +1543,11 @@ class ChatController extends State } } + void actionWithClearSelections(Function action) { + action(); + clearSelectedEvents(); + } + @override Widget build(BuildContext context) { return ChatView(this, key: widget.key); diff --git a/lib/pages/chat/chat_event_list.dart b/lib/pages/chat/chat_event_list.dart index f5eeec40e9..36b02713ee 100644 --- a/lib/pages/chat/chat_event_list.dart +++ b/lib/pages/chat/chat_event_list.dart @@ -108,7 +108,7 @@ class ChatEventList extends StatelessWidget { event, onSwipe: (direction) => controller.replyAction(replyTo: event), - onInfoTab: controller.showEventInfo, + onInfoTab: controller.showEventInfoAction, onAvatarTab: (Event event) => showAdaptiveBottomSheet( context: context, builder: (c) => UserBottomSheet( diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index e84b126f2e..24a9b50775 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -37,29 +37,35 @@ class ChatView extends StatelessWidget { TwakeIconButton( icon: Icons.copy_outlined, tooltip: L10n.of(context)!.copy, - onTap: controller.copyEventsAction, + onTap: () => controller + .actionWithClearSelections(controller.copyEventsAction), ), if (controller.canRedactSelectedEvents) TwakeIconButton( icon: Icons.delete_outlined, tooltip: L10n.of(context)!.redactMessage, - onTap: controller.redactEventsAction, + onTap: () => controller + .actionWithClearSelections(controller.redactEventsAction), ), TwakeIconButton( icon: Icons.push_pin_outlined, - onTap: controller.pinEvent, tooltip: L10n.of(context)!.pinMessage, + onTap: () => + controller.actionWithClearSelections(controller.pinEventAction), ), if (controller.selectedEvents.length == 1) PopupMenuButton<_EventContextAction>( onSelected: (action) { switch (action) { case _EventContextAction.info: - controller.showEventInfo(); - controller.clearSelectedEvents(); + controller.actionWithClearSelections( + controller.showEventInfoAction, + ); break; case _EventContextAction.report: - controller.reportEventAction(); + controller.actionWithClearSelections( + controller.reportEventAction, + ); break; } },