feat: apply thread screen news card layout to all post cards - show after body, hide URLs
This commit is contained in:
parent
feed826e39
commit
5674c8e4f8
|
|
@ -227,15 +227,6 @@ class _sojornPostCardState extends ConsumerState<sojornPostCard> {
|
|||
),
|
||||
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) ...[
|
||||
|
|
@ -253,6 +244,7 @@ class _sojornPostCardState extends ConsumerState<sojornPostCard> {
|
|||
bodyFormat: post.bodyFormat,
|
||||
backgroundId: post.backgroundId,
|
||||
mode: mode,
|
||||
hideUrls: post.hasLinkPreview,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -271,25 +263,17 @@ class _sojornPostCardState extends ConsumerState<sojornPostCard> {
|
|||
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<sojornPostCard> {
|
|||
);
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue