π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Clean up gallery sliver app bar migration
ashilkn4cb6b3683194
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dartindex 7e8552de69..bfb2db76c2 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart@@ -603,6 +603,21 @@ class GalleryState extends State<Gallery> {double get _appBarCollapseExtent => widget.appBar?.collapseExtent ?? 0;+ double get _headerHeight {+ final cachedHeight = _headerHeightNotifier.value;+ if (cachedHeight != null) {+ return cachedHeight;+ }+ final renderBox = _headerKey.currentContext?.findRenderObject();+ return renderBox is RenderBox && renderBox.hasSize+ ? renderBox.size.height+ : 0;+ }++ double _scrollOffsetForSectionOffset(double sectionOffset) {+ return sectionOffset + _appBarCollapseExtent + _headerHeight;+ }+ScrollPhysics get _scrollPhysics => widget.disableScroll? const NeverScrollableScrollPhysics(): const ExponentialBouncingScrollPhysics();@@ -644,11 +659,12 @@ class GalleryState extends State<Gallery> {widget.fileToJumpTo!,);if (offset != null) {- _logger.info("Jumping to date at offset: $offset");- _scrollController.jumpTo(offset - 50);+ final scrollOffset = _scrollOffsetForSectionOffset(offset);+ _logger.info("Jumping to date at offset: $scrollOffset");+ _scrollController.jumpTo(scrollOffset - 50);await Future.delayed(16.milliseconds);await _scrollController.animateTo(- offset,+ scrollOffset,duration: 300.milliseconds,curve: Curves.easeOutQuint,);@@ -734,7 +750,6 @@ class GalleryState extends State<Gallery> {}});}- final scrollContentMediaQuery = MediaQuery.of(context);return SwipeSelectionWrapper(isEnabled: shouldEnableSwipeSelection,@@ -775,59 +790,56 @@ class GalleryState extends State<Gallery> {return true;},- child: MediaQuery(- data: scrollContentMediaQuery,- child: Stack(- clipBehavior: Clip.none,- children: [- ValueListenableBuilder<bool>(- valueListenable: _swipeActiveNotifier,- builder: (context, isSwipeActive, child) {- return CustomScrollView(- physics: widget.disableScroll || isSwipeActive- ? const NeverScrollableScrollPhysics()- : const ExponentialBouncingScrollPhysics(),- controller: _scrollController,- slivers: [- if (widget.appBar != null)- widget.appBar!.buildSliver(context),- SliverToBoxAdapter(- child: SizeChangedLayoutNotifier(- child: SizedBox(- key: _headerKey,- child:- widget.header ??- const SizedBox.shrink(),- ),+ child: Stack(+ clipBehavior: Clip.none,+ children: [+ ValueListenableBuilder<bool>(+ valueListenable: _swipeActiveNotifier,+ builder: (context, isSwipeActive, child) {+ return CustomScrollView(+ physics: widget.disableScroll || isSwipeActive+ ? const NeverScrollableScrollPhysics()+ : const ExponentialBouncingScrollPhysics(),+ controller: _scrollController,+ slivers: [+ if (widget.appBar != null)+ widget.appBar!.buildSliver(context),+ SliverToBoxAdapter(+ child: SizeChangedLayoutNotifier(+ child: SizedBox(+ key: _headerKey,+ child:+ widget.header ??+ const SizedBox.shrink(),),),- SectionedListSliver(- sectionLayouts: groups.groupLayouts,- ),- SliverToBoxAdapter(child: widget.footer),- ],- );- },- ),- groups.groupType.showGroupHeader() &&- !widget.disablePinnedGroupHeader- ? PinnedGroupHeader(- scrollController: _scrollController,- galleryGroups: groups,- headerHeightNotifier: _headerHeightNotifier,- scrollOffsetBase: _appBarCollapseExtent,- topOffset: _appBarPinnedHeight,- selectedFiles: widget.selectedFiles,- showSelectAll:- widget.showSelectAll &&- !widget.limitSelectionToOne,- scrollbarInUseNotifier: scrollBarInUseNotifier,- showGallerySettingsCTA:- widget.showGallerySettingsCTA,- )- : const SizedBox.shrink(),- ],- ),+ ),+ SectionedListSliver(+ sectionLayouts: groups.groupLayouts,+ ),+ SliverToBoxAdapter(child: widget.footer),+ ],+ );+ },+ ),+ groups.groupType.showGroupHeader() &&+ !widget.disablePinnedGroupHeader+ ? PinnedGroupHeader(+ scrollController: _scrollController,+ galleryGroups: groups,+ headerHeightNotifier: _headerHeightNotifier,+ scrollOffsetBase: _appBarCollapseExtent,+ topOffset: _appBarPinnedHeight,+ selectedFiles: widget.selectedFiles,+ showSelectAll:+ widget.showSelectAll &&+ !widget.limitSelectionToOne,+ scrollbarInUseNotifier: scrollBarInUseNotifier,+ showGallerySettingsCTA:+ widget.showGallerySettingsCTA,+ )+ : const SizedBox.shrink(),+ ],),),),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 aedd9a0b20..6324005964 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@@ -68,10 +68,6 @@ class GalleryAppBarWidget extends StatefulWidget {static const double _defaultBackIconSize = IconSizes.medium;static const double _sliverExpandedHeight = 92.0;- static double hierarchicalPreferredHeight(BuildContext context) {- return toolbarHeight + AppBarFilterChips.preferredHeight(context);- }-static double sliverPinnedHeight(BuildContext context, {required bool isHierarchicalSearchable,@@ -198,7 +194,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {late StreamSubscription _userAuthEventSubscription;late StreamSubscription<CollectionMetaEvent> _collectionMetaEventSubscription;late Function() _selectedFilesListener;- String? _appBarTitle;+ late String _appBarTitle;late CollectionActions collectionActions;bool isQuickLink = false;late GalleryType galleryType;@@ -226,7 +222,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {).listen(stateRefresh);- _appBarTitle = widget.title;+ _appBarTitle = widget.title ?? "";galleryType = widget.type;_checkIfICloudSharedAlbum();}@@ -246,6 +242,14 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {}}+ @override+ void didUpdateWidget(covariant GalleryAppBarWidget oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.title != widget.title) {+ _appBarTitle = widget.title ?? "";+ }+ }+@overridevoid dispose() {_userAuthEventSubscription.cancel();@@ -313,7 +317,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {PreferredSizeWidget? bottom,}) {return SliverAppBarComponent(- title: _appBarTitle!,+ title: _appBarTitle,actions: actions,bottom: bottom,expandedHeight: GalleryAppBarWidget._sliverExpandedHeight,@@ -347,9 +351,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {child: Align(alignment: Alignment.centerLeft,child: TooltipComponent(- message: _appBarTitle!,+ message: _appBarTitle,child: Text(- _appBarTitle!,+ _appBarTitle,style: TextStyles.h2.copyWith(color: colors.textBase),maxLines: 1,overflow: TextOverflow.ellipsis,@@ -430,7 +434,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {textCapitalization: TextCapitalization.words,onSubmit: (String text) async {// indicates user cancelled the rename request- if (text == "" || text.trim() == _appBarTitle!.trim()) {+ if (text == "" || text.trim() == _appBarTitle.trim()) {return;}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dartindex 30b038ed7d..9fb66d701f 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart@@ -223,26 +223,21 @@ class _CustomScrollBarState extends State<CustomScrollBar> {clipBehavior: Clip.none,alignment: Alignment.centerLeft,children: [- // This media query is used to adjust the bottom padding of the scrollbar- MediaQuery(- data: MediaQuery.of(context).copyWith(- padding: EdgeInsets.only(- bottom: widget.bottomPadding.value,- top: widget.topPadding,- right: 3,- ),- ),- child: ScrollbarWithUseNotifer(- key: _scrollbarKey,- controller: widget.scrollController,- interactive: true,- inUseNotifier: widget.inUseNotifier,- minScrollbarLength: _kScrollbarMinLength,- showThumb: _showThumb,- radius: const Radius.circular(4),- thickness: 8,- child: widget.child,+ ScrollbarWithUseNotifer(+ key: _scrollbarKey,+ controller: widget.scrollController,+ interactive: true,+ inUseNotifier: widget.inUseNotifier,+ minScrollbarLength: _kScrollbarMinLength,+ showThumb: _showThumb,+ radius: const Radius.circular(4),+ thickness: 8,+ scrollbarPadding: EdgeInsets.only(+ bottom: widget.bottomPadding.value,+ top: widget.topPadding,+ right: 3,),+ child: widget.child,),positionToTitleMap == null || heightOfScrollbarDivider == null? const SizedBox.shrink()diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dartindex d2479bf1da..db269775d7 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart@@ -96,6 +96,7 @@ class ScrollbarWithUseNotifer extends StatelessWidget {this.interactive,this.scrollbarOrientation,this.showThumb,+ this.scrollbarPadding,});/// {@macro flutter.widgets.Scrollbar.child}@@ -157,6 +158,8 @@ class ScrollbarWithUseNotifer extends StatelessWidget {final bool? showThumb;+ final EdgeInsets? scrollbarPadding;+@overrideWidget build(BuildContext context) {return ScrollbarTheme(@@ -183,6 +186,7 @@ class ScrollbarWithUseNotifer extends StatelessWidget {inUseNotifier: inUseNotifier,minScrollbarLength: minScrollbarLength,showThumb: showThumb,+ scrollbarPadding: scrollbarPadding,child: child,),);@@ -193,11 +197,13 @@ class _MaterialScrollbar extends RawScrollbar {final ValueNotifier<bool> inUseNotifier;final double minScrollbarLength;final bool? showThumb;+ final EdgeInsets? scrollbarPadding;const _MaterialScrollbar({required super.child,required this.inUseNotifier,required this.minScrollbarLength,required this.showThumb,+ required this.scrollbarPadding,super.controller,super.thumbVisibility,super.trackVisibility,@@ -392,7 +398,7 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> {(_useAndroidScrollbar ? 0.0 : _kScrollbarMargin)..mainAxisMargin = _scrollbarTheme.mainAxisMargin ?? 0.0..minLength = widget.minScrollbarLength- ..padding = MediaQuery.paddingOf(context)+ ..padding = widget.scrollbarPadding ?? MediaQuery.paddingOf(context)..scrollbarOrientation = widget.scrollbarOrientation..ignorePointer = !enableGestures;}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 1dc6ff09c7..560394314d 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@@ -31,14 +31,13 @@ import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart"import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";import "package:photos/ui/viewer/gallery/empty_state.dart";import "package:photos/ui/viewer/gallery/gallery.dart";+import "package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart";import "package:photos/ui/viewer/gallery/hierarchical_search_gallery.dart";-import "package:photos/ui/viewer/gallery/state/boundary_reporter_mixin.dart";import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.dart";import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";import "package:photos/ui/viewer/gallery/state/search_filter_data_provider.dart";import "package:photos/ui/viewer/gallery/state/selection_state.dart";-import "package:photos/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart";import "package:photos/ui/viewer/people/person_selection_action_widgets.dart";import "package:photos/ui/viewer/search/contact_avatar_widget.dart";import "package:photos/ui/viewer/search/result/edit_contact_page.dart";@@ -123,7 +122,15 @@ 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,asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) {final result = files.where(@@ -154,33 +161,12 @@ class _ContactResultPageState extends State<ContactResultPage> {: const EmptyState(),);- final appBarHeight = _ContactResultAppBar.preferredHeight(- context,- isHierarchicalSearchable: true,- );-return GalleryBoundariesProvider(child: GalleryFilesState(child: InheritedSearchFilterDataWrapper(searchFilterDataProvider: _searchFilterDataProvider,child: Scaffold(backgroundColor: getEnteColorScheme(context).backgroundColour,- appBar: PreferredSize(- preferredSize: Size.fromHeight(appBarHeight),- child: widget.enableGrouping- ? _ContactResultAppBar(- title: _searchResultName,- isHierarchicalSearchable: true,- height: appBarHeight,- )- : _AppBarWithBoundary(- child: _ContactResultAppBar(- title: _searchResultName,- isHierarchicalSearchable: true,- height: appBarHeight,- ),- ),- ),body: SelectionState(selectedFiles: _selectedFiles,child: Stack(@@ -197,6 +183,7 @@ class _ContactResultPageState extends State<ContactResultPage> {? HierarchicalSearchGallery(tagPrefix: widget.tagPrefix,selectedFiles: _selectedFiles,+ appBar: appBar,): gallery;},@@ -581,102 +568,3 @@ class _UnsavedContactEmptyState extends StatelessWidget {);}}--class _ContactResultAppBar extends StatelessWidget- implements PreferredSizeWidget {- static const _toolbarHeight = 56.0;-- final String title;- final bool isHierarchicalSearchable;- final double height;-- const _ContactResultAppBar({- required this.title,- required this.isHierarchicalSearchable,- required this.height,- });-- static double preferredHeight(- BuildContext context, {- required bool isHierarchicalSearchable,- }) {- return isHierarchicalSearchable- ? AppBarFilterChips.appBarHeight(context)- : _toolbarHeight;- }-- @override- Size get preferredSize => Size.fromHeight(height);-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- if (!isHierarchicalSearchable) {- return AppBar(- elevation: 0,- scrolledUnderElevation: 0,- backgroundColor: colorScheme.backgroundColour,- surfaceTintColor: Colors.transparent,- titleSpacing: 0,- centerTitle: false,- title: _ContactResultAppBarTitle(title: title),- );- }-- return AppBar(- elevation: 0,- scrolledUnderElevation: 0,- backgroundColor: colorScheme.backgroundColour,- surfaceTintColor: Colors.transparent,- titleSpacing: 0,- centerTitle: false,- title: _ContactResultAppBarTitle(title: title),- bottom: PreferredSize(- preferredSize: Size.fromHeight(- AppBarFilterChips.preferredHeight(context),- ),- child: const Padding(- padding: EdgeInsets.symmetric(horizontal: 12),- child: AppBarFilterChips(),- ),- ),- );- }-}--class _ContactResultAppBarTitle extends StatelessWidget {- const _ContactResultAppBarTitle({required this.title});-- final String title;-- @override- Widget build(BuildContext context) {- return Text(- title,- style: getEnteTextTheme(- context,- ).largeBold.copyWith(color: getEnteColorScheme(context).textBase),- maxLines: 1,- overflow: TextOverflow.ellipsis,- );- }-}--/// Wrapper widget that reports the app bar as top boundary for auto-scroll-/// when file grouping is disabled-class _AppBarWithBoundary extends StatefulWidget {- final Widget child;-- const _AppBarWithBoundary({required this.child});-- @override- State<_AppBarWithBoundary> createState() => _AppBarWithBoundaryState();-}--class _AppBarWithBoundaryState extends State<_AppBarWithBoundary>- with BoundaryReporter {- @override- Widget build(BuildContext context) {- return boundaryWidget(position: BoundaryPosition.top, child: widget.child);- }-}