Fix hero animation issue for device folders with common entries
This commit is contained in:
parent
78f3294186
commit
9152c11149
3 changed files with 15 additions and 6 deletions
|
@ -3,8 +3,14 @@ import 'package:photos/models/file.dart';
|
|||
|
||||
class DeviceFolder {
|
||||
final String name;
|
||||
final String path;
|
||||
final File thumbnail;
|
||||
final GalleryItemsFilter filter;
|
||||
|
||||
DeviceFolder(this.name, this.thumbnail, this.filter);
|
||||
DeviceFolder(
|
||||
this.name,
|
||||
this.path,
|
||||
this.thumbnail,
|
||||
this.filter,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class _DeviceFolderPageState extends State<DeviceFolderPage> {
|
|||
var gallery = Gallery(
|
||||
syncLoader: () => _getFilteredFiles(FileRepository.instance.files),
|
||||
reloadEvent: Bus.instance.on<LocalPhotosUpdatedEvent>(),
|
||||
tagPrefix: "device_folder",
|
||||
tagPrefix: "device_folder:" + widget.folder.path,
|
||||
selectedFiles: _selectedFiles,
|
||||
);
|
||||
return Scaffold(
|
||||
|
|
|
@ -74,7 +74,8 @@ class _DeviceFolderGalleryWidgetState extends State<DeviceFolderGalleryWidget> {
|
|||
for (final path in paths) {
|
||||
final file = await FileDB.instance.getLatestFileInPath(path);
|
||||
final folderName = p.basename(path);
|
||||
folders.add(DeviceFolder(folderName, file, FolderNameFilter(folderName)));
|
||||
folders.add(
|
||||
DeviceFolder(folderName, path, file, FolderNameFilter(folderName)));
|
||||
}
|
||||
folders.sort((first, second) {
|
||||
return second.thumbnail.creationTime
|
||||
|
@ -83,11 +84,13 @@ class _DeviceFolderGalleryWidgetState extends State<DeviceFolderGalleryWidget> {
|
|||
if (FavoriteFilesRepository.instance.hasFavorites()) {
|
||||
final file = await FileDB.instance.getLatestFileAmongGeneratedIds(
|
||||
FavoriteFilesRepository.instance.getLiked().toList());
|
||||
folders.insert(0, DeviceFolder("Favorites", file, FavoriteItemsFilter()));
|
||||
folders.insert(0,
|
||||
DeviceFolder("Favorites", "/Favorites", file, FavoriteItemsFilter()));
|
||||
}
|
||||
final videos = await FileDB.instance.getAllVideos();
|
||||
if (videos.length > 0) {
|
||||
folders.insert(0, DeviceFolder("Videos", videos[0], VideoFileFilter()));
|
||||
folders.insert(
|
||||
0, DeviceFolder("Videos", "/Videos", videos[0], VideoFileFilter()));
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
@ -98,7 +101,7 @@ class _DeviceFolderGalleryWidgetState extends State<DeviceFolderGalleryWidget> {
|
|||
children: <Widget>[
|
||||
Container(
|
||||
child: Hero(
|
||||
tag: "device_folder" + folder.thumbnail.tag(),
|
||||
tag: "device_folder:" + folder.path + folder.thumbnail.tag(),
|
||||
child: ThumbnailWidget(folder.thumbnail)),
|
||||
height: 150,
|
||||
width: 150,
|
||||
|
|
Loading…
Add table
Reference in a new issue