π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use a separate widget to enclose all search sections
ashilkn62924e2d40e4
diff --git a/lib/models/search/search_types.dart b/lib/models/search/search_types.dartindex e435241c0b..0f52e0d65c 100644--- a/lib/models/search/search_types.dart+++ b/lib/models/search/search_types.dart@@ -1,5 +1,8 @@import "package:flutter/material.dart";import "package:photos/generated/l10n.dart";+import "package:photos/models/search/generic_search_result.dart";+import "package:photos/models/search/search_result.dart";+import "package:photos/services/search_service.dart";enum ResultType {collection,@@ -157,4 +160,32 @@ extension SectionTypeExtensions on SectionType {return null;}}++ Future<List<SearchResult>> getData({int? limit}) {+ switch (this) {+ case SectionType.face:+ return Future.value([GenericSearchResult(ResultType.file, "", [])]);++ case SectionType.content:+ return Future.value([GenericSearchResult(ResultType.file, "", [])]);++ case SectionType.moment:+ return Future.value([GenericSearchResult(ResultType.file, "", [])]);++ case SectionType.location:+ return SearchService.instance.getAllLocationTags(limit);++ case SectionType.people:+ return Future.value([GenericSearchResult(ResultType.file, "", [])]);++ case SectionType.album:+ return Future.value([GenericSearchResult(ResultType.file, "", [])]);++ case SectionType.fileTypesAndExtension:+ return Future.value([GenericSearchResult(ResultType.file, "", [])]);++ case SectionType.fileCaption:+ return Future.value([GenericSearchResult(ResultType.file, "", [])]);+ }+ }}diff --git a/lib/ui/search_tab.dart b/lib/ui/search_tab.dartindex fc8fd4ac8e..3467597e47 100644--- a/lib/ui/search_tab.dart+++ b/lib/ui/search_tab.dart@@ -1,5 +1,7 @@import "package:flutter/material.dart";+import "package:photos/models/search/search_result.dart";import "package:photos/models/search/search_types.dart";+import "package:photos/ui/common/loading_widget.dart";import "package:photos/ui/viewer/search/search_section.dart";import "package:photos/ui/viewer/search/search_widget.dart";@@ -18,33 +20,19 @@ class _SearchTabState extends State<SearchTab> {@overrideWidget build(BuildContext context) {- // Return a ListViewBuilder for value search_types.dart SectionType,- // render search section for each value- final searchTypes = SectionType.values.toList(growable: true);- // remove face and content sectionType- searchTypes.remove(SectionType.face);- searchTypes.remove(SectionType.content);-- return Padding(- padding: const EdgeInsets.only(+ return const Padding(+ padding: EdgeInsets.only(left: 12.0,right: 12.0,bottom: 100,),child: Column(children: [- const Align(+ Align(alignment: Alignment.topRight,child: SearchIconWidget(),),- Expanded(- child: ListView.builder(- itemCount: searchTypes.length,- itemBuilder: (context, index) {- return SearchSection(sectionType: searchTypes[index]);- },- ),- ),+ AllSearchSections(),],),);@@ -58,3 +46,49 @@ class _SearchTabState extends State<SearchTab> {setState(() => {});}}++class AllSearchSections extends StatefulWidget {+ const AllSearchSections({super.key});++ @override+ State<AllSearchSections> createState() => _AllSearchSectionsState();+}++class _AllSearchSectionsState extends State<AllSearchSections> {+ late Future<List<List<SearchResult>>> allFutures;+ final locationTags = SectionType.location.getData(limit: 3);+ @override+ void initState() {+ allFutures = Future.wait<List<SearchResult>>([locationTags]);+ super.initState();+ }++ @override+ Widget build(BuildContext context) {+ // Return a ListViewBuilder for value search_types.dart SectionType,+ // render search section for each value+ final searchTypes = SectionType.values.toList(growable: true);+ // remove face and content sectionType+ searchTypes.remove(SectionType.face);+ searchTypes.remove(SectionType.content);+ return Expanded(+ child: FutureBuilder(+ future: allFutures,+ builder: (context, snapshot) {+ if (snapshot.hasData) {+ return ListView.builder(+ itemCount: searchTypes.length,+ itemBuilder: (context, index) {+ return SearchSection(sectionType: searchTypes[index]);+ },+ );+ } else if (snapshot.hasError) {+ return const EnteLoadingWidget();+ } else {+ return const EnteLoadingWidget();+ }+ },+ ),+ );+ }+}