From 614db863bcd5049dfcecaef10a5222cdc79f0541 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:49:10 +0530 Subject: [PATCH] [mob] Fix search tab --- .../ui/viewer/search_tab/people_section.dart | 7 +++-- .../lib/ui/viewer/search_tab/search_tab.dart | 27 ++++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/mobile/lib/ui/viewer/search_tab/people_section.dart b/mobile/lib/ui/viewer/search_tab/people_section.dart index f2dba494f5..25ea6bc6ba 100644 --- a/mobile/lib/ui/viewer/search_tab/people_section.dart +++ b/mobile/lib/ui/viewer/search_tab/people_section.dart @@ -13,7 +13,6 @@ import "package:photos/models/search/search_types.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/result/person_face_widget.dart'; import "package:photos/ui/viewer/search/result/search_result_page.dart"; import 'package:photos/ui/viewer/search/result/search_section_all_page.dart'; @@ -215,11 +214,11 @@ class SearchExample extends StatelessWidget { ); } } else if (searchResult is AlbumSearchResult) { - final albumSearchResult = searchResult as AlbumSearchResult; + final albumSearchResult = searchResult as GenericSearchResult; routeToPage( context, - CollectionPage( - albumSearchResult.collectionWithThumbnail, + SearchResultPage( + albumSearchResult, tagPrefix: albumSearchResult.heroTag(), ), ); diff --git a/mobile/lib/ui/viewer/search_tab/search_tab.dart b/mobile/lib/ui/viewer/search_tab/search_tab.dart index bed48f175f..f00c981af3 100644 --- a/mobile/lib/ui/viewer/search_tab/search_tab.dart +++ b/mobile/lib/ui/viewer/search_tab/search_tab.dart @@ -6,6 +6,7 @@ import "package:logging/logging.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"; import "package:photos/models/search/search_types.dart"; import "package:photos/states/all_sections_examples_state.dart"; import "package:photos/ui/common/loading_widget.dart"; @@ -80,16 +81,13 @@ class _AllSearchSectionsState extends State { @override Widget build(BuildContext context) { final searchTypes = SectionType.values.toList(growable: true); - // remove face and content sectionType - // searchTypes.remove(SectionType.face); - // TODO: re-add album section searchTypes.remove(SectionType.content); - searchTypes.remove(SectionType.album); + return Padding( padding: const EdgeInsets.only(top: 8), child: Stack( children: [ - FutureBuilder( + FutureBuilder>>( future: InheritedAllSectionsExamples.of(context) .allSectionsExamplesFuture, builder: (context, snapshot) { @@ -100,6 +98,14 @@ class _AllSearchSectionsState extends State { child: SearchTabEmptyState(), ); } + if (snapshot.data!.length != searchTypes.length) { + return Padding( + padding: const EdgeInsets.only(bottom: 72), + child: Text( + 'Sections length mismatch: ${snapshot.data!.length} != ${searchTypes.length}', + ), + ); + } return ListView.builder( padding: const EdgeInsets.only(bottom: 180), physics: const BouncingScrollPhysics(), @@ -107,17 +113,18 @@ class _AllSearchSectionsState extends State { // ignore: body_might_complete_normally_nullable itemBuilder: (context, index) { switch (searchTypes[index]) { - case SectionType.album: - return AlbumsSection( - snapshot.data!.elementAt(index) - as List, - ); case SectionType.face: return SearchSection( sectionType: SectionType.face, examples: snapshot.data!.elementAt(index), limit: 7, ); + case SectionType.album: + // return const SizedBox.shrink(); + return AlbumsSection( + snapshot.data!.elementAt(index) + as List, + ); case SectionType.moment: return MomentsSection( snapshot.data!.elementAt(index)