change: Nicer design for selecting items

This commit is contained in:
Christian Pauly 2021-08-12 21:10:26 +02:00
parent 689e298865
commit 22ae2608e0
3 changed files with 31 additions and 43 deletions

View File

@ -590,20 +590,6 @@ class ChatController extends State<Chat> {
inputFocus.requestFocus(); inputFocus.requestFocus();
} }
void onEventActionPopupMenuSelected(selected) {
switch (selected) {
case 'copy':
copyEventsAction();
break;
case 'redact':
redactEventsAction();
break;
case 'report':
reportEventAction();
break;
}
}
void goToNewRoomAction() async { void goToNewRoomAction() async {
if (OkCancelResult.ok != if (OkCancelResult.ok !=
await showOkCancelAlertDialog( await showOkCancelAlertDialog(

View File

@ -31,6 +31,11 @@ class ChatListView extends StatelessWidget {
}, },
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
actionsIconTheme: IconThemeData(
color: controller.selectedRoomIds.isEmpty
? null
: Theme.of(context).colorScheme.primary,
),
leading: selectMode == SelectMode.normal leading: selectMode == SelectMode.normal
? controller.spaces.isEmpty ? controller.spaces.isEmpty
? null ? null
@ -43,6 +48,7 @@ class ChatListView extends StatelessWidget {
tooltip: L10n.of(context).cancel, tooltip: L10n.of(context).cancel,
icon: Icon(Icons.close_outlined), icon: Icon(Icons.close_outlined),
onPressed: controller.cancelAction, onPressed: controller.cancelAction,
color: Theme.of(context).colorScheme.primary,
), ),
centerTitle: false, centerTitle: false,
titleSpacing: controller.spaces.isEmpty ? null : 0, titleSpacing: controller.spaces.isEmpty ? null : 0,
@ -89,7 +95,7 @@ class ChatListView extends StatelessWidget {
onPressed: controller.toggleMuted, onPressed: controller.toggleMuted,
), ),
IconButton( IconButton(
icon: Icon(Icons.archive_outlined), icon: Icon(Icons.delete_outlined),
tooltip: L10n.of(context).archive, tooltip: L10n.of(context).archive,
onPressed: controller.archiveAction, onPressed: controller.archiveAction,
), ),
@ -176,8 +182,7 @@ class ChatListView extends StatelessWidget {
title: Text(selectMode == SelectMode.share title: Text(selectMode == SelectMode.share
? L10n.of(context).share ? L10n.of(context).share
: selectMode == SelectMode.select : selectMode == SelectMode.select
? L10n.of(context).numberSelected( ? controller.selectedRoomIds.length.toString()
controller.selectedRoomIds.length.toString())
: controller.activeSpaceId == null : controller.activeSpaceId == null
? AppConfig.applicationName ? AppConfig.applicationName
: Matrix.of(context) : Matrix.of(context)

View File

@ -64,11 +64,17 @@ class ChatView extends StatelessWidget {
}, },
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
actionsIconTheme: IconThemeData(
color: controller.selectedEvents.isEmpty
? null
: Theme.of(context).colorScheme.primary,
),
leading: controller.selectMode leading: controller.selectMode
? IconButton( ? IconButton(
icon: Icon(Icons.close), icon: Icon(Icons.close),
onPressed: controller.clearSelectedEvents, onPressed: controller.clearSelectedEvents,
tooltip: L10n.of(context).close, tooltip: L10n.of(context).close,
color: Theme.of(context).colorScheme.primary,
) )
: UnreadBadgeBackButton(roomId: controller.roomId), : UnreadBadgeBackButton(roomId: controller.roomId),
titleSpacing: 0, titleSpacing: 0,
@ -140,8 +146,7 @@ class ChatView extends StatelessWidget {
], ],
), ),
)) ))
: Text(L10n.of(context).numberSelected( : Text(controller.selectedEvents.length.toString()),
controller.selectedEvents.length.toString())),
actions: controller.selectMode actions: controller.selectMode
? <Widget>[ ? <Widget>[
if (controller.selectedEvents.length == 1 && if (controller.selectedEvents.length == 1 &&
@ -153,31 +158,23 @@ class ChatView extends StatelessWidget {
tooltip: L10n.of(context).edit, tooltip: L10n.of(context).edit,
onPressed: controller.editSelectedEventAction, onPressed: controller.editSelectedEventAction,
), ),
PopupMenuButton( IconButton(
onSelected: controller.onEventActionPopupMenuSelected, icon: Icon(Icons.copy_outlined),
itemBuilder: (_) => [ tooltip: L10n.of(context).copy,
PopupMenuItem( onPressed: controller.copyEventsAction,
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),
),
),
],
), ),
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,
),
] ]
: <Widget>[ : <Widget>[
if (controller.room.canSendDefaultStates) if (controller.room.canSendDefaultStates)