π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
remove albums section from the search tab
AmanRajSinghMourya6b1bd7cc098b
diff --git a/mobile/apps/photos/lib/states/all_sections_examples_state.dart b/mobile/apps/photos/lib/states/all_sections_examples_state.dartindex b81f50ff67..d0a6ad676b 100644--- a/mobile/apps/photos/lib/states/all_sections_examples_state.dart+++ b/mobile/apps/photos/lib/states/all_sections_examples_state.dart@@ -106,9 +106,11 @@ class _AllSectionsExamplesProviderStatefinal allSectionsExamples = <Future<List<SearchResult>>>[];for (SectionType sectionType in SectionType.values) {// Contacts section have been moved to shared collections tab- // temporarily from search tab. So we can skip computing data here- // since 'allSectionsExamples' is for search tab sections only.- if (sectionType == SectionType.contacts) {+ // temporarily from search tab. Albums are also not shown in the+ // search tab. So we can skip computing data here since+ // 'allSectionsExamples' is for search tab sections only.+ if (sectionType == SectionType.contacts ||+ sectionType == SectionType.album) {allSectionsExamples.add(Future.value([]));} else {allSectionsExamples.add(diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/albums_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/albums_section.dartdeleted file mode 100644index 1d573c2132..0000000000--- a/mobile/apps/photos/lib/ui/viewer/search_tab/albums_section.dart+++ /dev/null@@ -1,266 +0,0 @@-import "dart:async";--import "package:dotted_border/dotted_border.dart";-import "package:ente_pure_utils/ente_pure_utils.dart";-import "package:flutter/material.dart";-import "package:photos/core/constants.dart";-import "package:photos/events/event.dart";-import "package:photos/generated/l10n.dart";-import "package:photos/models/search/album_search_result.dart";-import "package:photos/models/search/recent_searches.dart";-import "package:photos/models/search/search_types.dart";-import "package:photos/services/collections_service.dart";-import "package:photos/theme/ente_theme.dart";-import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";-import "package:photos/ui/viewer/file/thumbnail_widget.dart";-import "package:photos/ui/viewer/gallery/collection_page.dart";-import "package:photos/ui/viewer/search/search_section_cta.dart";-import "package:photos/ui/viewer/search_tab/section_header.dart";--class AlbumsSection extends StatefulWidget {- final List<AlbumSearchResult> albumSearchResults;- const AlbumsSection(this.albumSearchResults, {super.key});-- @override- State<AlbumsSection> createState() => _AlbumsSectionState();-}--class _AlbumsSectionState extends State<AlbumsSection> {- late List<AlbumSearchResult> _albumSearchResults;- final streamSubscriptions = <StreamSubscription>[];-- @override- void initState() {- super.initState();- _albumSearchResults = widget.albumSearchResults;-- final streamsToListenTo = SectionType.album.sectionUpdateEvents();- for (Stream<Event> stream in streamsToListenTo) {- streamSubscriptions.add(- stream.listen((event) async {- _albumSearchResults = (await SectionType.album.getData(- context,- limit: kSearchSectionLimit,- )) as List<AlbumSearchResult>;- setState(() {});- }),- );- }- }-- @override- void dispose() {- for (var subscriptions in streamSubscriptions) {- subscriptions.cancel();- }- super.dispose();- }-- @override- void didUpdateWidget(covariant AlbumsSection oldWidget) {- super.didUpdateWidget(oldWidget);- _albumSearchResults = widget.albumSearchResults;- }-- @override- Widget build(BuildContext context) {- if (_albumSearchResults.isEmpty) {- final textTheme = getEnteTextTheme(context);- return Padding(- padding: const EdgeInsets.only(left: 12, right: 8),- child: Row(- children: [- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- SectionType.album.sectionTitle(context),- style: textTheme.largeBold,- ),- const SizedBox(height: 24),- Padding(- padding: const EdgeInsets.only(left: 4),- child: Text(- SectionType.album.getEmptyStateText(context),- style: textTheme.smallMuted,- ),- ),- ],- ),- ),- const SizedBox(width: 8),- const SearchSectionEmptyCTAIcon(SectionType.album),- ],- ),- );- } else {- final recommendations = <Widget>[- ..._albumSearchResults.map(- (albumSearchResult) => AlbumRecommendation(albumSearchResult),- ),- const AlbumCTA(),- ];- return Padding(- padding: const EdgeInsets.symmetric(vertical: 8),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- SectionHeader(- SectionType.album,- hasMore: (_albumSearchResults.length >= kSearchSectionLimit - 1),- ),- const SizedBox(height: 2),- SizedBox(- child: SingleChildScrollView(- padding: const EdgeInsets.symmetric(horizontal: 4.5),- physics: const BouncingScrollPhysics(),- scrollDirection: Axis.horizontal,- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: recommendations,- ),- ),- ),- ],- ),- );- }- }-}--class AlbumRecommendation extends StatelessWidget {- static const _width = 100.0;- final AlbumSearchResult albumSearchResult;- const AlbumRecommendation(this.albumSearchResult, {super.key});-- @override- Widget build(BuildContext context) {- final heroTag = albumSearchResult.heroTag() +- (albumSearchResult.previewThumbnail()?.tag ?? "");- final enteTextTheme = getEnteTextTheme(context);- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 2.5),- child: GestureDetector(- onTap: () {- RecentSearches().add(albumSearchResult.name());- routeToPage(- context,- CollectionPage(- albumSearchResult.collectionWithThumbnail,- tagPrefix: albumSearchResult.heroTag(),- ),- );- },- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- ClipRRect(- borderRadius: BorderRadius.circular(8),- child: SizedBox(- width: _width,- height: 100,- child: albumSearchResult.previewThumbnail() != null- ? Hero(- tag: heroTag,- child: ThumbnailWidget(- albumSearchResult.previewThumbnail()!,- shouldShowArchiveStatus: false,- shouldShowSyncStatus: false,- ),- )- : const NoThumbnailWidget(- borderRadius: 8,- ),- ),- ),- const SizedBox(height: 6),- ConstrainedBox(- constraints: const BoxConstraints(maxWidth: _width),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisAlignment: MainAxisAlignment.center,- children: [- Text(- albumSearchResult.name(),- style: enteTextTheme.small,- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),- const SizedBox(height: 2),- FutureBuilder(- future: CollectionsService.instance.getFileCount(- albumSearchResult.collectionWithThumbnail.collection,- ),- builder: (context, snapshot) {- if (snapshot.hasData &&- snapshot.data != null &&- snapshot.data != 0) {- return Text(- snapshot.data.toString(),- style: enteTextTheme.miniMuted,- );- } else {- return const SizedBox.shrink();- }- },- ),- ],- ),- ),- ],- ),- ),- );- }-}--class AlbumCTA extends StatelessWidget {- const AlbumCTA({super.key});-- @override- Widget build(BuildContext context) {- final enteColorScheme = getEnteColorScheme(context);- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 2.5),- child: GestureDetector(- onTap: SectionType.album.ctaOnTap(context),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- ClipRRect(- borderRadius: BorderRadius.circular(8),- child: Container(- color: Theme.of(context).brightness == Brightness.light- ? enteColorScheme.backdropBase- : enteColorScheme.backdropFaint,- height: 100,- width: 100,- child: DottedBorder(- borderType: BorderType.RRect,- strokeWidth: 1.5,- borderPadding: const EdgeInsets.all(0.75),- dashPattern: const [3.75, 3.75],- radius: const Radius.circular(8),- padding: EdgeInsets.zero,- color: enteColorScheme.strokeFaint,- child: Center(- child: Icon(- Icons.add,- color: enteColorScheme.strokeFaint,- ),- ),- ),- ),- ),- const SizedBox(height: 2),- Text(- AppLocalizations.of(context).addNew,- style: getEnteTextTheme(context).smallFaint,- ),- ],- ),- ),- );- }-}diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/device_albums_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/device_albums_section.dartdeleted file mode 100644index 11b07d8cf3..0000000000--- a/mobile/apps/photos/lib/ui/viewer/search_tab/device_albums_section.dart+++ /dev/null@@ -1,179 +0,0 @@-import "dart:async";--import "package:ente_pure_utils/ente_pure_utils.dart";-import "package:flutter/material.dart";-import "package:photos/core/event_bus.dart";-import "package:photos/db/device_files_db.dart";-import "package:photos/db/files_db.dart";-import "package:photos/events/backup_folders_updated_event.dart";-import "package:photos/events/local_photos_updated_event.dart";-import "package:photos/generated/l10n.dart";-import "package:photos/models/device_collection.dart";-import "package:photos/theme/ente_theme.dart";-import "package:photos/ui/viewer/file/thumbnail_widget.dart";-import "package:photos/ui/viewer/gallery/device_folder_page.dart";--class DeviceAlbumsSection extends StatefulWidget {- const DeviceAlbumsSection({super.key});-- @override- State<DeviceAlbumsSection> createState() => _DeviceAlbumsSectionState();-}--class _DeviceAlbumsSectionState extends State<DeviceAlbumsSection> {- StreamSubscription<BackupFoldersUpdatedEvent>? _backupFoldersUpdatedEvent;- StreamSubscription<LocalPhotosUpdatedEvent>? _localFilesSubscription;- final _debouncer = Debouncer(- const Duration(seconds: 2),- executionInterval: const Duration(seconds: 5),- leading: true,- );-- @override- void initState() {- super.initState();- _backupFoldersUpdatedEvent =- Bus.instance.on<BackupFoldersUpdatedEvent>().listen((event) {- if (mounted) {- setState(() {});- }- });- _localFilesSubscription =- Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event) {- _debouncer.run(() async {- if (mounted) {- setState(() {});- }- });- });- }-- @override- void dispose() {- _backupFoldersUpdatedEvent?.cancel();- _localFilesSubscription?.cancel();- _debouncer.cancelDebounceTimer();- super.dispose();- }-- @override- Widget build(BuildContext context) {- return FutureBuilder<List<DeviceCollection>>(- future:- FilesDB.instance.getDeviceCollections(includeCoverThumbnail: true),- builder: (context, snapshot) {- if (snapshot.hasData && snapshot.data!.isNotEmpty) {- final deviceCollections = snapshot.data!;- return Padding(- padding: const EdgeInsets.symmetric(vertical: 8),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- _buildHeader(context),- const SizedBox(height: 2),- SizedBox(- child: SingleChildScrollView(- padding: const EdgeInsets.symmetric(horizontal: 4.5),- physics: const BouncingScrollPhysics(),- scrollDirection: Axis.horizontal,- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: deviceCollections- .map(- (dc) => _DeviceAlbumRecommendation(dc),- )- .toList(),- ),- ),- ),- ],- ),- );- }- return const SizedBox.shrink();- },- );- }-- Widget _buildHeader(BuildContext context) {- return Padding(- padding: const EdgeInsets.all(12),- child: Text(- AppLocalizations.of(context).onDevice,- style: getEnteTextTheme(context).largeBold,- ),- );- }-}--class _DeviceAlbumRecommendation extends StatelessWidget {- static const _width = 100.0;- final DeviceCollection deviceCollection;-- const _DeviceAlbumRecommendation(this.deviceCollection);-- @override- Widget build(BuildContext context) {- final enteTextTheme = getEnteTextTheme(context);- final heroTag =- "device_folder:${deviceCollection.name}${deviceCollection.thumbnail?.tag ?? ""}";-- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 2.5),- child: GestureDetector(- onTap: () {- routeToPage(context, DeviceFolderPage(deviceCollection));- },- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- ClipRRect(- borderRadius: BorderRadius.circular(8),- child: SizedBox(- width: _width,- height: 100,- child: deviceCollection.thumbnail != null- ? Hero(- tag: heroTag,- child: ThumbnailWidget(- deviceCollection.thumbnail!,- shouldShowArchiveStatus: false,- shouldShowSyncStatus: false,- ),- )- : Container(- color: getEnteColorScheme(context).fillFaint,- child: Icon(- Icons.folder_outlined,- color: getEnteColorScheme(context).strokeMuted,- ),- ),- ),- ),- const SizedBox(height: 6),- ConstrainedBox(- constraints: const BoxConstraints(maxWidth: _width),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisAlignment: MainAxisAlignment.center,- children: [- Text(- deviceCollection.name,- style: enteTextTheme.small,- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),- const SizedBox(height: 2),- Text(- deviceCollection.count.toString(),- style: enteTextTheme.miniMuted,- ),- ],- ),- ),- ],- ),- ),- );- }-}diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dartindex cec4f66fe7..1d876275dd 100644--- a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart@@ -4,7 +4,6 @@ import "package:flutter/material.dart";import "package:flutter_animate/flutter_animate.dart";import "package:logging/logging.dart";import "package:photos/generated/intl/app_localizations.dart";-import "package:photos/models/search/album_search_result.dart";import "package:photos/models/search/generic_search_result.dart";import "package:photos/models/search/index_of_indexed_stack.dart";import "package:photos/models/search/search_result.dart";@@ -20,8 +19,6 @@ import "package:photos/ui/viewer/search/result/no_result_widget.dart";import "package:photos/ui/viewer/search/search_suggestions.dart";import "package:photos/ui/viewer/search/search_widget.dart";import "package:photos/ui/viewer/search/tab_empty_state.dart";-import "package:photos/ui/viewer/search_tab/albums_section.dart";-import "package:photos/ui/viewer/search_tab/device_albums_section.dart";import "package:photos/ui/viewer/search_tab/file_type_section.dart";import "package:photos/ui/viewer/search_tab/locations_section.dart";import "package:photos/ui/viewer/search_tab/magic_section.dart";@@ -117,8 +114,6 @@ class _AllSearchSectionsState extends State<AllSearchSections> {.allSectionsExamplesFuture,builder: (context, snapshot) {if (snapshot.hasData && snapshot.data!.isNotEmpty) {- // In offline mode, skip the empty state check since DeviceAlbumsSection- // fetches its own data and may have albums to showif (!isOfflineMode &&snapshot.data!.every((element) => element.isEmpty)) {return const Padding(@@ -166,13 +161,7 @@ class _AllSearchSectionsState extends State<AllSearchSections> {as List<GenericSearchResult>,);case SectionType.album:- if (isOfflineMode) {- return const DeviceAlbumsSection();- }- return AlbumsSection(- snapshot.data!.elementAt(sectionIndex)- as List<AlbumSearchResult>,- );+ return const SizedBox.shrink();case SectionType.ritual:if (isOfflineMode) {return const SizedBox.shrink();