mirror of
https://github.com/immich-app/immich.git
synced 2025-03-01 15:11:21 +01:00
fix(mobile): Fix back button closing the app from multiselection in Android (#1477)
* fixes back button multiselection on android in main timeline * back button on multiselect in album clears selection * fixed homepage back and refactor future * not a futureOr
This commit is contained in:
parent
f23979024a
commit
3210302ecd
2 changed files with 77 additions and 50 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -248,8 +250,20 @@ class AlbumViewerPage extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> onWillPop() async {
|
||||||
|
final isMultiselectEnable = ref.read(assetSelectionProvider).selectedAssetsInAlbumViewer.isNotEmpty;
|
||||||
|
if (isMultiselectEnable) {
|
||||||
|
ref.watch(assetSelectionProvider.notifier).removeAll();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Widget buildBody(AlbumResponseDto albumInfo) {
|
Widget buildBody(AlbumResponseDto albumInfo) {
|
||||||
return GestureDetector(
|
return WillPopScope(
|
||||||
|
onWillPop: onWillPop,
|
||||||
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
titleFocusNode.unfocus();
|
titleFocusNode.unfocus();
|
||||||
},
|
},
|
||||||
|
@ -276,6 +290,7 @@ class AlbumViewerPage extends HookConsumerWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,18 @@ class HomePage extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SafeArea(
|
Future<bool> onWillPop() async {
|
||||||
|
if (multiselectEnabled.state) {
|
||||||
|
selectionEnabledHook.value = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return WillPopScope(
|
||||||
|
onWillPop: onWillPop,
|
||||||
|
child: SafeArea(
|
||||||
bottom: !multiselectEnabled.state,
|
bottom: !multiselectEnabled.state,
|
||||||
top: true,
|
top: true,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
@ -229,6 +240,7 @@ class HomePage extends HookConsumerWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue