From 5674c8e4f887268bb2035b88d74d50f4a6583091 Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Mon, 9 Feb 2026 16:44:44 -0600 Subject: [PATCH] feat: apply thread screen news card layout to all post cards - show after body, hide URLs --- sojorn_app/lib/widgets/sojorn_post_card.dart | 56 ++++---------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/sojorn_app/lib/widgets/sojorn_post_card.dart b/sojorn_app/lib/widgets/sojorn_post_card.dart index 20c6bb9..b53090e 100644 --- a/sojorn_app/lib/widgets/sojorn_post_card.dart +++ b/sojorn_app/lib/widgets/sojorn_post_card.dart @@ -227,16 +227,7 @@ class _sojornPostCardState extends ConsumerState { ), const SizedBox(height: 16), - // Link preview card ABOVE body text for news posts - if (post.hasLinkPreview && - (post.imageUrl == null || post.imageUrl!.isEmpty) && - (post.videoUrl == null || post.videoUrl!.isEmpty)) ...[ - Padding( - padding: EdgeInsets.only(bottom: 12), - child: PostLinkPreview(post: post, mode: mode), - ), - ], - + // Body text - clickable for post detail with full background coverage if (_shouldBlurNsfw) ...[ // NSFW blurred body @@ -253,6 +244,7 @@ class _sojornPostCardState extends ConsumerState { bodyFormat: post.bodyFormat, backgroundId: post.backgroundId, mode: mode, + hideUrls: post.hasLinkPreview, ), ), ), @@ -271,25 +263,17 @@ class _sojornPostCardState extends ConsumerState { bodyFormat: post.bodyFormat, backgroundId: post.backgroundId, mode: mode, + hideUrls: post.hasLinkPreview, ), ), ), ], - // Show link URL below post body for posts with link previews - if (post.hasLinkPreview && post.linkPreviewUrl != null) ...[ - const SizedBox(height: 6), - GestureDetector( - onTap: () => _launchPreviewUrl(post.linkPreviewUrl!), - child: Text( - _truncateUrl(post.linkPreviewUrl!), - style: TextStyle( - color: AppTheme.royalPurple, - fontSize: 13, - fontWeight: FontWeight.w500, - decoration: TextDecoration.underline, - decorationColor: AppTheme.royalPurple.withValues(alpha: 0.5), - ), - ), + // Link preview card after post body + if (post.hasLinkPreview) ...[ + const SizedBox(height: 16), + PostLinkPreview( + post: post, + mode: mode, ), ], ], @@ -401,28 +385,6 @@ class _sojornPostCardState extends ConsumerState { ); } - String _truncateUrl(String url) { - if (url.length <= 45) return url; - try { - final uri = Uri.parse(url); - final path = uri.path; - if (path.length > 15) { - return '${uri.scheme}://${uri.host}${path.substring(0, 12)}...'; - } - return '${uri.scheme}://${uri.host}$path'; - } catch (_) { - return '${url.substring(0, 42)}...'; - } - } - - void _launchPreviewUrl(String url) { - final uri = Uri.tryParse(url); - if (uri != null) { - launchUrl(uri, mode: LaunchMode.externalApplication); - } - } -} - /// Subtle single-line "replying to" hint shown on feed cards that are chains. /// Uses a thin left accent bar and muted text to stay unobtrusive. class _ChainReplyHint extends StatelessWidget {