From 1d99ac64413546d93b7fdde13e9d3502f13246c7 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 2 Jan 2026 19:57:16 +0800 Subject: [PATCH] :lipstick: Adjust post detail screen --- lib/screens/posts/post_detail.dart | 3 ++- lib/widgets/content/markdown.dart | 4 +--- lib/widgets/post/post_item.dart | 8 ++++++++ lib/widgets/post/post_shared.dart | 10 ++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/screens/posts/post_detail.dart b/lib/screens/posts/post_detail.dart index 567930f2..88d48fb2 100644 --- a/lib/screens/posts/post_detail.dart +++ b/lib/screens/posts/post_detail.dart @@ -466,11 +466,12 @@ class PostDetailScreen extends HookConsumerWidget { SliverToBoxAdapter( child: Center( child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: 600), + constraints: BoxConstraints(maxWidth: 800), child: PostItem( item: post!, isFullPost: true, isEmbedReply: false, + textScale: post.type == 1 ? 1.2 : 1.1, onUpdate: (newItem) { // Update the local state with the new post data ref diff --git a/lib/widgets/content/markdown.dart b/lib/widgets/content/markdown.dart index 8f9624d3..7df09717 100644 --- a/lib/widgets/content/markdown.dart +++ b/lib/widgets/content/markdown.dart @@ -30,7 +30,6 @@ class MarkdownTextContent extends HookConsumerWidget { final String content; final bool isAutoWarp; - final TextScaler? textScaler; final TextStyle? textStyle; final TextStyle? linkStyle; final EdgeInsets? linesMargin; @@ -45,7 +44,6 @@ class MarkdownTextContent extends HookConsumerWidget { super.key, required this.content, this.isAutoWarp = false, - this.textScaler, this.textStyle, this.linkStyle, this.isSelectable = false, @@ -118,7 +116,7 @@ class MarkdownTextContent extends HookConsumerWidget { ? PreConfig.darkConfig.copy(textStyle: textStyle) : PreConfig().copy(textStyle: textStyle), PConfig( - textStyle: textStyle ?? Theme.of(context).textTheme.bodyMedium!, + textStyle: (textStyle ?? Theme.of(context).textTheme.bodyMedium!), ), HrConfig(height: 1, color: Theme.of(context).dividerColor), PreConfig( diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 084df381..e15e9701 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -308,6 +308,7 @@ class PostItem extends HookConsumerWidget { final bool isTextSelectable; final bool isTranslatable; final bool isCompact; + final double? textScale; final VoidCallback? onRefresh; final Function(SnPost)? onUpdate; final VoidCallback? onOpen; @@ -322,6 +323,7 @@ class PostItem extends HookConsumerWidget { this.isTextSelectable = true, this.isTranslatable = true, this.isCompact = false, + this.textScale, this.onRefresh, this.onUpdate, this.onOpen, @@ -422,6 +424,11 @@ class PostItem extends HookConsumerWidget { ], ), MarkdownTextContent( + textStyle: TextStyle( + fontSize: + Theme.of(context).textTheme.bodyMedium!.fontSize! * + (textScale ?? 1), + ), content: translatedText.value!, isSelectable: isTextSelectable, attachments: item.attachments, @@ -557,6 +564,7 @@ class PostItem extends HookConsumerWidget { ), PostBody( item: item, + textScale: textScale, isFullPost: isFullPost, isTextSelectable: isTextSelectable, translationSection: translationSection, diff --git a/lib/widgets/post/post_shared.dart b/lib/widgets/post/post_shared.dart index 80beb263..60d06268 100644 --- a/lib/widgets/post/post_shared.dart +++ b/lib/widgets/post/post_shared.dart @@ -870,6 +870,7 @@ class PostBody extends ConsumerWidget { final EdgeInsets renderingPadding; final bool isRelativeTime; final bool hideOverlay; + final double? textScale; const PostBody({ super.key, @@ -881,6 +882,7 @@ class PostBody extends ConsumerWidget { this.renderingPadding = EdgeInsets.zero, this.isRelativeTime = true, this.hideOverlay = false, + this.textScale, }); @override @@ -1108,6 +1110,14 @@ class PostBody extends ConsumerWidget { ], ).padding(bottom: 4), MarkdownTextContent( + linesMargin: item.type == 1 && isFullPost + ? const EdgeInsets.symmetric(vertical: 8) + : const EdgeInsets.symmetric(vertical: 4), + textStyle: TextStyle( + fontSize: + Theme.of(context).textTheme.bodyMedium!.fontSize! * + (textScale ?? 1), + ), content: item.isTruncated ? '${_convertContentToMarkdown(item)}...' : _convertContentToMarkdown(item),