Skip to content

Commit

Permalink
fix(mobile): Delete goes to next page instead of popping back to the …
Browse files Browse the repository at this point in the history
…main timeline (immich-app#1781)

* delete goes to next page instead of popping

* moves pagecontroller to constructor so we dont rebuilt each time
  • Loading branch information
martyfuhry authored Feb 18, 2023
1 parent 6e9749d commit 8c315df
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions mobile/lib/modules/asset_viewer/views/gallery_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 =
Expand Down Expand Up @@ -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);
},
);
},
Expand Down

0 comments on commit 8c315df

Please sign in to comment.