Procházet zdrojové kódy

Fix hero animation for location search results

vishnukvmd před 2 roky
rodič
revize
70e1d9442a

+ 5 - 3
lib/ui/viewer/search/collections/files_in_location_page.dart

@@ -11,13 +11,15 @@ import 'package:photos/ui/viewer/gallery/gallery_overlay_widget.dart';
 
 class FilesInLocationPage extends StatelessWidget {
   final LocationSearchResult locationSearchResult;
+  final String tagPrefix;
 
   final _selectedFiles = SelectedFiles();
-  static const String kTagPrefix = "location_search";
   static const GalleryType appBarType = GalleryType.searchResults;
   static const GalleryType overlayType = GalleryType.searchResults;
-  FilesInLocationPage({
+
+  FilesInLocationPage(
     this.locationSearchResult,
+    this.tagPrefix, {
     Key key,
   }) : super(key: key);
 
@@ -57,7 +59,7 @@ class FilesInLocationPage extends StatelessWidget {
                   null,
             ),
       ],
-      tagPrefix: kTagPrefix,
+      tagPrefix: tagPrefix,
       selectedFiles: _selectedFiles,
       initialFiles: [locationSearchResult.files[0]],
       footer: const SizedBox(height: 120),

+ 7 - 4
lib/ui/viewer/search/search_result_widgets/location_result_widget.dart

@@ -6,12 +6,17 @@ import 'package:photos/ui/viewer/search/collections/files_in_location_page.dart'
 import 'package:photos/utils/navigation_util.dart';
 
 class LocationSearchResultWidget extends StatelessWidget {
+  static const String kTagPrefix = "location_search";
+
   final LocationSearchResult locationSearchResult;
   const LocationSearchResultWidget(this.locationSearchResult, {Key key})
       : super(key: key);
+
   @override
   Widget build(BuildContext context) {
     final noOfMemories = locationSearchResult.files.length;
+    final heroTagPrefix = kTagPrefix + locationSearchResult.location;
+
     return GestureDetector(
       behavior: HitTestBehavior.opaque,
       child: Container(
@@ -53,7 +58,7 @@ class LocationSearchResultWidget extends StatelessWidget {
                 ),
               ),
               Hero(
-                tag: "location_search" + locationSearchResult.location,
+                tag: heroTagPrefix + locationSearchResult.files[0].tag(),
                 child: SizedBox(
                   height: 50,
                   width: 50,
@@ -67,9 +72,7 @@ class LocationSearchResultWidget extends StatelessWidget {
       onTap: () {
         routeToPage(
           context,
-          FilesInLocationPage(
-            locationSearchResult: locationSearchResult,
-          ),
+          FilesInLocationPage(locationSearchResult, heroTagPrefix),
           forceCustomPageRoute: true,
         );
       },