chore: Follow up dismiss room
This commit is contained in:
parent
3f9c7f3e91
commit
282f45059c
1 changed files with 19 additions and 28 deletions
|
|
@ -35,31 +35,30 @@ class ChatListItem extends StatelessWidget {
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<bool> archiveAction(BuildContext context, {bool? confirmed}) async {
|
Future<bool> archiveAction(BuildContext context) async {
|
||||||
{
|
{
|
||||||
if ([Membership.leave, Membership.ban].contains(room.membership)) {
|
if ([Membership.leave, Membership.ban].contains(room.membership)) {
|
||||||
await showFutureLoadingDialog(
|
final forgetResult = await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () => room.forget(),
|
future: () => room.forget(),
|
||||||
);
|
);
|
||||||
return true;
|
return forgetResult.isValue;
|
||||||
}
|
}
|
||||||
confirmed ??= (await showOkCancelAlertDialog(
|
final 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).leave,
|
okLabel: L10n.of(context).leave,
|
||||||
cancelLabel: L10n.of(context).cancel,
|
cancelLabel: L10n.of(context).cancel,
|
||||||
message: L10n.of(context).archiveRoomDescription,
|
message: L10n.of(context).archiveRoomDescription,
|
||||||
isDestructiveAction: true,
|
isDestructiveAction: true,
|
||||||
)) ==
|
);
|
||||||
OkCancelResult.ok;
|
if (confirmed != OkCancelResult.ok) return false;
|
||||||
if (!confirmed) return false;
|
final leaveResult = await showFutureLoadingDialog(
|
||||||
await showFutureLoadingDialog(
|
|
||||||
context: context,
|
context: context,
|
||||||
future: () => room.leave(),
|
future: () => room.leave(),
|
||||||
);
|
);
|
||||||
return true;
|
return leaveResult.isValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,18 +96,10 @@ class ChatListItem extends StatelessWidget {
|
||||||
|
|
||||||
return Dismissible(
|
return Dismissible(
|
||||||
key: ValueKey(room.id),
|
key: ValueKey(room.id),
|
||||||
confirmDismiss: (_) async =>
|
confirmDismiss: (_) => archiveAction(context),
|
||||||
(await showOkCancelAlertDialog(
|
onDismissed: (_) {
|
||||||
useRootNavigator: false,
|
// Empty dismissed callback to trigger the dismiss animation
|
||||||
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(
|
background: Material(
|
||||||
color: theme.colorScheme.errorContainer,
|
color: theme.colorScheme.errorContainer,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue