Forget rooms with slide

This commit is contained in:
Christian Pauly 2020-02-16 09:22:56 +01:00
parent be8f3a4a47
commit e13df1cbf0
2 changed files with 16 additions and 1 deletions

View File

@ -88,6 +88,14 @@ class ChatListItem extends StatelessWidget {
Future<bool> archiveAction(BuildContext context) async {
{
if ([Membership.leave, Membership.ban].contains(room.membership)) {
final success =
await Matrix.of(context).tryRequestWithLoadingDialog(room.forget());
if (success != false) {
if (this.onForget != null) this.onForget();
}
return success;
}
final bool confirmed = await SimpleDialogs(context).askConfirmation();
if (!confirmed) {
return false;
@ -113,6 +121,13 @@ class ChatListItem extends StatelessWidget {
icon: Icons.archive,
onTap: () => archiveAction(context),
),
if ([Membership.leave, Membership.ban].contains(room.membership))
IconSlideAction(
caption: I18n.of(context).delete,
color: Colors.red,
icon: Icons.delete_forever,
onTap: () => archiveAction(context),
),
],
actionPane: SlidableDrawerActionPane(),
dismissal: SlidableDismissal(

View File

@ -36,7 +36,7 @@ class _ArchiveState extends State<Archive> {
itemCount: archive.length,
itemBuilder: (BuildContext context, int i) => ChatListItem(
archive[i],
onForget: () => setState(() => archive = null)),
onForget: () => setState(() => archive.removeAt(i))),
);
}
},