Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

use IndexedStack to preserve state of all search sections screen when searching

ashilknafef0db1fdd4
diff --git a/lib/ui/search_tab.dart b/lib/ui/search_tab.dart
index 6f4e317346..1e032b5203 100644
--- a/lib/ui/search_tab.dart
+++ b/lib/ui/search_tab.dart
@@ -20,22 +20,35 @@ class SearchTab extends StatefulWidget {
class _SearchTabState extends State<SearchTab> {
// Focus nodes are necessary
var _searchResults = <SearchResult>[];
+ int index = 0;
@override
void didChangeDependencies() {
super.didChangeDependencies();
_searchResults = InheritedSearchResults.of(context).results;
+ if (_searchResults.isEmpty) {
+ if (isSearchQueryEmpty) {
+ index = 0;
+ } else {
+ index = 2;
+ }
+ } else {
+ index = 1;
+ }
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 8),
- child: _searchResults.isEmpty
- ? isSearchQueryEmpty
- ? const AllSearchSections()
- : const NoResultWidget()
- : SearchSuggestionsWidget(_searchResults),
+ child: IndexedStack(
+ index: index,
+ children: [
+ const AllSearchSections(),
+ SearchSuggestionsWidget(_searchResults),
+ const NoResultWidget(),
+ ],
+ ),
);
}
}