From 79442fc8a1eee2e8f3dad56c3ed3a79638172f95 Mon Sep 17 00:00:00 2001 From: martyfuhry Date: Wed, 28 Feb 2024 16:48:59 -0500 Subject: [PATCH] fix(mobile): Fixes thumbnail size with blur and alignment in video player (#7483) * Clip the edges of the image filter * Fixes thumbnail blur effect expanding outside of the image * Fixes thumbs with video player and delayed loader --- .../asset_viewer/views/gallery_viewer.dart | 25 +++++++++------ .../asset_viewer/views/video_viewer_page.dart | 12 ++++--- .../shared/ui/delayed_loading_indicator.dart | 31 ++++++++++--------- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart index 48eb778c10..e296483cc2 100644 --- a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart +++ b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart @@ -735,14 +735,21 @@ class GalleryViewerPage extends HookConsumerWidget { isZoomed.value = state != PhotoViewScaleState.initial; ref.read(showControlsProvider.notifier).show = !isZoomed.value; }, - loadingBuilder: (context, event, index) => ImageFiltered( - imageFilter: ui.ImageFilter.blur( - sigmaX: 1, - sigmaY: 1, - ), - child: ImmichThumbnail( - asset: asset(), - fit: BoxFit.contain, + loadingBuilder: (context, event, index) => ClipRect( + child: Stack( + fit: StackFit.expand, + children: [ + BackdropFilter( + filter: ui.ImageFilter.blur( + sigmaX: 10, + sigmaY: 10, + ), + ), + ImmichThumbnail( + asset: asset(), + fit: BoxFit.contain, + ), + ], ), ), pageController: controller, @@ -818,7 +825,7 @@ class GalleryViewerPage extends HookConsumerWidget { isMotionVideo: isPlayingMotionVideo.value, placeholder: Image( image: provider, - fit: BoxFit.fitWidth, + fit: BoxFit.contain, height: context.height, width: context.width, alignment: Alignment.center, diff --git a/mobile/lib/modules/asset_viewer/views/video_viewer_page.dart b/mobile/lib/modules/asset_viewer/views/video_viewer_page.dart index eb125f27fb..0da2bc52db 100644 --- a/mobile/lib/modules/asset_viewer/views/video_viewer_page.dart +++ b/mobile/lib/modules/asset_viewer/views/video_viewer_page.dart @@ -40,7 +40,7 @@ class VideoViewerPage extends HookWidget { controlsSafeAreaMinimum: const EdgeInsets.only( bottom: 100, ), - placeholder: SizedBox.expand(child: placeholder), + placeholder: placeholder, showControls: showControls && !isMotionVideo, hideControlsTimer: hideControlsTimer, customControls: const VideoPlayerControls(), @@ -58,9 +58,13 @@ class VideoViewerPage extends HookWidget { if (controller == null) { return Stack( children: [ - if (placeholder != null) SizedBox.expand(child: placeholder!), - const DelayedLoadingIndicator( - fadeInDuration: Duration(milliseconds: 500), + if (placeholder != null) placeholder!, + const Positioned.fill( + child: Center( + child: DelayedLoadingIndicator( + fadeInDuration: Duration(milliseconds: 500), + ), + ), ), ], ); diff --git a/mobile/lib/shared/ui/delayed_loading_indicator.dart b/mobile/lib/shared/ui/delayed_loading_indicator.dart index b4d9f4c806..e009b660c9 100644 --- a/mobile/lib/shared/ui/delayed_loading_indicator.dart +++ b/mobile/lib/shared/ui/delayed_loading_indicator.dart @@ -20,21 +20,24 @@ class DelayedLoadingIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - return AnimatedSwitcher( - duration: fadeInDuration ?? Duration.zero, - child: FutureBuilder( - future: Future.delayed(delay), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.done) { - return child ?? - const ImmichLoadingIndicator( - key: ValueKey('loading'), - ); - } + return FutureBuilder( + future: Future.delayed(delay), + builder: (context, snapshot) { + late Widget c; + if (snapshot.connectionState == ConnectionState.done) { + c = child ?? + const ImmichLoadingIndicator( + key: ValueKey('loading'), + ); + } else { + c = Container(key: const ValueKey('hiding')); + } - return Container(key: const ValueKey('hiding')); - }, - ), + return AnimatedSwitcher( + duration: fadeInDuration ?? Duration.zero, + child: c, + ); + }, ); } }