瀏覽代碼

[mob] Fix search tab

Neeraj Gupta 1 年之前
父節點
當前提交
614db863bc
共有 2 個文件被更改,包括 20 次插入14 次删除
  1. 3 4
      mobile/lib/ui/viewer/search_tab/people_section.dart
  2. 17 10
      mobile/lib/ui/viewer/search_tab/search_tab.dart

+ 3 - 4
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/theme/ente_theme.dart";
 import "package:photos/ui/viewer/file/no_thumbnail_widget.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/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/person_face_widget.dart';
 import "package:photos/ui/viewer/search/result/search_result_page.dart";
 import "package:photos/ui/viewer/search/result/search_result_page.dart";
 import 'package:photos/ui/viewer/search/result/search_section_all_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) {
         } else if (searchResult is AlbumSearchResult) {
-          final albumSearchResult = searchResult as AlbumSearchResult;
+          final albumSearchResult = searchResult as GenericSearchResult;
           routeToPage(
           routeToPage(
             context,
             context,
-            CollectionPage(
-              albumSearchResult.collectionWithThumbnail,
+            SearchResultPage(
+              albumSearchResult,
               tagPrefix: albumSearchResult.heroTag(),
               tagPrefix: albumSearchResult.heroTag(),
             ),
             ),
           );
           );

+ 17 - 10
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/album_search_result.dart";
 import "package:photos/models/search/generic_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/index_of_indexed_stack.dart";
+import "package:photos/models/search/search_result.dart";
 import "package:photos/models/search/search_types.dart";
 import "package:photos/models/search/search_types.dart";
 import "package:photos/states/all_sections_examples_state.dart";
 import "package:photos/states/all_sections_examples_state.dart";
 import "package:photos/ui/common/loading_widget.dart";
 import "package:photos/ui/common/loading_widget.dart";
@@ -80,16 +81,13 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
     final searchTypes = SectionType.values.toList(growable: true);
     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.content);
-    searchTypes.remove(SectionType.album);
+
     return Padding(
     return Padding(
       padding: const EdgeInsets.only(top: 8),
       padding: const EdgeInsets.only(top: 8),
       child: Stack(
       child: Stack(
         children: [
         children: [
-          FutureBuilder(
+          FutureBuilder<List<List<SearchResult>>>(
             future: InheritedAllSectionsExamples.of(context)
             future: InheritedAllSectionsExamples.of(context)
                 .allSectionsExamplesFuture,
                 .allSectionsExamplesFuture,
             builder: (context, snapshot) {
             builder: (context, snapshot) {
@@ -100,6 +98,14 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
                     child: SearchTabEmptyState(),
                     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(
                 return ListView.builder(
                   padding: const EdgeInsets.only(bottom: 180),
                   padding: const EdgeInsets.only(bottom: 180),
                   physics: const BouncingScrollPhysics(),
                   physics: const BouncingScrollPhysics(),
@@ -107,17 +113,18 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
                   // ignore: body_might_complete_normally_nullable
                   // ignore: body_might_complete_normally_nullable
                   itemBuilder: (context, index) {
                   itemBuilder: (context, index) {
                     switch (searchTypes[index]) {
                     switch (searchTypes[index]) {
-                      case SectionType.album:
-                        return AlbumsSection(
-                          snapshot.data!.elementAt(index)
-                              as List<AlbumSearchResult>,
-                        );
                       case SectionType.face:
                       case SectionType.face:
                         return SearchSection(
                         return SearchSection(
                           sectionType: SectionType.face,
                           sectionType: SectionType.face,
                           examples: snapshot.data!.elementAt(index),
                           examples: snapshot.data!.elementAt(index),
                           limit: 7,
                           limit: 7,
                         );
                         );
+                      case SectionType.album:
+                        // return const SizedBox.shrink();
+                        return AlbumsSection(
+                          snapshot.data!.elementAt(index)
+                              as List<AlbumSearchResult>,
+                        );
                       case SectionType.moment:
                       case SectionType.moment:
                         return MomentsSection(
                         return MomentsSection(
                           snapshot.data!.elementAt(index)
                           snapshot.data!.elementAt(index)