Merge branch 'android-back-button-cancels-share' into 'main'

android: back button cancels share (still pops)

See merge request famedly/fluffychat!421
This commit is contained in:
Krille Fear 2021-06-02 05:57:13 +00:00
commit 9e218174db
2 changed files with 10 additions and 14 deletions

View File

@ -42,6 +42,12 @@ class ChatListController extends State<ChatList> {
String get activeChat => VRouter.of(context).pathParameters['roomid']; String get activeChat => VRouter.of(context).pathParameters['roomid'];
SelectMode get selectMode => Matrix.of(context).shareContent != null
? SelectMode.share
: selectedRoomIds.isEmpty
? SelectMode.normal
: SelectMode.select;
void _processIncomingSharedFiles(List<SharedMediaFile> files) { void _processIncomingSharedFiles(List<SharedMediaFile> files) {
if (files?.isEmpty ?? true) return; if (files?.isEmpty ?? true) return;
VRouter.of(context).push('/rooms'); VRouter.of(context).push('/rooms');
@ -234,11 +240,6 @@ class ChatListController extends State<ChatList> {
} }
void cancelAction() { void cancelAction() {
final selectMode = Matrix.of(context).shareContent != null
? SelectMode.share
: selectedRoomIds.isEmpty
? SelectMode.normal
: SelectMode.select;
if (selectMode == SelectMode.share) { if (selectMode == SelectMode.share) {
setState(() => Matrix.of(context).shareContent = null); setState(() => Matrix.of(context).shareContent = null);
} else { } else {

View File

@ -20,17 +20,12 @@ class ChatListView extends StatelessWidget {
return StreamBuilder<Object>( return StreamBuilder<Object>(
stream: Matrix.of(context).onShareContentChanged.stream, stream: Matrix.of(context).onShareContentChanged.stream,
builder: (_, __) { builder: (_, __) {
final selectMode = Matrix.of(context).shareContent != null final selectMode = controller.selectMode;
? SelectMode.share
: controller.selectedRoomIds.isEmpty
? SelectMode.normal
: SelectMode.select;
return VWidgetGuard( return VWidgetGuard(
onSystemPop: (redirector) async { onSystemPop: (redirector) async {
if (controller.selectedRoomIds.isNotEmpty) { final selMode = controller.selectMode;
controller.cancelAction(); if (selMode != SelectMode.normal) controller.cancelAction();
redirector.stopRedirection(); if (selMode == SelectMode.select) redirector.stopRedirection();
}
}, },
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(