π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Create a map of searchType to suggested queries in NoResultWidget
ashilkn92458d2e0384
diff --git a/lib/ui/search_tab.dart b/lib/ui/search_tab.dartindex cfebbd1d72..466162f6b7 100644--- a/lib/ui/search_tab.dart+++ b/lib/ui/search_tab.dart@@ -8,6 +8,8 @@ import "package:photos/ui/viewer/search/search_section.dart";import "package:photos/ui/viewer/search/search_suggestions.dart";import "package:photos/ui/viewer/search/search_widget_new.dart";+late Future<List<List<SearchResult>>> allSectionsExamples;+class SearchTab extends StatefulWidget {const SearchTab({Key? key}) : super(key: key);@@ -57,7 +59,6 @@ class AllSearchSections extends StatefulWidget {}class _AllSearchSectionsState extends State<AllSearchSections> {- late Future<List<List<SearchResult>>> allSectionsExamples;late List<Future<List<SearchResult>>> sectionExamples;static const _limit = 7;diff --git a/lib/ui/viewer/search/result/no_result_widget.dart b/lib/ui/viewer/search/result/no_result_widget.dartindex c4d027eac9..9f7cc0b9dd 100644--- a/lib/ui/viewer/search/result/no_result_widget.dart+++ b/lib/ui/viewer/search/result/no_result_widget.dart@@ -1,74 +1,39 @@import 'package:flutter/material.dart';-import 'package:photos/ente_theme_data.dart';-import "package:photos/generated/l10n.dart";+import "package:photos/models/search/search_types.dart";+import "package:photos/ui/search_tab.dart";-class NoResultWidget extends StatelessWidget {+class NoResultWidget extends StatefulWidget {const NoResultWidget({Key? key}) : super(key: key);+ @override+ State<NoResultWidget> createState() => _NoResultWidgetState();+}++class _NoResultWidgetState extends State<NoResultWidget> {+ late final List<SectionType> searchTypes;+ final searchTypeToSearchSuggestion = <String, List<String>>{};+ @override+ void initState() {+ super.initState();+ searchTypes = SectionType.values.toList(growable: true);+ // remove face and content sectionType+ searchTypes.remove(SectionType.face);+ searchTypes.remove(SectionType.content);+ allSectionsExamples.then((value) {+ for (int i = 0; i < searchTypes.length; i++) {+ final querySuggestions = <String>[];+ for (int j = 0; j < 2 && j < value[i].length; j++) {+ querySuggestions.add(value[i][j].name());+ }+ //todo: remove keys with empty list+ searchTypeToSearchSuggestion+ .addAll({searchTypes[i].sectionTitle(context): querySuggestions});+ }+ });+ }+@overrideWidget build(BuildContext context) {- return Container(- width: double.infinity,- margin: const EdgeInsets.only(top: 6),- padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),- decoration: BoxDecoration(- color: Theme.of(context).colorScheme.searchResultsColor,- borderRadius: BorderRadius.circular(8),- boxShadow: [- BoxShadow(- color: Colors.black.withOpacity(0.2),- spreadRadius: -3,- blurRadius: 6,- offset: const Offset(0, 8),- ),- ],- ),- child: Container(- margin: const EdgeInsets.symmetric(horizontal: 8),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Container(- margin: const EdgeInsets.only(top: 8),- child: Text(- S.of(context).noResultsFound,- textAlign: TextAlign.left,- style: const TextStyle(- fontSize: 16,- ),- ),- ),- Container(- margin: const EdgeInsets.only(top: 16),- child: Text(- S.of(context).youCanTrySearchingForADifferentQuery,- style: TextStyle(- fontSize: 14,- color: Theme.of(context)- .colorScheme- .defaultTextColor- .withOpacity(0.5),- height: 1.5,- ),- ),- ),- Container(- margin: const EdgeInsets.only(bottom: 20, top: 12),- child: Text(- S.of(context).searchByExamples,- style: TextStyle(- fontSize: 14,- color: Theme.of(context)- .colorScheme- .defaultTextColor- .withOpacity(0.5),- height: 1.5,- ),- ),- ),- ],- ),- ),- );+ return const SizedBox.shrink();}}