1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

fix(mobile): Delete goes to next page instead of popping back to the main timeline (#1781)

* delete goes to next page instead of popping

* moves pagecontroller to constructor so we dont rebuilt each time
This commit is contained in:
martyfuhry 2023-02-17 21:47:28 -05:00 committed by GitHub
parent 6e9749d6c4
commit 8c315dfeb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,13 +35,16 @@ class GalleryViewerPage extends HookConsumerWidget {
final Asset asset;
GalleryViewerPage({
Key? key,
super.key,
required this.assetList,
required this.asset,
}) : super(key: key);
}) : controller =
PageController(initialPage: assetList.indexOf(asset));
Asset? assetDetail;
late PageController controller;
@override
Widget build(BuildContext context, WidgetRef ref) {
final Box<dynamic> box = Hive.box(userInfoBox);
@ -56,9 +59,6 @@ class GalleryViewerPage extends HookConsumerWidget {
late Offset localPosition;
final authToken = 'Bearer ${box.get(accessTokenKey)}';
PageController controller =
PageController(initialPage: assetList.indexOf(asset));
useEffect(
() {
isLoadPreview.value =
@ -187,8 +187,17 @@ class GalleryViewerPage extends HookConsumerWidget {
builder: (BuildContext _) {
return DeleteDialog(
onDelete: () {
if (assetList.length == 1) {
// Handle only one asset
AutoRouter.of(context).pop();
} else {
// Go to next page otherwise
controller.nextPage(
duration: const Duration(milliseconds: 100),
curve: Curves.fastLinearToSlowEaseIn,
);
}
ref.watch(assetProvider.notifier).deleteAssets({deleteAsset});
AutoRouter.of(context).pop(null);
},
);
},