Skip to content

armgit / ente

Public Imported from GitHub
0

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

update search results in InheritedSearchResults from new search bar

ashilknaa5b87d45bd1
diff --git a/lib/ui/tabs/home_widget.dart b/lib/ui/tabs/home_widget.dart
index 55e4bb2c1b..f44a2683e2 100644
--- a/lib/ui/tabs/home_widget.dart
+++ b/lib/ui/tabs/home_widget.dart
@@ -33,6 +33,7 @@ import 'package:photos/services/local_sync_service.dart';
import "package:photos/services/notification_service.dart";
import 'package:photos/services/update_service.dart';
import 'package:photos/services/user_service.dart';
+import "package:photos/states/search_results_state.dart";
import 'package:photos/states/user_details_state.dart';
import 'package:photos/theme/colors.dart';
import 'package:photos/theme/ente_theme.dart';
@@ -391,79 +392,81 @@ class _HomeWidgetState extends State<HomeWidget> {
!LocalSyncService.instance.hasGrantedLimitedPermissions() &&
CollectionsService.instance.getActiveCollections().isEmpty;
- return Stack(
- children: [
- Builder(
- builder: (context) {
- return ExtentsPageView(
- onPageChanged: (page) {
- Bus.instance.fire(
- TabChangedEvent(
- page,
- TabChangedEventSource.pageView,
- ),
- );
- },
- controller: _pageController,
- openDrawer: Scaffold.of(context).openDrawer,
- physics: const BouncingScrollPhysics(),
- children: [
- _showShowBackupHook
- ? const StartBackupHookWidget(headerWidget: _headerWidget)
- : HomeGalleryWidget(
- header: _headerWidget,
- footer: const PreserveFooterWidget(),
- selectedFiles: _selectedFiles,
- ),
- _userCollectionsTab,
- _sharedCollectionTab,
- _searchTab,
- ],
- );
- },
- ),
- Align(
- alignment: Alignment.bottomCenter,
- child: ValueListenableBuilder(
- valueListenable: isOnSearchTabNotifier,
- builder: (context, value, child) {
- return Column(
- mainAxisSize: MainAxisSize.min,
+ return SearchResultsProvider(
+ child: Stack(
+ children: [
+ Builder(
+ builder: (context) {
+ return ExtentsPageView(
+ onPageChanged: (page) {
+ Bus.instance.fire(
+ TabChangedEvent(
+ page,
+ TabChangedEventSource.pageView,
+ ),
+ );
+ },
+ controller: _pageController,
+ openDrawer: Scaffold.of(context).openDrawer,
+ physics: const BouncingScrollPhysics(),
children: [
- value
- ? const SearchWidgetNew()
- .animate()
- .fadeIn(
- duration: const Duration(milliseconds: 175),
- curve: Curves.easeInOutSine,
- )
- .scale(
- begin: const Offset(0.6, 0.6),
- end: const Offset(1, 1),
- duration: const Duration(
- milliseconds: 175,
- ),
- curve: Curves.easeInOutSine,
- )
- .slide(
- begin: const Offset(0, 0.8),
- curve: Curves.easeInOutSine,
- duration: const Duration(
- milliseconds: 175,
- ),
- )
- : const SizedBox.shrink(),
- child!,
+ _showShowBackupHook
+ ? const StartBackupHookWidget(headerWidget: _headerWidget)
+ : HomeGalleryWidget(
+ header: _headerWidget,
+ footer: const PreserveFooterWidget(),
+ selectedFiles: _selectedFiles,
+ ),
+ _userCollectionsTab,
+ _sharedCollectionTab,
+ _searchTab,
],
);
},
- child: HomeBottomNavigationBar(
- _selectedFiles,
- selectedTabIndex: _selectedTabIndex,
+ ),
+ Align(
+ alignment: Alignment.bottomCenter,
+ child: ValueListenableBuilder(
+ valueListenable: isOnSearchTabNotifier,
+ builder: (context, value, child) {
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ value
+ ? const SearchWidgetNew()
+ .animate()
+ .fadeIn(
+ duration: const Duration(milliseconds: 175),
+ curve: Curves.easeInOutSine,
+ )
+ .scale(
+ begin: const Offset(0.6, 0.6),
+ end: const Offset(1, 1),
+ duration: const Duration(
+ milliseconds: 175,
+ ),
+ curve: Curves.easeInOutSine,
+ )
+ .slide(
+ begin: const Offset(0, 0.8),
+ curve: Curves.easeInOutSine,
+ duration: const Duration(
+ milliseconds: 175,
+ ),
+ )
+ : const SizedBox.shrink(),
+ child!,
+ ],
+ );
+ },
+ child: HomeBottomNavigationBar(
+ _selectedFiles,
+ selectedTabIndex: _selectedTabIndex,
+ ),
),
),
- ),
- ],
+ ],
+ ),
);
}
diff --git a/lib/ui/viewer/search/search_widget_new.dart b/lib/ui/viewer/search/search_widget_new.dart
index 4abcaf1a5d..6d5d68a656 100644
--- a/lib/ui/viewer/search/search_widget_new.dart
+++ b/lib/ui/viewer/search/search_widget_new.dart
@@ -7,6 +7,7 @@ import "package:photos/core/event_bus.dart";
import "package:photos/events/tab_changed_event.dart";
import "package:photos/models/search/search_result.dart";
import "package:photos/services/search_service.dart";
+import "package:photos/states/search_results_state.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/viewer/search/search_suffix_icon_widget.dart";
import "package:photos/utils/date_time_util.dart";
@@ -21,7 +22,6 @@ class SearchWidgetNew extends StatefulWidget {
class _SearchWidgetNewState extends State<SearchWidgetNew> {
String _query = "";
- final List<SearchResult> _results = [];
final _searchService = SearchService.instance;
final _debouncer = Debouncer(const Duration(milliseconds: 100));
final Logger _logger = Logger((_SearchWidgetNewState).toString());
@@ -146,10 +146,9 @@ class _SearchWidgetNewState extends State<SearchWidgetNew> {
/*checking if _query == value to make sure that the results are from the current query
and not from the previous query (race condition).*/
if (mounted && _query == value) {
- setState(() {
- _results.clear();
- _results.addAll(allResults);
- });
+ final inheritedSearchResults =
+ InheritedSearchResults.of(context);
+ inheritedSearchResults.updateResults(allResults);
}
},
),