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:hive/hive.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import 'package:immich_mobile/constants/hive_box.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';
|
|
|
|
import 'package:immich_mobile/modules/asset_viewer/ui/download_loading_indicator.dart';
|
2022-02-11 04:40:11 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/ui/exif_bottom_sheet.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/asset_viewer/ui/top_control_app_bar.dart';
|
|
|
|
import 'package:immich_mobile/modules/home/services/asset.service.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/immich_asset.model.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/immich_asset_with_exif.model.dart';
|
|
|
|
|
|
|
|
// ignore: must_be_immutable
|
|
|
|
class ImageViewerPage extends HookConsumerWidget {
|
|
|
|
final String imageUrl;
|
|
|
|
final String heroTag;
|
|
|
|
final String thumbnailUrl;
|
|
|
|
final ImmichAsset asset;
|
|
|
|
final AssetService _assetService = AssetService();
|
|
|
|
ImmichAssetWithExif? assetDetail;
|
|
|
|
|
|
|
|
ImageViewerPage(
|
|
|
|
{Key? key, required this.imageUrl, required this.heroTag, required this.thumbnailUrl, required this.asset})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-04-02 19:31:53 +02:00
|
|
|
final downloadAssetStatus = ref.watch(imageViewerStateProvider).downloadAssetStatus;
|
2022-02-11 04:40:11 +02:00
|
|
|
var box = Hive.box(userInfoBox);
|
|
|
|
|
|
|
|
getAssetExif() async {
|
|
|
|
assetDetail = await _assetService.getAssetById(asset.id);
|
|
|
|
}
|
|
|
|
|
2022-04-24 04:08:45 +02:00
|
|
|
showInfo() {
|
|
|
|
showModalBottomSheet(
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
barrierColor: Colors.transparent,
|
|
|
|
isScrollControlled: false,
|
|
|
|
context: context,
|
|
|
|
builder: (context) {
|
|
|
|
return ExifBottomSheet(assetDetail: assetDetail!);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-11 04:40:11 +02:00
|
|
|
useEffect(() {
|
|
|
|
getAssetExif();
|
2022-02-13 23:10:42 +02:00
|
|
|
return null;
|
2022-02-11 04:40:11 +02:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
appBar: TopControlAppBar(
|
|
|
|
asset: asset,
|
2022-04-24 04:08:45 +02:00
|
|
|
onMoreInfoPressed: showInfo,
|
2022-04-02 19:31:53 +02:00
|
|
|
onDownloadPressed: () {
|
|
|
|
ref.watch(imageViewerStateProvider.notifier).downloadAsset(asset, context);
|
2022-02-11 04:40:11 +02:00
|
|
|
},
|
|
|
|
),
|
2022-06-20 20:29:42 +02:00
|
|
|
body: SafeArea(
|
2022-04-24 04:08:45 +02:00
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Center(
|
|
|
|
child: Hero(
|
|
|
|
tag: heroTag,
|
2022-06-20 20:29:42 +02:00
|
|
|
child: RemotePhotoView(
|
|
|
|
thumbnailUrl: thumbnailUrl,
|
|
|
|
imageUrl: imageUrl,
|
|
|
|
authToken: "Bearer ${box.get(accessTokenKey)}",
|
|
|
|
onSwipeDown: () => AutoRouter.of(context).pop(),
|
|
|
|
onSwipeUp: () => showInfo(),
|
|
|
|
)
|
2022-02-14 22:42:06 +02:00
|
|
|
),
|
2022-02-13 23:10:42 +02:00
|
|
|
),
|
2022-04-24 04:08:45 +02:00
|
|
|
if (downloadAssetStatus == DownloadAssetStatus.loading)
|
|
|
|
const Center(
|
|
|
|
child: DownloadLoadingIndicator(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-02-11 04:40:11 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|