Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/community/widgets/post_card_view_comfortable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class PostCardViewComfortable extends StatelessWidget {

Widget mediaView = MediaView(
media: postViewMedia.media.first,
postId: postViewMedia.postView.post.id,
showFullHeightImages: showFullHeightImages,
hideNsfwPreviews: hideNsfwPreviews,
hideThumbnails: hideThumbnails,
Expand Down
1 change: 1 addition & 0 deletions lib/community/widgets/post_card_view_compact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class ThumbnailPreview extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 4),
child: MediaView(
media: postViewMedia.media.first,
postId: postViewMedia.postView.post.id,
showFullHeightImages: false,
hideNsfwPreviews: hideNsfwPreviews,
markPostReadOnMediaView: markPostReadOnMediaView,
Expand Down
2 changes: 2 additions & 0 deletions lib/post/widgets/post_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class _PostSubviewState extends State<PostSubview> with SingleTickerProviderStat
expanded: MediaView(
viewMode: ViewMode.comfortable,
media: postViewMedia.media.first,
postId: postViewMedia.postView.post.id,
showFullHeightImages: true,
allowUnconstrainedImageHeight: true,
hideNsfwPreviews: hideNsfwPreviews,
Expand Down Expand Up @@ -388,6 +389,7 @@ class _PostSubviewState extends State<PostSubview> with SingleTickerProviderStat
),
child: MediaView(
media: postViewMedia.media.first,
postId: postViewMedia.postView.post.id,
showFullHeightImages: false,
hideNsfwPreviews: hideNsfwPreviews,
markPostReadOnMediaView: markPostReadOnMediaView,
Expand Down
32 changes: 24 additions & 8 deletions lib/shared/media/media_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ class _MediaViewState extends State<MediaView> with TickerProviderStateMixin {
return ViewMode.comfortable.height;
}

void handleTap() {
if (widget.isUserLoggedIn && widget.markPostReadOnMediaView) {
try {
final feedBloc = BlocProvider.of<FeedBloc>(context);
feedBloc.add(FeedItemActionedEvent(postAction: PostAction.read, postId: widget.postId, value: true));
} catch (e) {
debugPrint('Error marking post as read: $e');
}
}
}

@override
Widget build(BuildContext context) {
// If hiding thumbnails is enabled or if the media has no image URL (e.g., text or links with no images), we should display a link preview instead
Expand All @@ -155,7 +166,10 @@ class _MediaViewState extends State<MediaView> with TickerProviderStateMixin {
viewMode: widget.viewMode,
originURL: widget.media.originalUrl,
mediaType: widget.media.mediaType,
onTap: widget.media.mediaType == MediaType.image ? showImage : null,
onTap: () {
handleTap();
handleLink(context, url: widget.media.originalUrl!);
},
showEdgeToEdgeImages: widget.edgeToEdgeImages,
);
}
Expand Down Expand Up @@ -194,7 +208,10 @@ class _MediaViewState extends State<MediaView> with TickerProviderStateMixin {
child = InkWell(
splashColor: theme.colorScheme.primary.withValues(alpha: 0.4),
borderRadius: BorderRadius.circular((widget.edgeToEdgeImages ? 0 : 12)),
onTap: () => handleLink(context, url: widget.media.originalUrl!),
onTap: () {
handleTap();
handleLink(context, url: widget.media.originalUrl!);
},
onLongPress: () => handleLinkLongPress(context, widget.media.originalUrl!, widget.media.originalUrl),
child: widget.viewMode == ViewMode.comfortable
? SizedBox(
Expand All @@ -218,7 +235,10 @@ class _MediaViewState extends State<MediaView> with TickerProviderStateMixin {
child = InkWell(
splashColor: theme.colorScheme.primary.withValues(alpha: 0.4),
borderRadius: BorderRadius.circular((widget.edgeToEdgeImages ? 0 : 12)),
onTap: showImage,
onTap: () {
handleTap();
showImage();
},
child: GestureDetector(
onLongPressStart: (_) {
_overlayEntry = OverlayEntry(
Expand Down Expand Up @@ -252,11 +272,7 @@ class _MediaViewState extends State<MediaView> with TickerProviderStateMixin {
splashColor: theme.colorScheme.primary.withValues(alpha: 0.4),
borderRadius: BorderRadius.circular((widget.edgeToEdgeImages ? 0 : 12)),
onTap: () {
if (widget.isUserLoggedIn && widget.markPostReadOnMediaView) {
FeedBloc feedBloc = BlocProvider.of<FeedBloc>(context);
feedBloc.add(FeedItemActionedEvent(postAction: PostAction.read, postId: widget.postId, value: true));
}

handleTap();
showVideoPlayer(context, url: widget.media.mediaUrl ?? widget.media.originalUrl, postId: widget.postId);
},
child: widget.viewMode == ViewMode.comfortable
Expand Down