From f6aae5a3808ec0d992e1830c2af31117c73240bc Mon Sep 17 00:00:00 2001 From: Hamlet Jiang Su Date: Tue, 24 Mar 2026 17:18:52 -0700 Subject: [PATCH] fix: fix media text preview --- .../presentation/utils/post_media_utils.dart | 2 +- .../widgets/media/media_view_text.dart | 27 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/src/features/post/presentation/utils/post_media_utils.dart b/lib/src/features/post/presentation/utils/post_media_utils.dart index 605f5cb5f..f4c65c964 100644 --- a/lib/src/features/post/presentation/utils/post_media_utils.dart +++ b/lib/src/features/post/presentation/utils/post_media_utils.dart @@ -100,7 +100,7 @@ Future parsePost(ThunderPost post, bool fetchImageDimensions, bool // Set the proper alt text for the media if (media.mediaType == MediaType.text) { - media.altText = post.body; + media.altText = post.body ?? post.name; } else if (media.mediaType == MediaType.image) { media.altText = post.altText; } diff --git a/lib/src/shared/content/widgets/media/media_view_text.dart b/lib/src/shared/content/widgets/media/media_view_text.dart index fdf0f81a2..f49d52c74 100644 --- a/lib/src/shared/content/widgets/media/media_view_text.dart +++ b/lib/src/shared/content/widgets/media/media_view_text.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:thunder/src/foundation/primitives/primitives.dart'; + class MediaViewText extends StatelessWidget { const MediaViewText({ super.key, @@ -17,13 +19,24 @@ class MediaViewText extends StatelessWidget { alpha: read == true ? 0.55 : 1.0, ); - return Padding( - padding: const EdgeInsets.all(12.0), - child: Text( - text ?? '', - maxLines: 4, - overflow: TextOverflow.ellipsis, - style: theme.textTheme.bodyMedium?.copyWith(color: foreground), + return Container( + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12.0), + color: theme.colorScheme.surfaceContainerHighest.withValues( + alpha: read == true ? 0.55 : 1.0, + ), + ), + height: ViewMode.compact.height, + width: ViewMode.compact.height, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Text( + text ?? '', + maxLines: 4, + overflow: TextOverflow.ellipsis, + style: theme.textTheme.bodyMedium?.copyWith(color: foreground, fontSize: 8.0), + ), ), ); }