Skip to content

armgit / ente

Public Imported from GitHub
0

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

Open tapped photo in shared feed grid

Neeraj Guptaca5738c4c429
diff --git a/mobile/apps/photos/lib/ui/social/feed_screen.dart b/mobile/apps/photos/lib/ui/social/feed_screen.dart
index 57747d13b4..0a2fe096bf 100644
--- a/mobile/apps/photos/lib/ui/social/feed_screen.dart
+++ b/mobile/apps/photos/lib/ui/social/feed_screen.dart
@@ -418,6 +418,10 @@ class _FeedScreenState extends State<FeedScreen> {
const {},
isLastItem: isLastItem,
onTap: () => _handleFeedItemTap(item),
+ onSharedPhotoTap: (fileID) => _openSharedPhotos(
+ item,
+ initialFileID: fileID,
+ ),
);
},
),
@@ -549,7 +553,7 @@ class _FeedScreenState extends State<FeedScreen> {
}
/// Opens a gallery view of the shared photos.
- Future<void> _openSharedPhotos(FeedItem item) async {
+ Future<void> _openSharedPhotos(FeedItem item, {int? initialFileID}) async {
final fileIDs = item.sharedFileIDs;
if (fileIDs == null || fileIDs.isEmpty) return;
@@ -562,13 +566,22 @@ class _FeedScreenState extends State<FeedScreen> {
if (files.isEmpty || !mounted) return;
+ var initialIndex = 0;
+ if (initialFileID != null) {
+ final tappedIndex =
+ files.indexWhere((file) => file.uploadedFileID == initialFileID);
+ if (tappedIndex >= 0) {
+ initialIndex = tappedIndex;
+ }
+ }
+
unawaited(
routeToPage(
context,
DetailPage(
DetailPageConfiguration(
files,
- 0,
+ initialIndex,
"feed_shared_photos",
),
),
diff --git a/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart
index 711fac0e25..4e45efa791 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart
@@ -22,6 +22,9 @@ class FeedItemWidget extends StatelessWidget {
/// Called when the user taps anywhere on the feed item.
final VoidCallback? onTap;
+ /// Called when the user taps a specific shared photo in the shared grid.
+ final ValueChanged<int>? onSharedPhotoTap;
+
/// Map of anonUserID -> decrypted display name for the collection.
final Map<String, String> anonDisplayNames;
@@ -32,6 +35,7 @@ class FeedItemWidget extends StatelessWidget {
required this.feedItem,
required this.currentUserID,
this.onTap,
+ this.onSharedPhotoTap,
this.anonDisplayNames = const {},
this.isLastItem = false,
super.key,
@@ -171,6 +175,7 @@ class FeedItemWidget extends StatelessWidget {
fileIDs: feedItem.sharedFileIDs!,
collectionID: feedItem.collectionID,
onTap: onTap,
+ onPhotoTap: onSharedPhotoTap,
),
),
],
diff --git a/mobile/apps/photos/lib/ui/social/widgets/shared_photos_grid.dart b/mobile/apps/photos/lib/ui/social/widgets/shared_photos_grid.dart
index b6ffbdd172..cc7c98f587 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/shared_photos_grid.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/shared_photos_grid.dart
@@ -23,6 +23,9 @@ class SharedPhotosGrid extends StatefulWidget {
/// Called when user taps on the grid.
final VoidCallback? onTap;
+ /// Called when user taps an individual photo thumbnail.
+ final ValueChanged<int>? onPhotoTap;
+
/// Size of the grid (width). Height is calculated based on layout.
final double gridSize;
@@ -30,6 +33,7 @@ class SharedPhotosGrid extends StatefulWidget {
required this.fileIDs,
required this.collectionID,
this.onTap,
+ this.onPhotoTap,
this.gridSize = 300,
super.key,
});
@@ -248,13 +252,22 @@ class _SharedPhotosGridState extends State<SharedPhotosGrid> {
}
Widget _buildSharedPhotoThumbnail(EnteFile file) {
- return ThumbnailWidget(
+ final thumbnail = ThumbnailWidget(
file,
fit: BoxFit.cover,
rawThumbnail: true,
thumbnailSize: thumbnailLargeSize,
useRequestedThumbnailSizeForLocalCache: true,
);
+ final fileID = file.uploadedFileID;
+ if (widget.onPhotoTap == null || fileID == null) {
+ return thumbnail;
+ }
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => widget.onPhotoTap!(fileID),
+ child: thumbnail,
+ );
}
Widget _buildExtraCountOverlay(int extraCount) {