Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Make MagicResultScreen hierarchical searchable

ashilkn3716eb3d303a
diff --git a/mobile/lib/services/magic_cache_service.dart b/mobile/lib/services/magic_cache_service.dart
index ce1aceff63..a11490d662 100644
--- a/mobile/lib/services/magic_cache_service.dart
+++ b/mobile/lib/services/magic_cache_service.dart
@@ -24,6 +24,7 @@ import "package:photos/services/machine_learning/semantic_search/semantic_search
import "package:photos/services/remote_assets_service.dart";
import "package:photos/services/search_service.dart";
import "package:photos/ui/viewer/search/result/magic_result_screen.dart";
+import "package:photos/utils/file_util.dart";
import "package:photos/utils/navigation_util.dart";
import "package:shared_preferences/shared_preferences.dart";
@@ -143,16 +144,20 @@ GenericSearchResult? toGenericSearchResult(
title,
enteFilesInMagicCache,
hierarchicalSearchFilter:
- //TODO: Check if matchedUploadedIDs should be passed
MagicFilter(filterName: title, occurrence: kMostRelevantFilter),
).heroTag(),
+ magicFilter: MagicFilter(
+ filterName: title,
+ occurrence: kMostRelevantFilter,
+ matchedUploadedIDs: filesToUploadedFileIDs(enteFilesInMagicCache),
+ ),
),
);
},
- //TODO: Check if matchedUploadedIDs should be passed
hierarchicalSearchFilter: MagicFilter(
filterName: title,
occurrence: kMostRelevantFilter,
+ matchedUploadedIDs: filesToUploadedFileIDs(enteFilesInMagicCache),
),
);
}
diff --git a/mobile/lib/services/search_service.dart b/mobile/lib/services/search_service.dart
index 12eefd3d45..40032637ae 100644
--- a/mobile/lib/services/search_service.dart
+++ b/mobile/lib/services/search_service.dart
@@ -1246,6 +1246,11 @@ class SearchService {
matchedUploadedIDs: filesToUploadedFileIDs(files),
),
).heroTag(),
+ magicFilter: MagicFilter(
+ filterName: query,
+ occurrence: kMostRelevantFilter,
+ matchedUploadedIDs: filesToUploadedFileIDs(files),
+ ),
),
);
},
diff --git a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 8ace3ae04d..39a173f655 100644
--- a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -164,7 +164,8 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
// actions: _getDefaultActions(context),
bottom: galleryType == GalleryType.searchResults ||
galleryType == GalleryType.ownedCollection ||
- galleryType == GalleryType.locationTag
+ galleryType == GalleryType.locationTag ||
+ galleryType == GalleryType.magic
? const PreferredSize(
preferredSize: Size.fromHeight(0),
child: Flexible(child: RecommendedFilters()),
diff --git a/mobile/lib/ui/viewer/search/result/magic_result_screen.dart b/mobile/lib/ui/viewer/search/result/magic_result_screen.dart
index c8c4e3697d..aec6a3ef76 100644
--- a/mobile/lib/ui/viewer/search/result/magic_result_screen.dart
+++ b/mobile/lib/ui/viewer/search/result/magic_result_screen.dart
@@ -9,11 +9,15 @@ import "package:photos/events/magic_sort_change_event.dart";
import 'package:photos/models/file/file.dart';
import 'package:photos/models/file_load_result.dart';
import 'package:photos/models/gallery_type.dart';
+import "package:photos/models/search/hierarchical/magic_filter.dart";
import 'package:photos/models/selected_files.dart';
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
+import "package:photos/ui/viewer/gallery/hierarchical_search_gallery.dart";
import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
+import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";
+import "package:photos/ui/viewer/gallery/state/search_filter_data_provider.dart";
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
class MagicResultScreen extends StatefulWidget {
@@ -24,6 +28,7 @@ class MagicResultScreen extends StatefulWidget {
final String heroTag;
final bool enableGrouping;
final Map<int, int> fileIdToPosMap;
+ final MagicFilter magicFilter;
static const GalleryType appBarType = GalleryType.magic;
static const GalleryType overlayType = GalleryType.magic;
@@ -31,6 +36,7 @@ class MagicResultScreen extends StatefulWidget {
const MagicResultScreen(
this.files, {
required this.name,
+ required this.magicFilter,
this.enableGrouping = false,
this.fileIdToPosMap = const {},
this.heroTag = "",
@@ -157,31 +163,52 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
initialFiles: [files.first],
);
return GalleryFilesState(
- child: Scaffold(
- appBar: PreferredSize(
- preferredSize: const Size.fromHeight(50.0),
- child: GalleryAppBarWidget(
- MagicResultScreen.appBarType,
- widget.name,
- _selectedFiles,
- ),
+ child: InheritedSearchFilterData(
+ searchFilterDataProvider: SearchFilterDataProvider(
+ initialGalleryFilter: widget.magicFilter,
),
- body: SelectionState(
- selectedFiles: _selectedFiles,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 250),
- switchInCurve: Curves.easeInOutQuad,
- switchOutCurve: Curves.easeInOutQuad,
- child: gallery,
- ),
- FileSelectionOverlayBar(
- MagicResultScreen.overlayType,
- _selectedFiles,
- ),
- ],
+ child: Scaffold(
+ appBar: PreferredSize(
+ preferredSize: const Size.fromHeight(90.0),
+ child: GalleryAppBarWidget(
+ MagicResultScreen.appBarType,
+ widget.name,
+ _selectedFiles,
+ ),
+ ),
+ body: SelectionState(
+ selectedFiles: _selectedFiles,
+ child: Stack(
+ alignment: Alignment.bottomCenter,
+ children: [
+ Builder(
+ builder: (context) {
+ return ValueListenableBuilder(
+ valueListenable: InheritedSearchFilterData.of(context)
+ .searchFilterDataProvider!
+ .isSearchingNotifier,
+ builder: (context, value, _) {
+ return value
+ ? HierarchicalSearchGallery(
+ tagPrefix: widget.heroTag,
+ selectedFiles: _selectedFiles,
+ )
+ : AnimatedSwitcher(
+ duration: const Duration(milliseconds: 250),
+ switchInCurve: Curves.easeInOutQuad,
+ switchOutCurve: Curves.easeInOutQuad,
+ child: gallery,
+ );
+ },
+ );
+ },
+ ),
+ FileSelectionOverlayBar(
+ MagicResultScreen.overlayType,
+ _selectedFiles,
+ ),
+ ],
+ ),
),
),
),
diff --git a/mobile/lib/ui/viewer/search/result/search_section_all_page.dart b/mobile/lib/ui/viewer/search/result/search_section_all_page.dart
index c7585ed51c..0eae57792f 100644
--- a/mobile/lib/ui/viewer/search/result/search_section_all_page.dart
+++ b/mobile/lib/ui/viewer/search/result/search_section_all_page.dart
@@ -7,6 +7,7 @@ import "package:photos/events/event.dart";
import "package:photos/extensions/list.dart";
import "package:photos/models/search/album_search_result.dart";
import "package:photos/models/search/generic_search_result.dart";
+import "package:photos/models/search/hierarchical/magic_filter.dart";
import "package:photos/models/search/recent_searches.dart";
import "package:photos/models/search/search_result.dart";
import "package:photos/models/search/search_types.dart";
@@ -177,6 +178,9 @@ class _SearchSectionAllPageState extends State<SearchSectionAllPage> {
as Map<int, int>,
heroTag: "searchable_item" +
magicSectionResult.heroTag(),
+ magicFilter: magicSectionResult
+ .getHierarchicalSearchFilter()
+ as MagicFilter,
),
);
},