2022-04-24 04:08:45 +02:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2022-02-11 04:40:11 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2022-04-02 19:31:53 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/models/image_viewer_page_state.model.dart';
|
|
|
|
import 'package:immich_mobile/modules/asset_viewer/providers/image_viewer_page_state.provider.dart';
|
2022-06-20 20:29:42 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/ui/remote_photo_view.dart';
|
2022-02-11 04:40:11 +02:00
|
|
|
import 'package:immich_mobile/modules/home/services/asset.service.dart';
|
2022-11-08 19:00:24 +02:00
|
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
2022-11-11 19:52:02 +02:00
|
|
|
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
|
2022-02-11 04:40:11 +02:00
|
|
|
|
|
|
|
// ignore: must_be_immutable
|
|
|
|
class ImageViewerPage extends HookConsumerWidget {
|
|
|
|
final String heroTag;
|
2022-11-08 19:00:24 +02:00
|
|
|
final Asset asset;
|
2022-08-03 22:36:12 +02:00
|
|
|
final String authToken;
|
|
|
|
final ValueNotifier<bool> isZoomedListener;
|
|
|
|
final void Function() isZoomedFunction;
|
2023-01-11 22:54:12 +02:00
|
|
|
final void Function()? showExifSheet;
|
2022-12-02 22:55:10 +02:00
|
|
|
final bool loadPreview;
|
|
|
|
final bool loadOriginal;
|
2022-02-11 04:40:11 +02:00
|
|
|
|
2022-06-25 20:46:51 +02:00
|
|
|
ImageViewerPage({
|
|
|
|
Key? key,
|
|
|
|
required this.heroTag,
|
|
|
|
required this.asset,
|
2022-08-03 22:36:12 +02:00
|
|
|
required this.authToken,
|
|
|
|
required this.isZoomedFunction,
|
|
|
|
required this.isZoomedListener,
|
2022-12-02 22:55:10 +02:00
|
|
|
required this.loadPreview,
|
|
|
|
required this.loadOriginal,
|
2023-01-11 22:54:12 +02:00
|
|
|
this.showExifSheet,
|
2022-06-25 20:46:51 +02:00
|
|
|
}) : super(key: key);
|
2022-02-11 04:40:11 +02:00
|
|
|
|
2022-11-08 19:00:24 +02:00
|
|
|
Asset? assetDetail;
|
2022-08-13 22:51:09 +02:00
|
|
|
|
2022-02-11 04:40:11 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-06-25 20:46:51 +02:00
|
|
|
final downloadAssetStatus =
|
|
|
|
ref.watch(imageViewerStateProvider).downloadAssetStatus;
|
2022-02-11 04:40:11 +02:00
|
|
|
|
|
|
|
getAssetExif() async {
|
2022-11-08 19:00:24 +02:00
|
|
|
if (asset.isRemote) {
|
|
|
|
assetDetail =
|
|
|
|
await ref.watch(assetServiceProvider).getAssetById(asset.id);
|
|
|
|
} else {
|
|
|
|
// TODO local exif parsing?
|
|
|
|
assetDetail = asset;
|
|
|
|
}
|
2022-02-11 04:40:11 +02:00
|
|
|
}
|
|
|
|
|
2022-08-03 22:36:12 +02:00
|
|
|
useEffect(
|
|
|
|
() {
|
|
|
|
getAssetExif();
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
);
|
|
|
|
|
|
|
|
return Stack(
|
|
|
|
children: [
|
|
|
|
Center(
|
|
|
|
child: Hero(
|
|
|
|
tag: heroTag,
|
|
|
|
child: RemotePhotoView(
|
2022-11-08 19:00:24 +02:00
|
|
|
asset: asset,
|
2022-08-13 22:51:09 +02:00
|
|
|
authToken: authToken,
|
2022-12-02 22:55:10 +02:00
|
|
|
loadPreview: loadPreview,
|
|
|
|
loadOriginal: loadOriginal,
|
2022-08-13 22:51:09 +02:00
|
|
|
isZoomedFunction: isZoomedFunction,
|
|
|
|
isZoomedListener: isZoomedListener,
|
|
|
|
onSwipeDown: () => AutoRouter.of(context).pop(),
|
2023-01-11 22:54:12 +02:00
|
|
|
onSwipeUp: (asset.isRemote && showExifSheet != null) ? showExifSheet! : () {},
|
2022-08-13 22:51:09 +02:00
|
|
|
),
|
2022-08-03 22:36:12 +02:00
|
|
|
),
|
2022-02-11 04:40:11 +02:00
|
|
|
),
|
2022-08-03 22:36:12 +02:00
|
|
|
if (downloadAssetStatus == DownloadAssetStatus.loading)
|
|
|
|
const Center(
|
2022-11-11 19:52:02 +02:00
|
|
|
child: ImmichLoadingIndicator(),
|
2022-08-03 22:36:12 +02:00
|
|
|
),
|
|
|
|
],
|
2022-02-11 04:40:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|