From 24b632fc90a787c568207410588f65135e302b6d Mon Sep 17 00:00:00 2001 From: Steef Hegeman Date: Wed, 26 May 2021 20:28:08 +0200 Subject: [PATCH] back button clears selection: room list and chat When a room or event is selected and the Android back button is pressed, don't pop but clear the current selection. Fixes #399. --- lib/pages/views/chat_list_view.dart | 12 ++++++++++-- lib/pages/views/chat_view.dart | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/pages/views/chat_list_view.dart b/lib/pages/views/chat_list_view.dart index 9880f3e4..83961429 100644 --- a/lib/pages/views/chat_list_view.dart +++ b/lib/pages/views/chat_list_view.dart @@ -26,7 +26,15 @@ class ChatListView extends StatelessWidget { : controller.selectedRoomIds.isEmpty ? SelectMode.normal : SelectMode.select; - return Scaffold( + return VWidgetGuard( + onSystemPop: (redirector) async { + if (controller.selectedRoomIds.isNotEmpty) { + controller.cancelAction(); + redirector.stopRedirection(); + } + }, + child: + Scaffold( appBar: AppBar( elevation: MediaQuery.of(context).size.width > FluffyThemes.columnWidth * 2 @@ -231,7 +239,7 @@ class ChatListView extends StatelessWidget { child: Icon(CupertinoIcons.chat_bubble), ) : null, - ); + )); }); } } diff --git a/lib/pages/views/chat_view.dart b/lib/pages/views/chat_view.dart index ff0935ac..b4e65b43 100644 --- a/lib/pages/views/chat_view.dart +++ b/lib/pages/views/chat_view.dart @@ -54,7 +54,15 @@ class ChatView extends StatelessWidget { context: context, future: () => controller.room.join()); } - return Scaffold( + return VWidgetGuard( + onSystemPop: (redirector) async { + if (controller.selectedEvents.isNotEmpty) { + controller.clearSelectedEvents(); + redirector.stopRedirection(); + } + }, + child: + Scaffold( appBar: AppBar( leading: controller.selectMode ? IconButton( @@ -694,7 +702,7 @@ class ChatView extends StatelessWidget { ), ], ), - ); + )); } }