diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart index fbe6597236..fdb7c20a34 100644 --- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart +++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart @@ -614,11 +614,18 @@ class _PinnedGroupHeaderState extends State { String? currentGroupId; final _enlargeHeader = ValueNotifier(false); Timer? _enlargeHeaderTimer; + late final ValueNotifier _atZeroScrollNotifier; @override void initState() { super.initState(); widget.scrollbarInUseNotifier.addListener(scrollbarInUseListener); widget.scrollController.addListener(_setCurrentGroupID); + _atZeroScrollNotifier = ValueNotifier( + widget.scrollController.offset == 0, + ); + widget.scrollController.addListener( + _scrollControllerListenerForZeroScrollNotifier, + ); } @override @@ -631,8 +638,12 @@ class _PinnedGroupHeaderState extends State { void dispose() { widget.scrollController.removeListener(_setCurrentGroupID); widget.scrollbarInUseNotifier.removeListener(scrollbarInUseListener); - _enlargeHeaderTimer?.cancel(); + _atZeroScrollNotifier.removeListener( + _scrollControllerListenerForZeroScrollNotifier, + ); _enlargeHeader.dispose(); + _atZeroScrollNotifier.dispose(); + _enlargeHeaderTimer?.cancel(); super.dispose(); } @@ -691,6 +702,10 @@ class _PinnedGroupHeaderState extends State { } } + void _scrollControllerListenerForZeroScrollNotifier() { + _atZeroScrollNotifier.value = widget.scrollController.offset == 0; + } + void scrollbarInUseListener() { _enlargeHeaderTimer?.cancel(); if (widget.scrollbarInUseNotifier.value) { @@ -713,22 +728,43 @@ class _PinnedGroupHeaderState extends State { alignment: Alignment.topLeft, duration: const Duration(milliseconds: 200), curve: Curves.easeInOutSine, - child: ColoredBox( - color: getEnteColorScheme(context).backgroundBase, - child: GroupHeaderWidget( - title: widget.galleryGroups - .groupIdToheaderDataMap[currentGroupId!]!.groupType - .getTitle( - context, - widget.galleryGroups.groupIDToFilesMap[currentGroupId]! - .first, + child: ValueListenableBuilder( + valueListenable: _atZeroScrollNotifier, + builder: (context, atZeroScroll, child) { + return AnimatedContainer( + duration: const Duration(milliseconds: 250), + curve: Curves.easeOut, + decoration: BoxDecoration( + boxShadow: atZeroScroll + ? [] + : [ + BoxShadow( + color: Colors.black.withOpacity(0.15), + blurRadius: 4, + offset: const Offset(0, 2), + ), + ], + ), + child: child, + ); + }, + child: ColoredBox( + color: getEnteColorScheme(context).backgroundBase, + child: GroupHeaderWidget( + title: widget.galleryGroups + .groupIdToheaderDataMap[currentGroupId!]!.groupType + .getTitle( + context, + widget.galleryGroups.groupIDToFilesMap[currentGroupId]! + .first, + ), + gridSize: localSettings.getPhotoGridSize(), + height: widget.galleryGroups.headerExtent, + filesInGroup: widget + .galleryGroups.groupIDToFilesMap[currentGroupId!]!, + selectedFiles: widget.selectedFiles, + showSelectAllByDefault: widget.showSelectAllByDefault, ), - gridSize: localSettings.getPhotoGridSize(), - height: widget.galleryGroups.headerExtent, - filesInGroup: widget - .galleryGroups.groupIDToFilesMap[currentGroupId!]!, - selectedFiles: widget.selectedFiles, - showSelectAllByDefault: widget.showSelectAllByDefault, ), ), );