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 '../compose/compose_screen.dart';
|
||||||
import '../../services/notification_service.dart';
|
import '../../services/notification_service.dart';
|
||||||
import '../../widgets/post/post_body.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_view_mode.dart';
|
||||||
import '../../widgets/post/post_media.dart';
|
import '../../widgets/post/post_media.dart';
|
||||||
import '../home/full_screen_shell.dart';
|
import '../home/full_screen_shell.dart';
|
||||||
|
|
@ -585,11 +586,25 @@ class _ThreadedConversationScreenState extends ConsumerState<ThreadedConversatio
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildStageContent(Post post) {
|
Widget _buildStageContent(Post post) {
|
||||||
return PostBody(
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
PostBody(
|
||||||
text: post.body,
|
text: post.body,
|
||||||
bodyFormat: post.bodyFormat,
|
bodyFormat: post.bodyFormat,
|
||||||
backgroundId: post.backgroundId,
|
backgroundId: post.backgroundId,
|
||||||
mode: PostViewMode.detail,
|
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 String? backgroundId; // theme id
|
||||||
final bool isReflective;
|
final bool isReflective;
|
||||||
final PostViewMode mode;
|
final PostViewMode mode;
|
||||||
|
final bool hideUrls;
|
||||||
|
|
||||||
const PostBody({
|
const PostBody({
|
||||||
super.key,
|
super.key,
|
||||||
|
|
@ -26,6 +27,7 @@ class PostBody extends StatelessWidget {
|
||||||
this.backgroundId,
|
this.backgroundId,
|
||||||
this.isReflective = false,
|
this.isReflective = false,
|
||||||
this.mode = PostViewMode.feed,
|
this.mode = PostViewMode.feed,
|
||||||
|
this.hideUrls = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Check if text contains Markdown syntax
|
/// Check if text contains Markdown syntax
|
||||||
|
|
@ -96,6 +98,7 @@ class PostBody extends StatelessWidget {
|
||||||
: sojornRichText(
|
: sojornRichText(
|
||||||
text: cleanedText,
|
text: cleanedText,
|
||||||
style: style,
|
style: style,
|
||||||
|
hideUrls: hideUrls,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
|
|
@ -126,6 +129,7 @@ class PostBody extends StatelessWidget {
|
||||||
text: cleanedText,
|
text: cleanedText,
|
||||||
style: style,
|
style: style,
|
||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
|
hideUrls: hideUrls,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,14 @@ class sojornRichText extends StatelessWidget {
|
||||||
final String text;
|
final String text;
|
||||||
final TextStyle? style;
|
final TextStyle? style;
|
||||||
final int? maxLines;
|
final int? maxLines;
|
||||||
|
final bool hideUrls;
|
||||||
|
|
||||||
const sojornRichText({
|
const sojornRichText({
|
||||||
super.key,
|
super.key,
|
||||||
required this.text,
|
required this.text,
|
||||||
this.style,
|
this.style,
|
||||||
this.maxLines,
|
this.maxLines,
|
||||||
|
this.hideUrls = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -62,6 +64,14 @@ class sojornRichText extends StatelessWidget {
|
||||||
final bool isMention = matchText.startsWith('@');
|
final bool isMention = matchText.startsWith('@');
|
||||||
final bool isHashtag = matchText.startsWith('#');
|
final bool isHashtag = matchText.startsWith('#');
|
||||||
final bool issojornLink = matchText.startsWith('sojorn://');
|
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 =
|
final Color linkColor =
|
||||||
isHashtag ? AppTheme.brightNavy : AppTheme.royalPurple;
|
isHashtag ? AppTheme.brightNavy : AppTheme.royalPurple;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue