From 9f8c8923d97b15b50ef9a198184d831a6b8b8488 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 19 Mar 2025 00:29:29 +0800 Subject: [PATCH] :bug: Bug fixes in posts --- lib/widgets/post/post_comment_list.dart | 4 +++ lib/widgets/post/post_item.dart | 39 ++++++++++--------------- lib/widgets/post/post_mini_editor.dart | 9 +++++- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/lib/widgets/post/post_comment_list.dart b/lib/widgets/post/post_comment_list.dart index 32bf9a3..9e7324a 100644 --- a/lib/widgets/post/post_comment_list.dart +++ b/lib/widgets/post/post_comment_list.dart @@ -151,6 +151,7 @@ class PostCommentSliverListState extends State { }, ), onTap: () { + Navigator.pop(context); GoRouter.of(context).pushNamed( 'postDetail', pathParameters: {'slug': _posts[idx].id.toString()}, @@ -225,6 +226,9 @@ class _PostCommentListPopupState extends State { onPost: () { _childListKey.currentState!.refresh(); }, + onExpand: () { + Navigator.pop(context); + }, ), ), ), diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 86799f3..9221c59 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -1597,39 +1597,30 @@ class _PostContentHeader extends StatelessWidget { children: [ Row( children: [ - Flexible( - child: Text(data.publisher.nick).bold(), - ), + Text(data.publisher.nick).bold(), if (data.preload?.realm != null) const Icon(Symbols.arrow_right, size: 16) .padding(horizontal: 2) .opacity(0.5), - if (data.preload?.realm != null) - Flexible( - child: Text(data.preload!.realm!.name), - ), + if (data.preload?.realm != null) Text(data.preload!.realm!.name), ], ), Row( children: [ - Flexible( - child: Text( - '@${data.publisher.name}', - maxLines: 1, - ).fontSize(13), - ), + Text( + '@${data.publisher.name}', + maxLines: 1, + ).fontSize(13), const Gap(4), - Flexible( - child: Text( - isRelativeDate - ? RelativeTime(context).format( - (data.publishedAt ?? data.createdAt).toLocal()) - : DateFormat('y/M/d HH:mm').format( - (data.publishedAt ?? data.createdAt).toLocal()), - maxLines: 1, - overflow: TextOverflow.fade, - ).fontSize(13), - ), + Text( + isRelativeDate + ? RelativeTime(context) + .format((data.publishedAt ?? data.createdAt).toLocal()) + : DateFormat('y/M/d HH:mm') + .format((data.publishedAt ?? data.createdAt).toLocal()), + maxLines: 1, + overflow: TextOverflow.fade, + ).fontSize(13), ], ).opacity(0.8), ], diff --git a/lib/widgets/post/post_mini_editor.dart b/lib/widgets/post/post_mini_editor.dart index 460b746..e6f2da3 100644 --- a/lib/widgets/post/post_mini_editor.dart +++ b/lib/widgets/post/post_mini_editor.dart @@ -9,6 +9,7 @@ import 'package:styled_widget/styled_widget.dart'; import 'package:surface/controllers/post_write_controller.dart'; import 'package:surface/providers/config.dart'; import 'package:surface/providers/sn_network.dart'; +import 'package:surface/screens/post/post_editor.dart'; import 'package:surface/types/post.dart'; import 'package:surface/widgets/account/account_image.dart'; import 'package:surface/widgets/dialog.dart'; @@ -17,8 +18,10 @@ import 'package:surface/widgets/loading_indicator.dart'; class PostMiniEditor extends StatefulWidget { final int? postReplyId; final Function? onPost; + final Function? onExpand; - const PostMiniEditor({super.key, this.postReplyId, this.onPost}); + const PostMiniEditor( + {super.key, this.postReplyId, this.onPost, this.onExpand}); @override State createState() => _PostMiniEditorState(); @@ -214,12 +217,16 @@ class _PostMiniEditorState extends State { onPressed: () { GoRouter.of(context).pushNamed( 'postEditor', + extra: PostEditorExtra( + text: _writeController.contentController.text, + ), queryParameters: { if (widget.postReplyId != null) 'replying': widget.postReplyId.toString(), 'mode': 'stories', }, ); + widget.onExpand?.call(); }, ), TextButton.icon(