feat: show news card in thread screen, hide URL text when link preview is present
This commit is contained in:
parent
c8b08968ba
commit
feed826e39
|
|
@ -16,6 +16,7 @@ import '../../widgets/media/signed_media_image.dart';
|
|||
import '../compose/compose_screen.dart';
|
||||
import '../../services/notification_service.dart';
|
||||
import '../../widgets/post/post_body.dart';
|
||||
import '../../widgets/post/post_link_preview.dart';
|
||||
import '../../widgets/post/post_view_mode.dart';
|
||||
import '../../widgets/post/post_media.dart';
|
||||
import '../home/full_screen_shell.dart';
|
||||
|
|
@ -585,11 +586,25 @@ class _ThreadedConversationScreenState extends ConsumerState<ThreadedConversatio
|
|||
}
|
||||
|
||||
Widget _buildStageContent(Post post) {
|
||||
return PostBody(
|
||||
text: post.body,
|
||||
bodyFormat: post.bodyFormat,
|
||||
backgroundId: post.backgroundId,
|
||||
mode: PostViewMode.detail,
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
PostBody(
|
||||
text: post.body,
|
||||
bodyFormat: post.bodyFormat,
|
||||
backgroundId: post.backgroundId,
|
||||
mode: PostViewMode.detail,
|
||||
hideUrls: post.hasLinkPreview,
|
||||
),
|
||||
// Link preview card after post body
|
||||
if (post.hasLinkPreview) ...[
|
||||
const SizedBox(height: 16),
|
||||
PostLinkPreview(
|
||||
post: post,
|
||||
mode: PostViewMode.detail,
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class PostBody extends StatelessWidget {
|
|||
final String? backgroundId; // theme id
|
||||
final bool isReflective;
|
||||
final PostViewMode mode;
|
||||
final bool hideUrls;
|
||||
|
||||
const PostBody({
|
||||
super.key,
|
||||
|
|
@ -26,6 +27,7 @@ class PostBody extends StatelessWidget {
|
|||
this.backgroundId,
|
||||
this.isReflective = false,
|
||||
this.mode = PostViewMode.feed,
|
||||
this.hideUrls = false,
|
||||
});
|
||||
|
||||
/// Check if text contains Markdown syntax
|
||||
|
|
@ -96,6 +98,7 @@ class PostBody extends StatelessWidget {
|
|||
: sojornRichText(
|
||||
text: cleanedText,
|
||||
style: style,
|
||||
hideUrls: hideUrls,
|
||||
);
|
||||
|
||||
return Column(
|
||||
|
|
@ -126,6 +129,7 @@ class PostBody extends StatelessWidget {
|
|||
text: cleanedText,
|
||||
style: style,
|
||||
maxLines: maxLines,
|
||||
hideUrls: hideUrls,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,14 @@ class sojornRichText extends StatelessWidget {
|
|||
final String text;
|
||||
final TextStyle? style;
|
||||
final int? maxLines;
|
||||
final bool hideUrls;
|
||||
|
||||
const sojornRichText({
|
||||
super.key,
|
||||
required this.text,
|
||||
this.style,
|
||||
this.maxLines,
|
||||
this.hideUrls = false,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -62,6 +64,14 @@ class sojornRichText extends StatelessWidget {
|
|||
final bool isMention = matchText.startsWith('@');
|
||||
final bool isHashtag = matchText.startsWith('#');
|
||||
final bool issojornLink = matchText.startsWith('sojorn://');
|
||||
final bool isUrl = !isMention && !isHashtag;
|
||||
|
||||
// Skip URLs entirely if hideUrls is true
|
||||
if (hideUrls && isUrl && !issojornLink) {
|
||||
start = match.end;
|
||||
continue;
|
||||
}
|
||||
|
||||
final Color linkColor =
|
||||
isHashtag ? AppTheme.brightNavy : AppTheme.royalPurple;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue