mirror of
https://github.com/immich-app/immich.git
synced 2024-11-28 09:33:27 +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:
parent
6e9749d6c4
commit
8c315dfeb1
@ -35,13 +35,16 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
final Asset asset;
|
final Asset asset;
|
||||||
|
|
||||||
GalleryViewerPage({
|
GalleryViewerPage({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.assetList,
|
required this.assetList,
|
||||||
required this.asset,
|
required this.asset,
|
||||||
}) : super(key: key);
|
}) : controller =
|
||||||
|
PageController(initialPage: assetList.indexOf(asset));
|
||||||
|
|
||||||
Asset? assetDetail;
|
Asset? assetDetail;
|
||||||
|
|
||||||
|
late PageController controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final Box<dynamic> box = Hive.box(userInfoBox);
|
final Box<dynamic> box = Hive.box(userInfoBox);
|
||||||
@ -56,9 +59,6 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
late Offset localPosition;
|
late Offset localPosition;
|
||||||
final authToken = 'Bearer ${box.get(accessTokenKey)}';
|
final authToken = 'Bearer ${box.get(accessTokenKey)}';
|
||||||
|
|
||||||
PageController controller =
|
|
||||||
PageController(initialPage: assetList.indexOf(asset));
|
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() {
|
() {
|
||||||
isLoadPreview.value =
|
isLoadPreview.value =
|
||||||
@ -187,8 +187,17 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
builder: (BuildContext _) {
|
builder: (BuildContext _) {
|
||||||
return DeleteDialog(
|
return DeleteDialog(
|
||||||
onDelete: () {
|
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});
|
ref.watch(assetProvider.notifier).deleteAssets({deleteAsset});
|
||||||
AutoRouter.of(context).pop(null);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user