refactor: Adjust chat list item UX
This commit is contained in:
parent
e2ad11970f
commit
960d603037
3 changed files with 97 additions and 103 deletions
|
|
@ -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,68 +517,90 @@ class ChatListController extends State<ChatList>
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
if (room.membership == Membership.join) ...[
|
||||||
value: ChatContextAction.mute,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
room.pushRuleState == PushRuleState.notify
|
|
||||||
? Icons.notifications_off_outlined
|
|
||||||
: Icons.notifications_off,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Text(
|
|
||||||
room.pushRuleState == PushRuleState.notify
|
|
||||||
? L10n.of(context).muteChat
|
|
||||||
: L10n.of(context).unmuteChat,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
value: ChatContextAction.markUnread,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
room.markedUnread
|
|
||||||
? Icons.mark_as_unread
|
|
||||||
: Icons.mark_as_unread_outlined,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Text(
|
|
||||||
room.markedUnread
|
|
||||||
? L10n.of(context).markAsRead
|
|
||||||
: L10n.of(context).markAsUnread,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
value: ChatContextAction.favorite,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(room.isFavourite ? Icons.push_pin : Icons.push_pin_outlined),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Text(
|
|
||||||
room.isFavourite
|
|
||||||
? L10n.of(context).unpin
|
|
||||||
: L10n.of(context).pin,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (spacesWithPowerLevels.isNotEmpty)
|
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: ChatContextAction.addToSpace,
|
value: ChatContextAction.mute,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.group_work_outlined),
|
Icon(
|
||||||
|
room.pushRuleState == PushRuleState.notify
|
||||||
|
? Icons.notifications_off_outlined
|
||||||
|
: Icons.notifications_off,
|
||||||
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Text(L10n.of(context).addToSpace),
|
Text(
|
||||||
|
room.pushRuleState == PushRuleState.notify
|
||||||
|
? L10n.of(context).muteChat
|
||||||
|
: L10n.of(context).unmuteChat,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChatContextAction.markUnread,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
room.markedUnread
|
||||||
|
? Icons.mark_as_unread
|
||||||
|
: Icons.mark_as_unread_outlined,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(
|
||||||
|
room.markedUnread
|
||||||
|
? L10n.of(context).markAsRead
|
||||||
|
: L10n.of(context).markAsUnread,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChatContextAction.favorite,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
room.isFavourite ? Icons.push_pin : Icons.push_pin_outlined,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(
|
||||||
|
room.isFavourite
|
||||||
|
? L10n.of(context).unpin
|
||||||
|
: L10n.of(context).pin,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (spacesWithPowerLevels.isNotEmpty)
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChatContextAction.addToSpace,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.group_work_outlined),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(L10n.of(context).addToSpace),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
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),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -632,9 +609,19 @@ class ChatListController extends State<ChatList>
|
||||||
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…
Add table
Add a link
Reference in a new issue