π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Derive gallery app bar geometry from context
ashilknb6ef7fc793dd
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/archive_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/archive_page.dartindex bec4a5c3df..41b6eee59e 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/archive_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/archive_page.dart@@ -39,11 +39,9 @@ class ArchivePage extends StatelessWidget {final Set<int> hiddenCollectionIDs = CollectionsService.instance.getHiddenCollectionIds();final appBar = GalleryAppBarWidget.sliverConfig(- context,appBarType,AppLocalizations.of(context).archive,_selectedFiles,- isHierarchicalSearchable: false,);final gallery = Gallery(appBar: appBar,diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/cleanup_hidden_from_device_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/cleanup_hidden_from_device_page.dartindex c2b537489f..f98dbd7895 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/cleanup_hidden_from_device_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/cleanup_hidden_from_device_page.dart@@ -61,11 +61,9 @@ class _CleanupHiddenFromDevicePageStatefinal bottomPadding = MediaQuery.of(context).padding.bottom;final deleteAllButtonHeight = 40.0 + max(bottomPadding, 6.0) + 12.0;final appBar = GalleryAppBarWidget.sliverConfig(- context,GalleryType.cleanupHiddenFromDevice,AppLocalizations.of(context).deleteOnDeviceFiles,_selectedFiles,- isHierarchicalSearchable: false,);final gallery = Gallery(diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dartindex b9fe2e1e20..305fd44501 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/collection_page.dart@@ -59,11 +59,9 @@ class CollectionPage extends StatelessWidget {? [c.thumbnail!]: null;final appBar = GalleryAppBarWidget.sliverConfig(- context,galleryType,c.collection.displayName,_selectedFiles,- isHierarchicalSearchable: true,collection: c.collection,isFromCollectPhotos: isFromCollectPhotos,);diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/delete_suggestions_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/delete_suggestions_page.dartindex 4b5794ab4d..f0122ef6fe 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/delete_suggestions_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/delete_suggestions_page.dart@@ -30,11 +30,9 @@ class DeleteSuggestionsPage extends StatelessWidget {@overrideWidget build(BuildContext context) {final appBar = GalleryAppBarWidget.sliverConfig(- context,appBarType,AppLocalizations.of(context).deleteSuggestions,_selectedFiles,- isHierarchicalSearchable: false,);final gallery = Gallery(appBar: appBar,diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/device_folder_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/device_folder_page.dartindex 67cd969c1f..de469a128a 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/device_folder_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/device_folder_page.dart@@ -112,11 +112,9 @@ class _DeviceFolderPageState extends State<DeviceFolderPage> {@overrideWidget build(BuildContext context) {final appBar = GalleryAppBarWidget.sliverConfig(- context,GalleryType.localFolder,widget.deviceCollection.name,_selectedFiles,- isHierarchicalSearchable: false,deviceCollection: widget.deviceCollection,);final gallery = Gallery(diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dartindex bfb2db76c2..2b49caae9c 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart@@ -599,10 +599,6 @@ class GalleryState extends State<Gallery> {super.dispose();}- double get _appBarPinnedHeight => widget.appBar?.pinnedHeight ?? 0;-- double get _appBarCollapseExtent => widget.appBar?.collapseExtent ?? 0;-double get _headerHeight {final cachedHeight = _headerHeightNotifier.value;if (cachedHeight != null) {@@ -614,8 +610,11 @@ class GalleryState extends State<Gallery> {: 0;}- double _scrollOffsetForSectionOffset(double sectionOffset) {- return sectionOffset + _appBarCollapseExtent + _headerHeight;+ double _scrollOffsetForSectionOffset(+ double sectionOffset,+ double appBarCollapseExtent,+ ) {+ return sectionOffset + appBarCollapseExtent + _headerHeight;}ScrollPhysics get _scrollPhysics => widget.disableScroll@@ -640,6 +639,9 @@ class GalleryState extends State<Gallery> {@overrideWidget build(BuildContext context) {_logger.info("Building Gallery ${widget.tagPrefix}");+ final appBarGeometry = widget.appBar?.resolveGeometry(context);+ final appBarPinnedHeight = appBarGeometry?.minExtent ?? 0;+ final appBarCollapseExtent = appBarGeometry?.collapseExtent ?? 0;// Share scroll controller with boundaries provider after buildWidgetsBinding.instance.addPostFrameCallback((_) {@@ -659,7 +661,10 @@ class GalleryState extends State<Gallery> {widget.fileToJumpTo!,);if (offset != null) {- final scrollOffset = _scrollOffsetForSectionOffset(offset);+ final scrollOffset = _scrollOffsetForSectionOffset(+ offset,+ appBarCollapseExtent,+ );_logger.info("Jumping to date at offset: $scrollOffset");_scrollController.jumpTo(scrollOffset - 50);await Future.delayed(16.milliseconds);@@ -741,12 +746,12 @@ class GalleryState extends State<Gallery> {}});}- if (_appBarPinnedHeight > 0 &&+ if (appBarPinnedHeight > 0 &&(!groups.groupType.showGroupHeader() ||widget.disablePinnedGroupHeader)) {WidgetsBinding.instance.addPostFrameCallback((_) {if (mounted) {- _boundariesProvider?.setTopBoundary(_appBarPinnedHeight);+ _boundariesProvider?.setTopBoundary(appBarPinnedHeight);}});}@@ -771,7 +776,7 @@ class GalleryState extends State<Gallery> {heighOfViewport: MediaQuery.sizeOf(context).height,topPadding: widget.disableVerticalPaddingForScrollbar? 0.0- : _appBarPinnedHeight + groupHeaderExtent!,+ : appBarPinnedHeight + groupHeaderExtent!,bottomPadding: widget.disableVerticalPaddingForScrollbar? ValueNotifier(0.0): scrollbarBottomPaddingNotifier,@@ -828,8 +833,8 @@ class GalleryState extends State<Gallery> {scrollController: _scrollController,galleryGroups: groups,headerHeightNotifier: _headerHeightNotifier,- scrollOffsetBase: _appBarCollapseExtent,- topOffset: _appBarPinnedHeight,+ scrollOffsetBase: appBarCollapseExtent,+ topOffset: appBarPinnedHeight,selectedFiles: widget.selectedFiles,showSelectAll:widget.showSelectAll &&diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_config.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_config.dartindex 824e343fb0..a8fa11f43b 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_config.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_config.dart@@ -1,17 +1,23 @@+import "package:ente_components/ente_components.dart";import "package:flutter/widgets.dart";+typedef GalleryAppBarGeometryBuilder =+ HeaderAppBarGeometry Function(BuildContext context);+class GalleryAppBarConfig {const GalleryAppBarConfig({required this.sliverBuilder,- required this.pinnedHeight,- required this.expandedHeight,- }) : assert(expandedHeight >= pinnedHeight);+ required this.geometryBuilder,+ });final WidgetBuilder sliverBuilder;- final double pinnedHeight;- final double expandedHeight;+ final GalleryAppBarGeometryBuilder geometryBuilder;- double get collapseExtent => expandedHeight - pinnedHeight;+ HeaderAppBarGeometry resolveGeometry(BuildContext context) {+ final geometry = geometryBuilder(context);+ assert(geometry.maxExtent >= geometry.minExtent);+ return geometry;+ }Widget buildSliver(BuildContext context) => sliverBuilder(context);}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dartindex 424fdac486..088726c302 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart@@ -69,27 +69,14 @@ class GalleryAppBarWidget extends StatefulWidget {static const double _sliverExpandedHeight = 92.0;static GalleryAppBarConfig sliverConfig(- BuildContext context,GalleryType type,String? title,SelectedFiles selectedFiles, {- required bool isHierarchicalSearchable,DeviceCollection? deviceCollection,Collection? collection,bool isFromCollectPhotos = false,List<EnteFile>? files,}) {- final bottomHeight = isHierarchicalSearchable- ? AppBarFilterChips.preferredHeight(context)- : 0.0;- final geometry = SliverAppBarComponent.resolveGeometry(- context,- subtitle: null,- expandedHeight: _sliverExpandedHeight,- collapsedHeight: toolbarHeight,- titleBuilderHeight: null,- bottomHeight: bottomHeight,- );return GalleryAppBarConfig(sliverBuilder: (_) => GalleryAppBarWidget(type,@@ -101,8 +88,26 @@ class GalleryAppBarWidget extends StatefulWidget {files: files,asSliver: true,),- pinnedHeight: geometry.minExtent,- expandedHeight: geometry.maxExtent,+ geometryBuilder: _resolveSliverGeometry,+ );+ }++ static HeaderAppBarGeometry _resolveSliverGeometry(BuildContext context) {+ final inheritedSearchFilterData = InheritedSearchFilterData.maybeOf(+ context,+ );+ final isHierarchicalSearchable =+ inheritedSearchFilterData?.isHierarchicalSearchable ?? false;+ final bottomHeight = isHierarchicalSearchable+ ? AppBarFilterChips.preferredHeight(context)+ : 0.0;+ return SliverAppBarComponent.resolveGeometry(+ context,+ subtitle: null,+ expandedHeight: _sliverExpandedHeight,+ collapsedHeight: toolbarHeight,+ titleBuilderHeight: null,+ bottomHeight: bottomHeight,);}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/hidden_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/hidden_page.dartindex 38800583b8..b536fa85ea 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/hidden_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hidden_page.dart@@ -170,11 +170,9 @@ class _HiddenPageState extends State<HiddenPage> {return const EnteLoadingWidget();}final appBar = GalleryAppBarWidget.sliverConfig(- context,widget.appBarType,AppLocalizations.of(context).hidden,_selectedFiles,- isHierarchicalSearchable: false,);final gallery = Gallery(appBar: appBar,diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/jump_to_date_gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/jump_to_date_gallery.dartindex 57dc000544..2a9b0270b6 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/jump_to_date_gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/jump_to_date_gallery.dart@@ -117,11 +117,9 @@ class _JumpToDateGalleryState extends State<JumpToDateGallery> {@overrideWidget build(BuildContext context) {final appBar = GalleryAppBarWidget.sliverConfig(- context,JumpToDateGallery.appBarType,"",_selectedFiles,- isHierarchicalSearchable: false,);return GalleryBoundariesProvider(child: GalleryFilesState(diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dartindex e0cb293d20..4a031688e8 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart@@ -127,11 +127,9 @@ class _SharedPublicCollectionPageState? GroupType.none: GroupType.day;final appBar = GalleryAppBarWidget.sliverConfig(- context,galleryType,widget.c.collection.displayName,_selectedFiles,- isHierarchicalSearchable: false,collection: widget.c.collection,files: widget.files,);diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/trash_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/trash_page.dartindex 6141740f24..3d44965f65 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/trash_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/trash_page.dart@@ -37,11 +37,9 @@ class TrashPage extends StatelessWidget {final bottomPadding = MediaQuery.of(context).padding.bottom;final deleteAllButtonHeight = 40.0 + max(bottomPadding, 6.0) + 12.0;final appBar = GalleryAppBarWidget.sliverConfig(- context,appBarType,AppLocalizations.of(context).trash,_selectedFiles,- isHierarchicalSearchable: false,);final gallery = Gallery(diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/uncategorized_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/uncategorized_page.dartindex 7d04e9c7ca..0ba03f2d3d 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/uncategorized_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/uncategorized_page.dart@@ -40,11 +40,9 @@ class UnCategorizedPage extends StatelessWidget {@overrideWidget build(BuildContext context) {final appBar = GalleryAppBarWidget.sliverConfig(- context,appBarType,AppLocalizations.of(context).uncategorized,_selectedFiles,- isHierarchicalSearchable: true,collection: collection,);final gallery = Gallery(diff --git a/mobile/apps/photos/lib/ui/viewer/location/location_screen.dart b/mobile/apps/photos/lib/ui/viewer/location/location_screen.dartindex 58822794c6..c3a1462ad5 100644--- a/mobile/apps/photos/lib/ui/viewer/location/location_screen.dart+++ b/mobile/apps/photos/lib/ui/viewer/location/location_screen.dart@@ -143,11 +143,9 @@ class _LocationGalleryWidgetState extends State<LocationGalleryWidget> {context,).locationTagEntity.item.centerPoint;final appBar = GalleryAppBarWidget.sliverConfig(- context,GalleryType.locationTag,locationTag.name,_selectedFiles,- isHierarchicalSearchable: true,);Future<FileLoadResult> filterFiles() async {diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dartindex 560394314d..d0efd7fc4d 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart@@ -123,11 +123,9 @@ class _ContactResultPageState extends State<ContactResultPage> {@overrideWidget build(BuildContext context) {final appBar = GalleryAppBarWidget.sliverConfig(- context,ContactResultPage.appBarType,_searchResultName,_selectedFiles,- isHierarchicalSearchable: true,);final gallery = Gallery(appBar: appBar,diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart b/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dartindex f84c979417..1535176fe5 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/magic_result_screen.dart@@ -178,11 +178,9 @@ class _MagicResultScreenState extends State<MagicResultScreen> {@overrideWidget build(BuildContext context) {final appBar = GalleryAppBarWidget.sliverConfig(- context,MagicResultScreen.appBarType,widget.name,_selectedFiles,- isHierarchicalSearchable: true,);final gallery = Gallery(key: ValueKey(_enableGrouping),diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/search_result_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/search_result_page.dartindex 437a542de0..b995668524 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/search_result_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/search_result_page.dart@@ -75,11 +75,9 @@ class _SearchResultPageState extends State<SearchResultPage> {@overrideWidget build(BuildContext context) {final appBar = GalleryAppBarWidget.sliverConfig(- context,SearchResultPage.appBarType,widget.searchResult.name(),_selectedFiles,- isHierarchicalSearchable: true,);final gallery = Gallery(appBar: appBar,