From 22ae2608e003a991db35bddab55eb488f92258ef Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 12 Aug 2021 21:10:26 +0200 Subject: [PATCH] change: Nicer design for selecting items --- lib/pages/chat.dart | 14 --------- lib/pages/views/chat_list_view.dart | 11 +++++-- lib/pages/views/chat_view.dart | 49 ++++++++++++++--------------- 3 files changed, 31 insertions(+), 43 deletions(-) diff --git a/lib/pages/chat.dart b/lib/pages/chat.dart index b05da19d..6eeb868b 100644 --- a/lib/pages/chat.dart +++ b/lib/pages/chat.dart @@ -590,20 +590,6 @@ class ChatController extends State { inputFocus.requestFocus(); } - void onEventActionPopupMenuSelected(selected) { - switch (selected) { - case 'copy': - copyEventsAction(); - break; - case 'redact': - redactEventsAction(); - break; - case 'report': - reportEventAction(); - break; - } - } - void goToNewRoomAction() async { if (OkCancelResult.ok != await showOkCancelAlertDialog( diff --git a/lib/pages/views/chat_list_view.dart b/lib/pages/views/chat_list_view.dart index 7414a860..e197d2b7 100644 --- a/lib/pages/views/chat_list_view.dart +++ b/lib/pages/views/chat_list_view.dart @@ -31,6 +31,11 @@ class ChatListView extends StatelessWidget { }, child: Scaffold( appBar: AppBar( + actionsIconTheme: IconThemeData( + color: controller.selectedRoomIds.isEmpty + ? null + : Theme.of(context).colorScheme.primary, + ), leading: selectMode == SelectMode.normal ? controller.spaces.isEmpty ? null @@ -43,6 +48,7 @@ class ChatListView extends StatelessWidget { tooltip: L10n.of(context).cancel, icon: Icon(Icons.close_outlined), onPressed: controller.cancelAction, + color: Theme.of(context).colorScheme.primary, ), centerTitle: false, titleSpacing: controller.spaces.isEmpty ? null : 0, @@ -89,7 +95,7 @@ class ChatListView extends StatelessWidget { onPressed: controller.toggleMuted, ), IconButton( - icon: Icon(Icons.archive_outlined), + icon: Icon(Icons.delete_outlined), tooltip: L10n.of(context).archive, onPressed: controller.archiveAction, ), @@ -176,8 +182,7 @@ class ChatListView extends StatelessWidget { title: Text(selectMode == SelectMode.share ? L10n.of(context).share : selectMode == SelectMode.select - ? L10n.of(context).numberSelected( - controller.selectedRoomIds.length.toString()) + ? controller.selectedRoomIds.length.toString() : controller.activeSpaceId == null ? AppConfig.applicationName : Matrix.of(context) diff --git a/lib/pages/views/chat_view.dart b/lib/pages/views/chat_view.dart index 3b718dbf..0e5023b2 100644 --- a/lib/pages/views/chat_view.dart +++ b/lib/pages/views/chat_view.dart @@ -64,11 +64,17 @@ class ChatView extends StatelessWidget { }, child: Scaffold( appBar: AppBar( + actionsIconTheme: IconThemeData( + color: controller.selectedEvents.isEmpty + ? null + : Theme.of(context).colorScheme.primary, + ), leading: controller.selectMode ? IconButton( icon: Icon(Icons.close), onPressed: controller.clearSelectedEvents, tooltip: L10n.of(context).close, + color: Theme.of(context).colorScheme.primary, ) : UnreadBadgeBackButton(roomId: controller.roomId), titleSpacing: 0, @@ -140,8 +146,7 @@ class ChatView extends StatelessWidget { ], ), )) - : Text(L10n.of(context).numberSelected( - controller.selectedEvents.length.toString())), + : Text(controller.selectedEvents.length.toString()), actions: controller.selectMode ? [ if (controller.selectedEvents.length == 1 && @@ -153,31 +158,23 @@ class ChatView extends StatelessWidget { tooltip: L10n.of(context).edit, onPressed: controller.editSelectedEventAction, ), - PopupMenuButton( - onSelected: controller.onEventActionPopupMenuSelected, - itemBuilder: (_) => [ - PopupMenuItem( - value: 'copy', - child: Text(L10n.of(context).copy), - ), - if (controller.canRedactSelectedEvents) - PopupMenuItem( - value: 'redact', - child: Text( - L10n.of(context).redactMessage, - style: TextStyle(color: Colors.orange), - ), - ), - if (controller.selectedEvents.length == 1) - PopupMenuItem( - value: 'report', - child: Text( - L10n.of(context).reportMessage, - style: TextStyle(color: Colors.red), - ), - ), - ], + IconButton( + icon: Icon(Icons.copy_outlined), + tooltip: L10n.of(context).copy, + onPressed: controller.copyEventsAction, ), + if (controller.canRedactSelectedEvents) + IconButton( + icon: Icon(Icons.report_outlined), + tooltip: L10n.of(context).reportMessage, + onPressed: controller.reportEventAction, + ), + if (controller.canRedactSelectedEvents) + IconButton( + icon: Icon(Icons.delete_outlined), + tooltip: L10n.of(context).redactMessage, + onPressed: controller.redactEventsAction, + ), ] : [ if (controller.room.canSendDefaultStates)