feat: Swipe to archive rooms
This commit is contained in:
parent
fcc43e3328
commit
3f9c7f3e91
1 changed files with 303 additions and 272 deletions
|
|
@ -35,29 +35,31 @@ class ChatListItem extends StatelessWidget {
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<void> archiveAction(BuildContext context) async {
|
Future<bool> archiveAction(BuildContext context, {bool? confirmed}) async {
|
||||||
{
|
{
|
||||||
if ([Membership.leave, Membership.ban].contains(room.membership)) {
|
if ([Membership.leave, Membership.ban].contains(room.membership)) {
|
||||||
await showFutureLoadingDialog(
|
await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () => room.forget(),
|
future: () => room.forget(),
|
||||||
);
|
);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
final confirmed = await showOkCancelAlertDialog(
|
confirmed ??= (await showOkCancelAlertDialog(
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
context: context,
|
context: context,
|
||||||
title: L10n.of(context).areYouSure,
|
title: L10n.of(context).areYouSure,
|
||||||
okLabel: L10n.of(context).yes,
|
okLabel: L10n.of(context).leave,
|
||||||
cancelLabel: L10n.of(context).no,
|
cancelLabel: L10n.of(context).cancel,
|
||||||
message: L10n.of(context).archiveRoomDescription,
|
message: L10n.of(context).archiveRoomDescription,
|
||||||
);
|
isDestructiveAction: true,
|
||||||
if (confirmed == OkCancelResult.cancel) return;
|
)) ==
|
||||||
|
OkCancelResult.ok;
|
||||||
|
if (!confirmed) return false;
|
||||||
await showFutureLoadingDialog(
|
await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () => room.leave(),
|
future: () => room.leave(),
|
||||||
);
|
);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +95,28 @@ class ChatListItem extends StatelessWidget {
|
||||||
: room.getState(EventTypes.RoomMember, lastEvent.senderId) == null;
|
: room.getState(EventTypes.RoomMember, lastEvent.senderId) == null;
|
||||||
final space = this.space;
|
final space = this.space;
|
||||||
|
|
||||||
return Padding(
|
return Dismissible(
|
||||||
|
key: ValueKey(room.id),
|
||||||
|
confirmDismiss: (_) async =>
|
||||||
|
(await showOkCancelAlertDialog(
|
||||||
|
useRootNavigator: false,
|
||||||
|
context: context,
|
||||||
|
title: L10n.of(context).areYouSure,
|
||||||
|
okLabel: L10n.of(context).leave,
|
||||||
|
cancelLabel: L10n.of(context).cancel,
|
||||||
|
message: L10n.of(context).archiveRoomDescription,
|
||||||
|
isDestructiveAction: true,
|
||||||
|
)) ==
|
||||||
|
OkCancelResult.ok,
|
||||||
|
onDismissed: (_) => archiveAction(context, confirmed: true),
|
||||||
|
background: Material(
|
||||||
|
color: theme.colorScheme.errorContainer,
|
||||||
|
child: Icon(
|
||||||
|
Icons.archive_outlined,
|
||||||
|
color: theme.colorScheme.onErrorContainer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 8,
|
horizontal: 8,
|
||||||
vertical: 1,
|
vertical: 1,
|
||||||
|
|
@ -210,7 +233,8 @@ class ChatListItem extends StatelessWidget {
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (room.isFavourite || room.membership == Membership.invite)
|
if (room.isFavourite ||
|
||||||
|
room.membership == Membership.invite)
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
right: hasNotifications ? 4.0 : 0.0,
|
right: hasNotifications ? 4.0 : 0.0,
|
||||||
|
|
@ -252,7 +276,8 @@ class ChatListItem extends StatelessWidget {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
child:
|
||||||
|
CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
],
|
],
|
||||||
|
|
@ -274,7 +299,8 @@ class ChatListItem extends StatelessWidget {
|
||||||
? Text(
|
? Text(
|
||||||
L10n.of(context).countChatsAndCountParticipants(
|
L10n.of(context).countChatsAndCountParticipants(
|
||||||
room.spaceChildren.length.toString(),
|
room.spaceChildren.length.toString(),
|
||||||
(room.summary.mJoinedMemberCount ?? 1).toString(),
|
(room.summary.mJoinedMemberCount ?? 1)
|
||||||
|
.toString(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: typingText.isNotEmpty
|
: typingText.isNotEmpty
|
||||||
|
|
@ -297,7 +323,8 @@ class ChatListItem extends StatelessWidget {
|
||||||
hideEdit: true,
|
hideEdit: true,
|
||||||
plaintextBody: true,
|
plaintextBody: true,
|
||||||
removeMarkdown: true,
|
removeMarkdown: true,
|
||||||
withSenderNamePrefix: (!isDirectChat ||
|
withSenderNamePrefix:
|
||||||
|
(!isDirectChat ||
|
||||||
directChatMatrixId !=
|
directChatMatrixId !=
|
||||||
room.lastEvent?.senderId),
|
room.lastEvent?.senderId),
|
||||||
)
|
)
|
||||||
|
|
@ -328,7 +355,8 @@ class ChatListItem extends StatelessWidget {
|
||||||
? FontWeight.bold
|
? FontWeight.bold
|
||||||
: null,
|
: null,
|
||||||
color: theme.colorScheme.onSurfaceVariant,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
decoration: room.lastEvent?.redacted == true
|
decoration:
|
||||||
|
room.lastEvent?.redacted == true
|
||||||
? TextDecoration.lineThrough
|
? TextDecoration.lineThrough
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
|
@ -341,7 +369,8 @@ class ChatListItem extends StatelessWidget {
|
||||||
curve: FluffyThemes.animationCurve,
|
curve: FluffyThemes.animationCurve,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||||
height: unreadBubbleSize,
|
height: unreadBubbleSize,
|
||||||
width: !hasNotifications && !unread && !room.hasNewMessages
|
width:
|
||||||
|
!hasNotifications && !unread && !room.hasNewMessages
|
||||||
? 0
|
? 0
|
||||||
: (unreadBubbleSize - 9) *
|
: (unreadBubbleSize - 9) *
|
||||||
room.notificationCount.toString().length +
|
room.notificationCount.toString().length +
|
||||||
|
|
@ -365,7 +394,8 @@ class ChatListItem extends StatelessWidget {
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: hasNotifications
|
: hasNotifications
|
||||||
? theme.colorScheme.onPrimary
|
? theme.colorScheme.onPrimary
|
||||||
: theme.colorScheme.onPrimaryContainer,
|
: theme
|
||||||
|
.colorScheme.onPrimaryContainer,
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -385,6 +415,7 @@ class ChatListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue