From 08ca53a46d5d59a99e7eb87dce562c927ce7fb96 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Thu, 28 Dec 2023 18:54:44 +0100 Subject: [PATCH] chore: Follow up chat appbar actions --- lib/pages/chat/chat_view.dart | 77 +++++++++++++---------------------- 1 file changed, 29 insertions(+), 48 deletions(-) diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index 9b8894a9..f0d72f56 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -24,8 +24,6 @@ import '../../utils/stream_extension.dart'; import 'chat_emoji_picker.dart'; import 'chat_input_row.dart'; -enum _EventContextAction { info, report } - class ChatView extends StatelessWidget { final ChatController controller; @@ -60,54 +58,30 @@ class ChatView extends StatelessWidget { onPressed: controller.pinEvent, tooltip: L10n.of(context)!.pinMessage, ), - if (controller.canRedactSelectedEvents) + if (controller.selectedEvents.length == 1) ...[ IconButton( - icon: const Icon(Icons.delete_outlined), - tooltip: L10n.of(context)!.redactMessage, - onPressed: controller.redactEventsAction, + icon: const Icon(Icons.info_outlined), + tooltip: L10n.of(context)!.messageInfo, + onPressed: controller.showEventInfo, ), - if (controller.selectedEvents.length == 1) - PopupMenuButton<_EventContextAction>( - onSelected: (action) { - switch (action) { - case _EventContextAction.info: - controller.showEventInfo(); - controller.clearSelectedEvents(); - break; - case _EventContextAction.report: - controller.reportEventAction(); - break; - } - }, - itemBuilder: (context) => [ - PopupMenuItem( - value: _EventContextAction.info, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Icon(Icons.info_outlined), - const SizedBox(width: 12), - Text(L10n.of(context)!.messageInfo), - ], - ), + IconButton( + icon: const Icon( + Icons.shield_outlined, + color: Colors.orange, + ), + tooltip: L10n.of(context)!.reportMessage, + onPressed: controller.reportEventAction, + ), + if (controller.canRedactSelectedEvents) + IconButton( + icon: Icon( + Icons.delete_outlined, + color: Theme.of(context).colorScheme.error, ), - if (controller.selectedEvents.single.status.isSent) - PopupMenuItem( - value: _EventContextAction.report, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Icon( - Icons.shield_outlined, - color: Colors.red, - ), - const SizedBox(width: 12), - Text(L10n.of(context)!.reportMessage), - ], - ), - ), - ], - ), + tooltip: L10n.of(context)!.redactMessage, + onPressed: controller.redactEventsAction, + ), + ], ]; } else if (!controller.room.isArchived) { return [ @@ -178,7 +152,14 @@ class ChatView extends StatelessWidget { ), titleSpacing: 0, title: ChatAppBarTitle(controller), - actions: _appBarActions(context), + actions: _appBarActions(context) + .map( + (icon) => Padding( + padding: const EdgeInsets.only(left: 8), + child: icon, + ), + ) + .toList(), ), floatingActionButton: controller.showScrollDownButton && controller.selectedEvents.isEmpty