π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use shared sliver app bar for person and cluster screens
ashilkndf49985d2318
diff --git a/mobile/apps/photos/changes/person-screen-app-bar.md b/mobile/apps/photos/changes/person-screen-app-bar.mdnew file mode 100644index 0000000000..8dd2b7338c--- /dev/null+++ b/mobile/apps/photos/changes/person-screen-app-bar.md@@ -0,0 +1 @@+- Updated the app bar on person and face group screens to match the rest of the galleries.diff --git a/mobile/apps/photos/lib/ui/viewer/people/cluster_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/people/cluster_app_bar.dartindex 86e29d6eb2..1ff3721a78 100644--- a/mobile/apps/photos/lib/ui/viewer/people/cluster_app_bar.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/cluster_app_bar.dart@@ -1,5 +1,6 @@import 'dart:async';+import "package:ente_components/ente_components.dart";import "package:flutter/foundation.dart";import 'package:flutter/material.dart';import 'package:logging/logging.dart';@@ -13,34 +14,51 @@ import 'package:photos/events/subscription_purchased_event.dart';import "package:photos/generated/l10n.dart";import "package:photos/models/file/file.dart";import 'package:photos/models/gallery_type.dart';-import "package:photos/models/ml/face/person.dart";import 'package:photos/models/selected_files.dart';import "package:photos/service_locator.dart" show isLocalGalleryMode;import 'package:photos/services/collections_service.dart';import "package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart";import "package:photos/services/machine_learning/ml_result.dart";+import "package:photos/theme/ente_theme.dart";import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';import "package:photos/ui/common/popup_item.dart";import 'package:photos/ui/components/buttons/button_widget.dart';+import "package:photos/ui/viewer/gallery/gallery_app_bar_config.dart";import "package:photos/ui/viewer/people/cluster_breakup_page.dart";import "package:photos/ui/viewer/people/cluster_page.dart";import "package:photos/utils/dialog_util.dart";class ClusterAppBar extends StatefulWidget {+ static const double _sliverExpandedHeight = 92.0;++ static GalleryAppBarConfig sliverConfig(+ GalleryType type,+ String? title,+ SelectedFiles selectedFiles,+ String clusterID,+ ) {+ return GalleryAppBarConfig(+ sliverBuilder: (_) =>+ ClusterAppBar._(type, title, selectedFiles, clusterID),+ geometryBuilder: (context) => SliverAppBarComponent.resolveGeometry(+ context,+ expandedHeight: _sliverExpandedHeight,+ collapsedHeight: kToolbarHeight,+ ),+ );+ }+final GalleryType type;final String? title;final SelectedFiles selectedFiles;final String clusterID;- final PersonEntity? person;- const ClusterAppBar(+ const ClusterAppBar._(this.type,this.title,this.selectedFiles,- this.clusterID, {- this.person,- super.key,- });+ this.clusterID,+ );@overrideState<ClusterAppBar> createState() => _AppBarWidgetState();@@ -88,22 +106,22 @@ class _AppBarWidgetState extends State<ClusterAppBar> {super.dispose();}+ @override+ void didUpdateWidget(covariant ClusterAppBar oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.title != widget.title) {+ _appBarTitle = widget.title;+ }+ }+@overrideWidget build(BuildContext context) {- return AppBar(- elevation: 0,- centerTitle: false,- title: Text(- _appBarTitle!,- style: Theme.of(- context,- ).textTheme.headlineSmall!.copyWith(fontSize: 16),- maxLines: 2,- overflow: TextOverflow.ellipsis,- ),+ return SliverAppBarComponent(+ title: _appBarTitle ?? "",actions: _getDefaultActions(context),- scrolledUnderElevation: 0,- surfaceTintColor: Colors.transparent,+ expandedHeight: ClusterAppBar._sliverExpandedHeight,+ collapsedHeight: kToolbarHeight,+ backgroundColor: getEnteColorScheme(context).backgroundColour,);}diff --git a/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart b/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dartindex d0dc891d81..9eba0a1f7c 100644--- a/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart@@ -23,7 +23,6 @@ import "package:photos/ui/components/banners/name_face_banner.dart";import "package:photos/ui/notification/toast.dart";import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";import "package:photos/ui/viewer/gallery/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/selection_state.dart";@@ -197,7 +196,14 @@ class _ClusterPageState extends State<ClusterPage> {@overrideWidget build(BuildContext context) {+ final appBar = ClusterAppBar.sliverConfig(+ SearchResultPage.appBarType,+ "${files.length} memories${widget.appendTitle}",+ _selectedFiles,+ widget.clusterID,+ );final gallery = Gallery(+ appBar: appBar,asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) {final result = files.where(@@ -253,26 +259,6 @@ class _ClusterPageState extends State<ClusterPage> {return GalleryBoundariesProvider(child: GalleryFilesState(child: Scaffold(- appBar: PreferredSize(- preferredSize: const Size.fromHeight(50.0),- child: widget.enableGrouping- ? ClusterAppBar(- SearchResultPage.appBarType,- "${files.length} memories${widget.appendTitle}",- _selectedFiles,- widget.clusterID,- key: ValueKey(files.length),- )- : _AppBarWithBoundary(- child: ClusterAppBar(- SearchResultPage.appBarType,- "${files.length} memories${widget.appendTitle}",- _selectedFiles,- widget.clusterID,- key: ValueKey(files.length),- ),- ),- ),body: SelectionState(selectedFiles: _selectedFiles,child: Stack(@@ -292,22 +278,3 @@ class _ClusterPageState extends State<ClusterPage> {);}}--/// 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);- }-}diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dartindex 3be6a4a866..bcfa6a146d 100644--- a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart@@ -1,5 +1,6 @@import 'dart:async';+import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import 'package:flutter/material.dart';import 'package:logging/logging.dart';@@ -18,6 +19,7 @@ import "package:photos/theme/ente_theme.dart";import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';import "package:photos/ui/components/buttons/button_widget.dart";import "package:photos/ui/notification/toast.dart";+import "package:photos/ui/viewer/gallery/gallery_app_bar_config.dart";import "package:photos/ui/viewer/gallery/hooks/pick_person_avatar.dart";import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";import "package:photos/ui/viewer/hierarchicial_search/app_bar_filter_chips.dart";@@ -30,8 +32,44 @@ const kShowUnnamedIgnoredPersonEventSource ="_AppBarWidgetState._showPersonUnnamedDelete";class PeopleAppBar extends StatefulWidget {- static double hierarchicalPreferredHeight(BuildContext context) {- return AppBarFilterChips.appBarHeight(context);+ static const double _sliverExpandedHeight = 92.0;++ static GalleryAppBarConfig sliverConfig(+ GalleryType type,+ String? title,+ SelectedFiles selectedFiles,+ PersonEntity person, {+ bool memoryLaneReady = false,+ Future<void> Function()? onMemoryLaneTap,+ }) {+ return GalleryAppBarConfig(+ sliverBuilder: (_) => PeopleAppBar._(+ type,+ title,+ selectedFiles,+ person,+ memoryLaneReady: memoryLaneReady,+ onMemoryLaneTap: onMemoryLaneTap,+ ),+ 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,+ expandedHeight: _sliverExpandedHeight,+ collapsedHeight: kToolbarHeight,+ bottomHeight: bottomHeight,+ );}final GalleryType type;@@ -43,14 +81,13 @@ class PeopleAppBar extends StatefulWidget {bool get isIgnored => person.data.isIgnored;- const PeopleAppBar(+ const PeopleAppBar._(this.type,this.title,this.selectedFiles,this.person, {this.memoryLaneReady = false,this.onMemoryLaneTap,- super.key,});@override@@ -170,48 +207,44 @@ class _AppBarWidgetState extends State<PeopleAppBar> {);final isHierarchicalSearchable =inheritedSearchFilterData?.isHierarchicalSearchable ?? false;- return isHierarchicalSearchable- ? ValueListenableBuilder(- valueListenable: inheritedSearchFilterData!- .searchFilterDataProvider!- .isSearchingNotifier,- child: PreferredSize(- preferredSize: Size.fromHeight(- AppBarFilterChips.preferredHeight(context),- ),- child: const AppBarFilterChips(),- ),- builder: (context, isSearching, child) {- return AppBar(- elevation: 0,- centerTitle: false,- title: Text(- _appBarTitle ?? "",- style: Theme.of(- context,- ).textTheme.headlineSmall!.copyWith(fontSize: 16),- maxLines: 2,- overflow: TextOverflow.ellipsis,- ),- bottom: child as PreferredSizeWidget,- actions: isSearching ? null : _getDefaultActions(context),- surfaceTintColor: Colors.transparent,- );- },- )- : AppBar(- elevation: 0,- centerTitle: false,- title: Text(- _appBarTitle ?? "",- style: Theme.of(- context,- ).textTheme.headlineSmall!.copyWith(fontSize: 16),- maxLines: 2,- overflow: TextOverflow.ellipsis,- ),- actions: _getDefaultActions(context),- );++ if (!isHierarchicalSearchable) {+ return _buildSliverAppBar(context, actions: _getDefaultActions(context));+ }++ return ValueListenableBuilder(+ valueListenable: inheritedSearchFilterData!+ .searchFilterDataProvider!+ .isSearchingNotifier,+ child: PreferredSize(+ preferredSize: Size.fromHeight(+ AppBarFilterChips.preferredHeight(context),+ ),+ child: const AppBarFilterChips(),+ ),+ builder: (context, isSearching, child) {+ return _buildSliverAppBar(+ context,+ actions: isSearching ? const [] : _getDefaultActions(context),+ bottom: child as PreferredSizeWidget,+ );+ },+ );+ }++ Widget _buildSliverAppBar(+ BuildContext context, {+ required List<Widget> actions,+ PreferredSizeWidget? bottom,+ }) {+ return SliverAppBarComponent(+ title: _appBarTitle ?? "",+ actions: actions,+ bottom: bottom,+ expandedHeight: PeopleAppBar._sliverExpandedHeight,+ collapsedHeight: kToolbarHeight,+ backgroundColor: getEnteColorScheme(context).backgroundColour,+ );}Future<dynamic> _editPerson(BuildContext context) async {diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart b/mobile/apps/photos/lib/ui/viewer/people/people_page.dartindex 22e8e8ffc9..d8139f359e 100644--- a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/people_page.dart@@ -23,6 +23,7 @@ import "package:photos/services/search_service.dart";import "package:photos/ui/components/end_to_end_banner.dart";import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';import 'package:photos/ui/viewer/gallery/gallery.dart';+import "package:photos/ui/viewer/gallery/gallery_app_bar_config.dart";import "package:photos/ui/viewer/gallery/hierarchical_search_gallery.dart";import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.dart";import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";@@ -60,7 +61,6 @@ class _PeoplePageState extends State<PeoplePage> {final Logger _timelineLogger = Logger("MemoryLaneInteractions");final _selectedFiles = SelectedFiles();List<EnteFile>? files;- Future<List<EnteFile>> filesFuture = Future.value([]);late PersonEntity _person;bool userDismissedPersonGallerySuggestion = false;@@ -96,8 +96,6 @@ class _PeoplePageState extends State<PeoplePage> {}});- filesFuture = _loadPersonFiles();-_filesUpdatedEvent = Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event,) {@@ -243,101 +241,72 @@ class _PeoplePageState extends State<PeoplePage> {final bool showMemoryLaneBanner =featureEnabled && memoryLaneReady && !hasSeenMemoryLane;+ final appBar = PeopleAppBar.sliverConfig(+ GalleryType.peopleTag,+ _getPeoplePageTitle(context),+ _selectedFiles,+ _person,+ memoryLaneReady: memoryLaneReady,+ onMemoryLaneTap: featureEnabled && memoryLaneReady+ ? _openMemoryLanePage+ : null,+ );++ final personGallery = _Gallery(+ appBar: appBar,+ tagPrefix: widget.tagPrefix,+ selectedFiles: _selectedFiles,+ personFiles: files ?? const <EnteFile>[],+ loadPersonFiles: _loadPersonFiles,+ personEntity: _person,+ memoryLaneEnabled: featureEnabled,+ showTimelineBanner: showMemoryLaneBanner,+ onTimelineTap: featureEnabled && memoryLaneReady+ ? () => unawaited(_openMemoryLanePage())+ : null,+ );+return GalleryBoundariesProvider(child: GalleryFilesState(child: InheritedSearchFilterDataWrapper(searchFilterDataProvider: _searchFilterDataProvider,child: Scaffold(- appBar: PreferredSize(- preferredSize: Size.fromHeight(- widget.searchResult != null- ? PeopleAppBar.hierarchicalPreferredHeight(context)- : 50.0,- ),- child: PeopleAppBar(- GalleryType.peopleTag,- _getPeoplePageTitle(context),- _selectedFiles,- _person,- memoryLaneReady: memoryLaneReady,- onMemoryLaneTap: featureEnabled && memoryLaneReady- ? _openMemoryLanePage- : null,+ body: SelectionState(+ selectedFiles: _selectedFiles,+ child: Stack(+ alignment: Alignment.bottomCenter,+ children: [+ Builder(+ builder: (context) {+ final inheritedSearchFilterData =+ InheritedSearchFilterData.of(context);+ if (!inheritedSearchFilterData.isHierarchicalSearchable) {+ return personGallery;+ }+ return ValueListenableBuilder(+ valueListenable: inheritedSearchFilterData+ .searchFilterDataProvider!+ .isSearchingNotifier,+ builder: (context, value, _) {+ return value+ ? HierarchicalSearchGallery(+ tagPrefix: widget.tagPrefix,+ selectedFiles: _selectedFiles,+ appBar: appBar,+ )+ : personGallery;+ },+ );+ },+ ),+ FileSelectionOverlayBar(+ PeoplePage.overlayType,+ _selectedFiles,+ person: _person,+ ),+ ],),),- body: FutureBuilder<List<EnteFile>>(- future: filesFuture,- builder: (context, snapshot) {- final inheritedSearchFilterData = InheritedSearchFilterData.of(- context,- );- if (snapshot.hasData) {- final personFiles = snapshot.data as List<EnteFile>;- return SelectionState(- selectedFiles: _selectedFiles,- child: Stack(- alignment: Alignment.bottomCenter,- children: [- inheritedSearchFilterData.isHierarchicalSearchable- ? ValueListenableBuilder(- valueListenable: inheritedSearchFilterData- .searchFilterDataProvider!- .isSearchingNotifier,- builder: (context, value, _) {- return value- ? HierarchicalSearchGallery(- tagPrefix: widget.tagPrefix,- selectedFiles: _selectedFiles,- )- : _Gallery(- tagPrefix: widget.tagPrefix,- selectedFiles: _selectedFiles,- personFiles: personFiles,- loadPersonFiles: _loadPersonFiles,- personEntity: _person,- memoryLaneEnabled: featureEnabled,- showTimelineBanner:- showMemoryLaneBanner,- onTimelineTap:- featureEnabled && memoryLaneReady- ? () => unawaited(- _openMemoryLanePage(),- )- : null,- );- },- )- : _Gallery(- tagPrefix: widget.tagPrefix,- selectedFiles: _selectedFiles,- personFiles: personFiles,- loadPersonFiles: _loadPersonFiles,- personEntity: _person,- memoryLaneEnabled: featureEnabled,- showTimelineBanner: showMemoryLaneBanner,- onTimelineTap: featureEnabled && memoryLaneReady- ? () => unawaited(_openMemoryLanePage())- : null,- ),- FileSelectionOverlayBar(- PeoplePage.overlayType,- _selectedFiles,- person: _person,- ),- ],- ),- );- } else if (snapshot.hasError) {- _logger.severe(- "Error: ${snapshot.error} ${snapshot.stackTrace}}",- );- //Need to show an error on the UI here- return const SizedBox.shrink();- } else {- return const Center(child: CircularProgressIndicator());- }- },- ),),),),@@ -346,6 +315,7 @@ class _PeoplePageState extends State<PeoplePage> {}class _Gallery extends StatefulWidget {+ final GalleryAppBarConfig appBar;final String tagPrefix;final SelectedFiles selectedFiles;final List<EnteFile> personFiles;@@ -356,6 +326,7 @@ class _Gallery extends StatefulWidget {final VoidCallback? onTimelineTap;const _Gallery({+ required this.appBar,required this.tagPrefix,required this.selectedFiles,required this.personFiles,@@ -392,6 +363,7 @@ class _GalleryState extends State<_Gallery> {_loggedTimelineImpression = true;}return Gallery(+ appBar: widget.appBar,asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) async {final result = await widget.loadPersonFiles();return Future.value(FileLoadResult(result, false));