2024-02-29 00:13:15 +02:00
|
|
|
import 'dart:async';
|
2023-02-01 18:59:34 +02:00
|
|
|
import 'dart:io';
|
2023-06-26 18:54:08 +02:00
|
|
|
import 'dart:math';
|
2024-02-27 17:51:19 +02:00
|
|
|
import 'dart:ui' as ui;
|
2022-08-03 22:36:12 +02:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2022-10-14 18:26:10 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2023-03-23 03:36:44 +02:00
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart' hide Store;
|
2022-08-03 22:36:12 +02:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-11-09 18:19:53 +02:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2024-02-27 17:51:19 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/image_providers/immich_remote_image_provider.dart';
|
2023-10-22 04:38:07 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/providers/asset_stack.provider.dart';
|
2024-01-05 07:20:55 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/providers/current_asset.provider.dart';
|
2023-06-26 17:27:47 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/providers/show_controls.provider.dart';
|
|
|
|
import 'package:immich_mobile/modules/asset_viewer/providers/video_player_value_provider.dart';
|
2023-04-11 19:21:00 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/ui/advanced_bottom_sheet.dart';
|
2024-03-06 05:42:22 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/ui/bottom_gallery_bar.dart';
|
2024-03-07 05:27:33 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/ui/exif_sheet/exif_bottom_sheet.dart';
|
2024-03-06 05:42:22 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/ui/gallery_app_bar.dart';
|
2022-08-03 22:36:12 +02:00
|
|
|
import 'package:immich_mobile/modules/asset_viewer/views/video_viewer_page.dart';
|
2022-08-16 01:53:30 +02:00
|
|
|
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
|
|
|
|
import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
|
2024-04-15 07:50:47 +02:00
|
|
|
import 'package:immich_mobile/shared/providers/haptic_feedback.provider.dart';
|
2023-03-15 23:29:07 +02:00
|
|
|
import 'package:immich_mobile/shared/ui/immich_image.dart';
|
2024-02-27 17:51:19 +02:00
|
|
|
import 'package:immich_mobile/shared/ui/immich_thumbnail.dart';
|
2023-02-01 18:59:34 +02:00
|
|
|
import 'package:immich_mobile/shared/ui/photo_view/photo_view_gallery.dart';
|
|
|
|
import 'package:immich_mobile/shared/ui/photo_view/src/photo_view_computed_scale.dart';
|
|
|
|
import 'package:immich_mobile/shared/ui/photo_view/src/photo_view_scale_state.dart';
|
|
|
|
import 'package:immich_mobile/shared/ui/photo_view/src/utils/photo_view_hero_attributes.dart';
|
2022-11-08 19:00:24 +02:00
|
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
2023-10-23 20:28:12 +02:00
|
|
|
import 'package:isar/isar.dart';
|
2023-09-18 05:57:05 +02:00
|
|
|
import 'package:openapi/api.dart' show ThumbnailFormat;
|
2022-08-03 22:36:12 +02:00
|
|
|
|
2024-01-15 18:50:33 +02:00
|
|
|
@RoutePage()
|
2022-08-03 22:36:12 +02:00
|
|
|
// ignore: must_be_immutable
|
|
|
|
class GalleryViewerPage extends HookConsumerWidget {
|
2023-05-17 19:36:02 +02:00
|
|
|
final Asset Function(int index) loadAsset;
|
|
|
|
final int totalAssets;
|
|
|
|
final int initialIndex;
|
2023-07-13 17:42:06 +02:00
|
|
|
final int heroOffset;
|
2023-10-22 04:38:07 +02:00
|
|
|
final bool showStack;
|
2022-08-08 02:43:09 +02:00
|
|
|
|
2022-08-03 22:36:12 +02:00
|
|
|
GalleryViewerPage({
|
2023-02-18 04:47:28 +02:00
|
|
|
super.key,
|
2023-05-17 19:36:02 +02:00
|
|
|
required this.initialIndex,
|
|
|
|
required this.loadAsset,
|
|
|
|
required this.totalAssets,
|
2023-07-13 17:42:06 +02:00
|
|
|
this.heroOffset = 0,
|
2023-10-22 04:38:07 +02:00
|
|
|
this.showStack = false,
|
2023-05-17 19:36:02 +02:00
|
|
|
}) : controller = PageController(initialPage: initialIndex);
|
2022-08-13 22:51:09 +02:00
|
|
|
|
2023-02-23 04:50:13 +02:00
|
|
|
final PageController controller;
|
2023-02-18 04:47:28 +02:00
|
|
|
|
2023-09-18 05:57:05 +02:00
|
|
|
static const jpeg = ThumbnailFormat.JPEG;
|
|
|
|
static const webp = ThumbnailFormat.WEBP;
|
|
|
|
|
2022-08-03 22:36:12 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-12-02 22:55:10 +02:00
|
|
|
final settings = ref.watch(appSettingsServiceProvider);
|
|
|
|
final isLoadPreview = useState(AppSettingsEnum.loadPreview.defaultValue);
|
|
|
|
final isLoadOriginal = useState(AppSettingsEnum.loadOriginal.defaultValue);
|
2024-03-06 05:42:22 +02:00
|
|
|
final isZoomed = useState(false);
|
2023-02-05 14:57:07 +02:00
|
|
|
final isPlayingVideo = useState(false);
|
2024-03-06 05:42:22 +02:00
|
|
|
final localPosition = useState<Offset?>(null);
|
2023-05-17 19:36:02 +02:00
|
|
|
final currentIndex = useState(initialIndex);
|
|
|
|
final currentAsset = loadAsset(currentIndex.value);
|
2024-03-06 05:42:22 +02:00
|
|
|
// Update is playing motion video
|
|
|
|
ref.listen(videoPlaybackValueProvider.select((v) => v.state), (_, state) {
|
|
|
|
isPlayingVideo.value = state == VideoPlaybackState.playing;
|
|
|
|
});
|
|
|
|
|
2023-10-22 04:38:07 +02:00
|
|
|
final stackIndex = useState(-1);
|
2023-10-26 16:19:06 +02:00
|
|
|
final stack = showStack && currentAsset.stackChildrenCount > 0
|
2023-10-22 04:38:07 +02:00
|
|
|
? ref.watch(assetStackStateProvider(currentAsset))
|
|
|
|
: <Asset>[];
|
|
|
|
final stackElements = showStack ? [currentAsset, ...stack] : <Asset>[];
|
2023-10-23 20:28:12 +02:00
|
|
|
// Assets from response DTOs do not have an isar id, querying which would give us the default autoIncrement id
|
2023-10-29 22:28:54 +02:00
|
|
|
final isFromDto = currentAsset.id == Isar.autoIncrement;
|
2023-05-17 19:36:02 +02:00
|
|
|
|
2024-03-06 05:42:22 +02:00
|
|
|
Asset asset = stackIndex.value == -1
|
2023-10-22 04:38:07 +02:00
|
|
|
? currentAsset
|
|
|
|
: stackElements.elementAt(stackIndex.value);
|
2022-08-13 22:51:09 +02:00
|
|
|
|
2024-03-06 05:42:22 +02:00
|
|
|
final isMotionPhoto = asset.livePhotoVideoId != null;
|
2024-01-05 07:20:55 +02:00
|
|
|
// Listen provider to prevent autoDispose when navigating to other routes from within the gallery page
|
|
|
|
ref.listen(currentAssetProvider, (_, __) {});
|
|
|
|
useEffect(
|
|
|
|
() {
|
|
|
|
// Delay state update to after the execution of build method
|
|
|
|
Future.microtask(
|
2024-03-06 05:42:22 +02:00
|
|
|
() => ref.read(currentAssetProvider.notifier).set(asset),
|
2024-01-05 07:20:55 +02:00
|
|
|
);
|
|
|
|
return null;
|
|
|
|
},
|
2024-03-06 05:42:22 +02:00
|
|
|
[asset],
|
2024-01-05 07:20:55 +02:00
|
|
|
);
|
|
|
|
|
2022-08-13 22:51:09 +02:00
|
|
|
useEffect(
|
|
|
|
() {
|
2022-12-02 22:55:10 +02:00
|
|
|
isLoadPreview.value =
|
|
|
|
settings.getSetting<bool>(AppSettingsEnum.loadPreview);
|
|
|
|
isLoadOriginal.value =
|
|
|
|
settings.getSetting<bool>(AppSettingsEnum.loadOriginal);
|
2022-08-13 22:51:09 +02:00
|
|
|
return null;
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
);
|
2022-08-03 22:36:12 +02:00
|
|
|
|
2024-02-29 00:13:15 +02:00
|
|
|
Future<void> precacheNextImage(int index) async {
|
2023-09-18 05:57:05 +02:00
|
|
|
void onError(Object exception, StackTrace? stackTrace) {
|
|
|
|
// swallow error silently
|
2024-02-13 23:30:32 +02:00
|
|
|
debugPrint('Error precaching next image: $exception, $stackTrace');
|
2023-09-18 05:57:05 +02:00
|
|
|
}
|
2024-02-18 06:03:01 +02:00
|
|
|
|
2023-05-17 19:36:02 +02:00
|
|
|
if (index < totalAssets && index >= 0) {
|
|
|
|
final asset = loadAsset(index);
|
2024-02-29 00:13:15 +02:00
|
|
|
await precacheImage(
|
2024-02-13 23:30:32 +02:00
|
|
|
ImmichImage.imageProvider(asset: asset),
|
|
|
|
context,
|
|
|
|
onError: onError,
|
|
|
|
);
|
2023-02-01 18:59:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void showInfo() {
|
2023-02-04 22:42:42 +02:00
|
|
|
showModalBottomSheet(
|
2024-01-06 05:02:16 +02:00
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(15.0)),
|
2023-02-04 22:42:42 +02:00
|
|
|
),
|
|
|
|
barrierColor: Colors.transparent,
|
|
|
|
isScrollControlled: true,
|
2024-02-18 06:03:01 +02:00
|
|
|
showDragHandle: true,
|
|
|
|
enableDrag: true,
|
2023-02-04 22:42:42 +02:00
|
|
|
context: context,
|
2024-02-18 06:03:01 +02:00
|
|
|
useSafeArea: true,
|
2023-02-04 22:42:42 +02:00
|
|
|
builder: (context) {
|
2024-03-07 05:27:33 +02:00
|
|
|
return FractionallySizedBox(
|
|
|
|
heightFactor: 0.75,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
bottom: MediaQuery.viewInsetsOf(context).bottom,
|
|
|
|
),
|
|
|
|
child: ref
|
|
|
|
.watch(appSettingsServiceProvider)
|
|
|
|
.getSetting<bool>(AppSettingsEnum.advancedTroubleshooting)
|
|
|
|
? AdvancedBottomSheet(assetDetail: asset)
|
|
|
|
: ExifBottomSheet(asset: asset),
|
2023-04-13 17:22:06 +02:00
|
|
|
),
|
2023-01-27 07:16:28 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-01 18:59:34 +02:00
|
|
|
void handleSwipeUpDown(DragUpdateDetails details) {
|
2024-03-06 18:15:54 +02:00
|
|
|
const int sensitivity = 15;
|
|
|
|
const int dxThreshold = 50;
|
|
|
|
const double ratioThreshold = 3.0;
|
2023-02-01 18:59:34 +02:00
|
|
|
|
|
|
|
if (isZoomed.value) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-21 02:58:17 +02:00
|
|
|
// Guard [localPosition] null
|
2024-03-06 05:42:22 +02:00
|
|
|
if (localPosition.value == null) {
|
2023-06-21 02:58:17 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-01 18:59:34 +02:00
|
|
|
// Check for delta from initial down point
|
2024-03-06 05:42:22 +02:00
|
|
|
final d = details.localPosition - localPosition.value!;
|
2023-02-01 18:59:34 +02:00
|
|
|
// If the magnitude of the dx swipe is large, we probably didn't mean to go down
|
2023-02-11 22:23:32 +02:00
|
|
|
if (d.dx.abs() > dxThreshold) {
|
2023-02-01 18:59:34 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-31 20:18:40 +02:00
|
|
|
final ratio = d.dy / max(d.dx.abs(), 1);
|
|
|
|
if (d.dy > sensitivity && ratio > ratioThreshold) {
|
2024-01-05 07:20:55 +02:00
|
|
|
context.popRoute();
|
2023-07-31 20:18:40 +02:00
|
|
|
} else if (d.dy < -sensitivity && ratio < -ratioThreshold) {
|
2023-02-01 18:59:34 +02:00
|
|
|
showInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-06 05:42:22 +02:00
|
|
|
useEffect(
|
|
|
|
() {
|
|
|
|
if (ref.read(showControlsProvider)) {
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
|
|
|
} else {
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
|
|
|
}
|
|
|
|
isPlayingVideo.value = false;
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
);
|
2023-08-06 04:40:50 +02:00
|
|
|
|
2024-03-06 05:42:22 +02:00
|
|
|
useEffect(
|
|
|
|
() {
|
|
|
|
// No need to await this
|
|
|
|
unawaited(
|
|
|
|
// Delay this a bit so we can finish loading the page
|
|
|
|
Future.delayed(const Duration(milliseconds: 400)).then(
|
|
|
|
// Precache the next image
|
|
|
|
(_) => precacheNextImage(currentIndex.value + 1),
|
|
|
|
),
|
2024-01-06 05:02:16 +02:00
|
|
|
);
|
2024-03-06 05:42:22 +02:00
|
|
|
return null;
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
);
|
2024-01-06 05:02:16 +02:00
|
|
|
|
2024-03-06 05:42:22 +02:00
|
|
|
ref.listen(showControlsProvider, (_, show) {
|
|
|
|
if (show) {
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
|
|
|
} else {
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
2023-11-06 17:46:26 +02:00
|
|
|
}
|
2024-03-06 05:42:22 +02:00
|
|
|
});
|
2023-06-26 17:27:47 +02:00
|
|
|
|
2023-10-22 04:38:07 +02:00
|
|
|
Widget buildStackedChildren() {
|
|
|
|
return ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
itemCount: stackElements.length,
|
2024-03-06 05:42:22 +02:00
|
|
|
padding: const EdgeInsets.only(
|
2024-03-06 07:44:56 +02:00
|
|
|
left: 5,
|
|
|
|
right: 5,
|
2024-03-06 05:42:22 +02:00
|
|
|
bottom: 30,
|
|
|
|
),
|
2023-10-22 04:38:07 +02:00
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final assetId = stackElements.elementAt(index).remoteId;
|
|
|
|
return Padding(
|
2024-03-06 07:44:56 +02:00
|
|
|
padding: const EdgeInsets.only(right: 5),
|
2023-10-22 04:38:07 +02:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () => stackIndex.value = index,
|
|
|
|
child: Container(
|
2024-03-06 07:44:56 +02:00
|
|
|
width: 60,
|
|
|
|
height: 60,
|
2023-10-22 04:38:07 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.circular(6),
|
2023-11-04 03:43:43 +02:00
|
|
|
border: (stackIndex.value == -1 && index == 0) ||
|
|
|
|
index == stackIndex.value
|
2023-10-22 04:38:07 +02:00
|
|
|
? Border.all(
|
|
|
|
color: Colors.white,
|
|
|
|
width: 2,
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(4),
|
2024-02-27 17:51:19 +02:00
|
|
|
child: Image(
|
2023-10-22 04:38:07 +02:00
|
|
|
fit: BoxFit.cover,
|
2024-02-27 17:51:19 +02:00
|
|
|
image: ImmichRemoteImageProvider(assetId: assetId!),
|
2023-10-22 04:38:07 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-01-27 18:14:32 +02:00
|
|
|
return PopScope(
|
|
|
|
canPop: false,
|
|
|
|
onPopInvoked: (_) {
|
|
|
|
// Change immersive mode back to normal "edgeToEdge" mode
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
|
|
|
context.pop();
|
|
|
|
},
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
body: Stack(
|
2023-03-06 06:51:18 +02:00
|
|
|
children: [
|
|
|
|
PhotoViewGallery.builder(
|
|
|
|
scaleStateChangedCallback: (state) {
|
|
|
|
isZoomed.value = state != PhotoViewScaleState.initial;
|
2023-07-22 21:56:49 +02:00
|
|
|
ref.read(showControlsProvider.notifier).show = !isZoomed.value;
|
2023-03-06 06:51:18 +02:00
|
|
|
},
|
2024-02-28 23:48:59 +02:00
|
|
|
loadingBuilder: (context, event, index) => ClipRect(
|
|
|
|
child: Stack(
|
|
|
|
fit: StackFit.expand,
|
|
|
|
children: [
|
|
|
|
BackdropFilter(
|
|
|
|
filter: ui.ImageFilter.blur(
|
|
|
|
sigmaX: 10,
|
|
|
|
sigmaY: 10,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ImmichThumbnail(
|
2024-03-06 05:42:22 +02:00
|
|
|
asset: asset,
|
2024-02-28 23:48:59 +02:00
|
|
|
fit: BoxFit.contain,
|
|
|
|
),
|
|
|
|
],
|
2024-02-27 17:51:19 +02:00
|
|
|
),
|
2024-02-13 23:30:32 +02:00
|
|
|
),
|
2023-03-06 06:51:18 +02:00
|
|
|
pageController: controller,
|
|
|
|
scrollPhysics: isZoomed.value
|
|
|
|
? const NeverScrollableScrollPhysics() // Don't allow paging while scrolled in
|
|
|
|
: (Platform.isIOS
|
2023-04-18 18:23:56 +02:00
|
|
|
? const ScrollPhysics() // Use bouncing physics for iOS
|
2023-03-06 06:51:18 +02:00
|
|
|
: const ClampingScrollPhysics() // Use heavy physics for Android
|
|
|
|
),
|
2023-05-17 19:36:02 +02:00
|
|
|
itemCount: totalAssets,
|
2023-03-06 06:51:18 +02:00
|
|
|
scrollDirection: Axis.horizontal,
|
2024-02-29 00:13:15 +02:00
|
|
|
onPageChanged: (value) async {
|
2023-09-18 05:57:05 +02:00
|
|
|
final next = currentIndex.value < value ? value + 1 : value - 1;
|
2024-04-15 07:50:47 +02:00
|
|
|
|
|
|
|
ref.read(hapticFeedbackProvider.notifier).selectionClick();
|
|
|
|
|
2023-05-17 19:36:02 +02:00
|
|
|
currentIndex.value = value;
|
2023-10-22 04:38:07 +02:00
|
|
|
stackIndex.value = -1;
|
2024-03-06 05:42:22 +02:00
|
|
|
isPlayingVideo.value = false;
|
2024-02-29 00:13:15 +02:00
|
|
|
|
|
|
|
// Wait for page change animation to finish
|
|
|
|
await Future.delayed(const Duration(milliseconds: 400));
|
|
|
|
// Then precache the next image
|
|
|
|
unawaited(precacheNextImage(next));
|
2023-03-06 06:51:18 +02:00
|
|
|
},
|
|
|
|
builder: (context, index) {
|
2023-10-22 04:38:07 +02:00
|
|
|
final a =
|
2024-03-06 05:42:22 +02:00
|
|
|
index == currentIndex.value ? asset : loadAsset(index);
|
2024-02-13 23:30:32 +02:00
|
|
|
final ImageProvider provider =
|
|
|
|
ImmichImage.imageProvider(asset: a);
|
2023-06-20 23:17:43 +02:00
|
|
|
|
2024-03-06 05:42:22 +02:00
|
|
|
if (a.isImage && !isPlayingVideo.value) {
|
2023-03-06 06:51:18 +02:00
|
|
|
return PhotoViewGalleryPageOptions(
|
|
|
|
onDragStart: (_, details, __) =>
|
2024-03-06 05:42:22 +02:00
|
|
|
localPosition.value = details.localPosition,
|
2023-03-15 23:29:07 +02:00
|
|
|
onDragUpdate: (_, details, __) =>
|
|
|
|
handleSwipeUpDown(details),
|
2023-06-26 17:27:47 +02:00
|
|
|
onTapDown: (_, __, ___) {
|
|
|
|
ref.read(showControlsProvider.notifier).toggle();
|
|
|
|
},
|
2023-03-06 06:51:18 +02:00
|
|
|
imageProvider: provider,
|
|
|
|
heroAttributes: PhotoViewHeroAttributes(
|
2023-10-29 22:28:54 +02:00
|
|
|
tag: isFromDto
|
2023-12-20 19:23:17 +02:00
|
|
|
? '${currentAsset.remoteId}-$heroOffset'
|
|
|
|
: currentAsset.id + heroOffset,
|
2023-12-05 17:45:04 +02:00
|
|
|
transitionOnUserGestures: true,
|
2023-03-06 06:51:18 +02:00
|
|
|
),
|
|
|
|
filterQuality: FilterQuality.high,
|
|
|
|
tightMode: true,
|
|
|
|
minScale: PhotoViewComputedScale.contained,
|
2023-03-15 23:29:07 +02:00
|
|
|
errorBuilder: (context, error, stackTrace) => ImmichImage(
|
2023-10-22 04:38:07 +02:00
|
|
|
a,
|
2023-03-15 23:29:07 +02:00
|
|
|
fit: BoxFit.contain,
|
|
|
|
),
|
2023-03-06 06:51:18 +02:00
|
|
|
);
|
2023-02-01 18:59:34 +02:00
|
|
|
} else {
|
2023-03-06 06:51:18 +02:00
|
|
|
return PhotoViewGalleryPageOptions.customChild(
|
|
|
|
onDragStart: (_, details, __) =>
|
2024-03-06 05:42:22 +02:00
|
|
|
localPosition.value = details.localPosition,
|
2023-03-15 23:29:07 +02:00
|
|
|
onDragUpdate: (_, details, __) =>
|
|
|
|
handleSwipeUpDown(details),
|
2023-03-06 06:51:18 +02:00
|
|
|
heroAttributes: PhotoViewHeroAttributes(
|
2023-10-29 22:28:54 +02:00
|
|
|
tag: isFromDto
|
2023-12-20 19:23:17 +02:00
|
|
|
? '${currentAsset.remoteId}-$heroOffset'
|
|
|
|
: currentAsset.id + heroOffset,
|
2023-02-04 22:42:42 +02:00
|
|
|
),
|
2023-03-06 06:51:18 +02:00
|
|
|
filterQuality: FilterQuality.high,
|
|
|
|
maxScale: 1.0,
|
|
|
|
minScale: 1.0,
|
2023-06-26 17:27:47 +02:00
|
|
|
basePosition: Alignment.center,
|
2023-06-20 23:17:43 +02:00
|
|
|
child: VideoViewerPage(
|
2024-03-06 05:42:22 +02:00
|
|
|
key: ValueKey(a),
|
2023-10-22 04:38:07 +02:00
|
|
|
asset: a,
|
2024-03-06 05:42:22 +02:00
|
|
|
isMotionVideo: a.livePhotoVideoId != null,
|
2023-06-20 23:17:43 +02:00
|
|
|
placeholder: Image(
|
|
|
|
image: provider,
|
2024-02-28 23:48:59 +02:00
|
|
|
fit: BoxFit.contain,
|
2023-11-09 18:19:53 +02:00
|
|
|
height: context.height,
|
|
|
|
width: context.width,
|
2023-06-20 23:17:43 +02:00
|
|
|
alignment: Alignment.center,
|
2023-03-06 06:51:18 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
2024-03-06 05:42:22 +02:00
|
|
|
child: GalleryAppBar(
|
|
|
|
asset: asset,
|
|
|
|
showInfo: showInfo,
|
|
|
|
isPlayingVideo: isPlayingVideo.value,
|
|
|
|
onToggleMotionVideo: () =>
|
|
|
|
isPlayingVideo.value = !isPlayingVideo.value,
|
|
|
|
),
|
2023-03-06 06:51:18 +02:00
|
|
|
),
|
2023-04-17 07:02:07 +02:00
|
|
|
Positioned(
|
|
|
|
bottom: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
2024-03-06 05:42:22 +02:00
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Visibility(
|
|
|
|
visible: stack.isNotEmpty,
|
|
|
|
child: SizedBox(
|
2024-03-06 07:44:56 +02:00
|
|
|
height: 80,
|
2024-03-06 05:42:22 +02:00
|
|
|
child: buildStackedChildren(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
BottomGalleryBar(
|
|
|
|
totalAssets: totalAssets,
|
|
|
|
controller: controller,
|
|
|
|
showStack: showStack,
|
|
|
|
stackIndex: stackIndex.value,
|
|
|
|
asset: asset,
|
|
|
|
showVideoPlayerControls: !asset.isImage && !isMotionPhoto,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-04-17 07:02:07 +02:00
|
|
|
),
|
2023-03-06 06:51:18 +02:00
|
|
|
],
|
|
|
|
),
|
2022-08-03 22:36:12 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|