refactor: Adjust chat list item UX

pull/1517/head
Krille 3 months ago
parent e2ad11970f
commit 960d603037
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -113,47 +113,6 @@ class ChatListController extends State<ChatList>
void onChatTap(Room room) async { void onChatTap(Room room) async {
if (room.membership == Membership.invite) { if (room.membership == Membership.invite) {
final inviterId =
room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId;
final inviteAction = await showModalActionSheet<InviteActions>(
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( final joinResult = await showFutureLoadingDialog(
context: context, context: context,
future: () async { future: () async {
@ -486,10 +445,6 @@ class ChatListController extends State<ChatList>
BuildContext posContext, [ BuildContext posContext, [
Room? space, Room? space,
]) async { ]) async {
if (room.membership == Membership.invite) {
return onChatTap(room);
}
final overlay = final overlay =
Overlay.of(posContext).context.findRenderObject() as RenderBox; Overlay.of(posContext).context.findRenderObject() as RenderBox;
@ -562,6 +517,7 @@ class ChatListController extends State<ChatList>
], ],
), ),
), ),
if (room.membership == Membership.join) ...[
PopupMenuItem( PopupMenuItem(
value: ChatContextAction.mute, value: ChatContextAction.mute,
child: Row( child: Row(
@ -605,7 +561,9 @@ class ChatListController extends State<ChatList>
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Icon(room.isFavourite ? Icons.push_pin : Icons.push_pin_outlined), Icon(
room.isFavourite ? Icons.push_pin : Icons.push_pin_outlined,
),
const SizedBox(width: 12), const SizedBox(width: 12),
Text( Text(
room.isFavourite room.isFavourite
@ -627,14 +585,43 @@ class ChatListController extends State<ChatList>
], ],
), ),
), ),
],
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),
),
],
),
),
PopupMenuItem( PopupMenuItem(
value: ChatContextAction.leave, value: ChatContextAction.leave,
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
const Icon(Icons.delete_outlined), Icon(
Icons.delete_outlined,
color: Theme.of(context).colorScheme.onErrorContainer,
),
const SizedBox(width: 12), 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<ChatList>
useRootNavigator: false, useRootNavigator: false,
context: context, context: context,
title: L10n.of(context).areYouSure, title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).leave,
cancelLabel: L10n.of(context).no,
message: L10n.of(context).archiveRoomDescription, message: L10n.of(context).archiveRoomDescription,
okLabel: L10n.of(context).leave,
cancelLabel: L10n.of(context).cancel,
isDestructiveAction: true, isDestructiveAction: true,
); );
if (confirmed == OkCancelResult.cancel) return; if (confirmed == OkCancelResult.cancel) return;
@ -708,6 +695,10 @@ class ChatListController extends State<ChatList>
context: context, context: context,
future: () => space.setSpaceChild(room.id), 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, mute,
leave, leave,
addToSpace, addToSpace,
block
} }

@ -136,6 +136,7 @@ class _SpaceViewState extends State<SpaceView> {
okLabel: L10n.of(context).ok, okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel, cancelLabel: L10n.of(context).cancel,
message: L10n.of(context).archiveRoomDescription, message: L10n.of(context).archiveRoomDescription,
isDestructiveAction: true,
); );
if (!mounted) return; if (!mounted) return;
if (confirmed != OkCancelResult.ok) return; if (confirmed != OkCancelResult.ok) return;

@ -62,6 +62,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
okLabel: L10n.of(context).ok, okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel, cancelLabel: L10n.of(context).cancel,
message: L10n.of(context).archiveRoomDescription, message: L10n.of(context).archiveRoomDescription,
isDestructiveAction: true,
); );
if (confirmed == OkCancelResult.ok) { if (confirmed == OkCancelResult.ok) {
final success = await showFutureLoadingDialog( final success = await showFutureLoadingDialog(

Loading…
Cancel
Save