π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Add received album filters (#11028)
Aman Raj54d89a846655
diff --git a/mobile/apps/photos/changes/shared-received-album-filters.md b/mobile/apps/photos/changes/shared-received-album-filters.mdnew file mode 100644index 0000000000..44944ffe2d--- /dev/null+++ b/mobile/apps/photos/changes/shared-received-album-filters.md@@ -0,0 +1 @@+- Added separate Shared and Received filters to Albums.diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arbindex 8c484dd75f..66ea6657fb 100644--- a/mobile/apps/photos/lib/l10n/intl_en.arb+++ b/mobile/apps/photos/lib/l10n/intl_en.arb@@ -1540,9 +1540,14 @@"@searchResultPerson": {"description": "Search result subtitle label for person results"},- "searchResultShared": "Shared",- "@searchResultShared": {- "description": "Search result subtitle label for shared-with-you results"+ "shared": "Shared",+ "sharedAlbumsLabel": "Shared",+ "@sharedAlbumsLabel": {+ "description": "Albums tab label for albums shared by you"+ },+ "receivedAlbumsLabel": "Received",+ "@receivedAlbumsLabel": {+ "description": "Albums tab filter label for albums received from other people"},"searchResultUploadedBy": "Uploaded by","@searchResultUploadedBy": {@@ -1723,7 +1728,6 @@"nothingSharedWithYouYet": "Nothing shared with you yet","noAlbumsSharedByYouYet": "No albums shared by you yet","sharedWithYou": "Shared with you",- "sharedByYou": "Shared by you","inviteYourFriendsToEnte": "Invite your friends to Ente","failedToDownloadVideo": "Failed to download video","hiding": "Hiding...",diff --git a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart b/mobile/apps/photos/lib/ui/tabs/albums_tab.dartindex edc352c01b..f157020dfd 100644--- a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart+++ b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart@@ -1,4 +1,5 @@import "dart:async";+import "dart:ui" show BlendMode, ImageFilter;import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";@@ -35,7 +36,7 @@ import "package:photos/ui/viewer/actions/album_selection_overlay_bar.dart";import "package:photos/ui/viewer/actions/delete_empty_albums.dart";import "package:photos/utils/local_settings.dart";-enum _AlbumsFilter { ente, onDevice, shared }+enum _AlbumsFilter { ente, onDevice, shared, received }enum _AlbumsMenuAction { toggleView, name, lastUpdated }@@ -73,6 +74,9 @@ class _AlbumsTabState extends State<AlbumsTab>final ValueNotifier<List<Collection>?> _sharedCollections = ValueNotifier(null,);+ final ValueNotifier<List<Collection>?> _receivedCollections = ValueNotifier(+ null,+ );final ValueNotifier<bool> _shouldShowDeleteEmptyAlbums = ValueNotifier(false);late final ValueNotifier<AlbumViewType> _viewType = ValueNotifier(localSettings.albumViewType(),@@ -161,6 +165,7 @@ class _AlbumsTabState extends State<AlbumsTab>_loggedOutEvent = Bus.instance.on<UserLoggedOutEvent>().listen((_) {_enteCollections.value = null;_sharedCollections.value = null;+ _receivedCollections.value = null;});_tabChangedEvent = Bus.instance.on<TabChangedEvent>().listen(_handleTabChanged,@@ -225,6 +230,7 @@ class _AlbumsTabState extends State<AlbumsTab>if (!Configuration.instance.hasConfiguredAccount()) {_enteCollections.value = <Collection>[];_sharedCollections.value = <Collection>[];+ _receivedCollections.value = <Collection>[];_shouldShowDeleteEmptyAlbums.value = false;return;}@@ -281,7 +287,8 @@ class _AlbumsTabState extends State<AlbumsTab>Future<void> _loadSharedCollections() async {final shared = await CollectionsService.instance.getSharedCollections();if (!mounted) return;- _sharedCollections.value = shared.incoming;+ _sharedCollections.value = shared.outgoing;+ _receivedCollections.value = shared.incoming;}void _selectFilter(_AlbumsFilter filter) {@@ -487,17 +494,24 @@ class _AlbumsTabState extends State<AlbumsTab>final enteCollections = _enteCollections.value;final sharedCollections = _sharedCollections.value;+ final receivedCollections = _receivedCollections.value;final filteredEnteCollections = enteCollections == null? null: _filterCollectionsByQuery(enteCollections);final filteredSharedCollections = sharedCollections == null? null: _filterCollectionsByQuery(sharedCollections);+ final filteredReceivedCollections = receivedCollections == null+ ? null+ : _filterCollectionsByQuery(receivedCollections);final hasRemoteCollections =(filteredEnteCollections?.isNotEmpty ?? false) ||- (filteredSharedCollections?.isNotEmpty ?? false);+ (filteredSharedCollections?.isNotEmpty ?? false) ||+ (filteredReceivedCollections?.isNotEmpty ?? false);final hasFinishedLoadingRemoteCollections =- enteCollections != null && sharedCollections != null;+ enteCollections != null &&+ sharedCollections != null &&+ receivedCollections != null;final shouldShowDeviceSearchState =hasFinishedLoadingRemoteCollections && !hasRemoteCollections;@@ -523,10 +537,15 @@ class _AlbumsTabState extends State<AlbumsTab>: null,),..._buildCollectionSearchSectionSlivers(- title: strings.searchResultShared,+ title: strings.sharedAlbumsLabel,tag: "album_search_shared",collections: filteredSharedCollections,),+ ..._buildCollectionSearchSectionSlivers(+ title: strings.receivedAlbumsLabel,+ tag: "album_search_received",+ collections: filteredReceivedCollections,+ ),SliverToBoxAdapter(child: SizedBox(height: bottomPadding)),],);@@ -549,6 +568,10 @@ class _AlbumsTabState extends State<AlbumsTab>collections = _sharedCollections.value;showCreateAlbum = false;emptyState = const SharedEmptyState();+ case _AlbumsFilter.received:+ collections = _receivedCollections.value;+ showCreateAlbum = false;+ emptyState = const SharedEmptyState();case _AlbumsFilter.onDevice:return DeviceFolderVerticalGridSliver(searchQuery: _searchQuery.trim(),@@ -583,6 +606,10 @@ class _AlbumsTabState extends State<AlbumsTab>_enteCollections.value == null ? "ente_loading" : "ente_ready",_AlbumsFilter.shared =>_sharedCollections.value == null ? "shared_loading" : "shared_ready",+ _AlbumsFilter.received =>+ _receivedCollections.value == null+ ? "received_loading"+ : "received_ready",_AlbumsFilter.onDevice => "device",};@@ -726,6 +753,7 @@ class _AlbumsTabState extends State<AlbumsTab>_filter.dispose();_enteCollections.dispose();_sharedCollections.dispose();+ _receivedCollections.dispose();_shouldShowDeleteEmptyAlbums.dispose();_viewType.dispose();_sortKey.dispose();@@ -866,7 +894,7 @@ class _AlbumsTabState extends State<AlbumsTab>: Padding(key: const ValueKey("album_filters"),padding: const EdgeInsets.symmetric(- horizontal: 8,+ horizontal: 16,vertical: 8,),child: Row(@@ -878,59 +906,71 @@ class _AlbumsTabState extends State<AlbumsTab>final effectiveFilter = localGalleryMode? _AlbumsFilter.onDevice: selected;- return SingleChildScrollView(- scrollDirection: Axis.horizontal,- physics: const BouncingScrollPhysics(),- child: Row(- children: [- if (!localGalleryMode) ...[- _AlbumsFilterChip(- label: strings.ente,- selected:- effectiveFilter ==- _AlbumsFilter.ente,- onTap: () => _selectFilter(- _AlbumsFilter.ente,- ),- ),- const SizedBox(width: 8),- ],- _AlbumsFilterChip(- label: strings.onDevice,- selected:- effectiveFilter ==- _AlbumsFilter.onDevice,- onTap: () => _selectFilter(- _AlbumsFilter.onDevice,- ),+ return Stack(+ children: [+ SingleChildScrollView(+ scrollDirection: Axis.horizontal,+ physics:+ const BouncingScrollPhysics(),+ padding: const EdgeInsets.only(+ right: 44,),- if (!localGalleryMode) ...[- const SizedBox(width: 8),- _AlbumsFilterChip(- label: strings.searchResultShared,- selected:- effectiveFilter ==- _AlbumsFilter.shared,- onTap: () => _selectFilter(- _AlbumsFilter.shared,- ),- ),- const SizedBox(width: 8),- _AlbumsFilterChip(- label: strings.more,- selected: false,- trailing: const Icon(- Icons.keyboard_arrow_down,- size: 18,+ child: Row(+ children: [+ if (!localGalleryMode) ...[+ _AlbumsFilterChip(+ label: strings.ente,+ selected:+ effectiveFilter ==+ _AlbumsFilter.ente,+ onTap: () => _selectFilter(+ _AlbumsFilter.ente,+ ),+ ),+ const SizedBox(width: 8),+ ],+ _AlbumsFilterChip(+ label: strings.onDevice,+ selected:+ effectiveFilter ==+ _AlbumsFilter.onDevice,+ onTap: () => _selectFilter(+ _AlbumsFilter.onDevice,+ ),),- onTap: () =>- showAlbumsManageSheet(- context,+ if (!localGalleryMode) ...[+ const SizedBox(width: 8),+ _AlbumsFilterChip(+ label:+ strings.sharedAlbumsLabel,+ selected:+ effectiveFilter ==+ _AlbumsFilter.shared,+ onTap: () => _selectFilter(+ _AlbumsFilter.shared,+ ),+ ),+ const SizedBox(width: 8),+ _AlbumsFilterChip(+ label: strings+ .receivedAlbumsLabel,+ selected:+ effectiveFilter ==+ _AlbumsFilter.received,+ onTap: () => _selectFilter(+ _AlbumsFilter.received,),- ),- ],- ],- ),+ ),+ ],+ ],+ ),+ ),+ _AlbumsMoreButtonOverlay(+ tooltip: strings.more,+ onTap: () =>+ showAlbumsManageSheet(context),+ ),+ ],);},),@@ -946,6 +986,7 @@ class _AlbumsTabState extends State<AlbumsTab>_filter,_enteCollections,_sharedCollections,+ _receivedCollections,_shouldShowDeleteEmptyAlbums,_viewType,_sortKey,@@ -994,6 +1035,7 @@ class _AlbumsTabState extends State<AlbumsTab>_filter,_enteCollections,_sharedCollections,+ _receivedCollections,]),builder: (context, _) {final filter = _effectiveFilter;@@ -1004,8 +1046,11 @@ class _AlbumsTabState extends State<AlbumsTab>sectionType = UISectionType.homeCollections;collections = _enteCollections.value;case _AlbumsFilter.shared:- sectionType = UISectionType.incomingCollections;+ sectionType = UISectionType.outgoingCollections;collections = _sharedCollections.value;+ case _AlbumsFilter.received:+ sectionType = UISectionType.incomingCollections;+ collections = _receivedCollections.value;case _AlbumsFilter.onDevice:return const SizedBox.shrink();}@@ -1035,19 +1080,16 @@ class _AlbumsFilterChip extends StatelessWidget {required this.label,required this.selected,required this.onTap,- this.trailing,});final String label;final bool selected;final VoidCallback onTap;- final Widget? trailing;@overrideWidget build(BuildContext context) {return TagChipComponent(label: label,- trailing: trailing,state: selected? TagChipComponentState.selected: TagChipComponentState.unselected,@@ -1055,3 +1097,68 @@ class _AlbumsFilterChip extends StatelessWidget {);}}++class _AlbumsMoreButtonOverlay extends StatelessWidget {+ const _AlbumsMoreButtonOverlay({required this.tooltip, required this.onTap});++ final String tooltip;+ final FutureOr<void> Function() onTap;++ @override+ Widget build(BuildContext context) {+ final componentColors = context.componentColors;+ final maskColor = componentColors.backgroundBase;++ return Positioned.fill(+ child: Stack(+ children: [+ Positioned(+ top: 0,+ right: 0,+ bottom: 0,+ child: IgnorePointer(+ child: ShaderMask(+ blendMode: BlendMode.dstIn,+ shaderCallback: (bounds) => LinearGradient(+ begin: Alignment.centerRight,+ end: Alignment.centerLeft,+ colors: [+ maskColor,+ maskColor,+ maskColor.withValues(alpha: 0),+ ],+ stops: const [0, 0.48, 1],+ ).createShader(bounds),+ child: SizedBox(+ width: 72,+ child: ClipRect(+ child: BackdropFilter(+ filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),+ child: ColoredBox(+ color: componentColors.backgroundBase.withValues(+ alpha: 0.66,+ ),+ child: const SizedBox.expand(),+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ Positioned(+ top: 4,+ right: 0,+ child: IconButtonComponent(+ variant: IconButtonComponentVariant.primary,+ shouldSurfaceExecutionStates: false,+ tooltip: tooltip,+ icon: const Icon(Icons.keyboard_arrow_down, size: 18),+ onTap: onTap,+ ),+ ),+ ],+ ),+ );+ }+}diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/search_result_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/result/search_result_widget.dartindex 75ab8e5979..c0c026bb36 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/search_result_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/search_result_widget.dart@@ -122,7 +122,7 @@ class SearchResultWidget extends StatelessWidget {case ResultType.faces:return localizations.searchResultPerson;case ResultType.shared:- return localizations.searchResultShared;+ return localizations.shared;case ResultType.uploader:return localizations.searchResultUploadedBy;case ResultType.cameraMake:diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart b/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dartindex b4b6deb087..61903409fd 100644--- a/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart@@ -315,7 +315,7 @@ String _sectionTitle(BuildContext context, _SearchResultsSection section) {case _SearchResultsSection.people:return AppLocalizations.of(context).people;case _SearchResultsSection.shared:- return AppLocalizations.of(context).searchResultShared;+ return AppLocalizations.of(context).shared;case _SearchResultsSection.albums:return AppLocalizations.of(context).albums;case _SearchResultsSection.magic: