From 06e0fa465b27b48fcd88e33ab225127d7191686a Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 4 Aug 2024 20:48:51 +0800 Subject: [PATCH] :sparkles: Article has special badge --- lib/widgets/posts/post_item.dart | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/widgets/posts/post_item.dart b/lib/widgets/posts/post_item.dart index d3a9f9a..3cb9a67 100644 --- a/lib/widgets/posts/post_item.dart +++ b/lib/widgets/posts/post_item.dart @@ -76,12 +76,13 @@ class _PostItemState extends State { Widget _buildHeader() { return Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ if (widget.isCompact) AccountAvatar( content: item.author.avatar.toString(), radius: 10, - ).paddingOnly(left: 2), + ).paddingOnly(left: 2, top: 1), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -108,18 +109,26 @@ class _PostItemState extends State { item.body['description'], style: Theme.of(context).textTheme.bodySmall, ), - if (item.body['description'] != null || - item.body['title'] != null) - const Divider(thickness: 0.3, height: 1).paddingSymmetric( - vertical: 8, - ), ], ).paddingOnly(left: widget.isCompact ? 6 : 12), ), + if (widget.item.type == 'article') + Badge( + label: Text('article'.tr), + ).paddingOnly(top: 3), ], ); } + Widget _buildHeaderDivider() { + if (item.body['description'] != null || item.body['title'] != null) { + return const Divider(thickness: 0.3, height: 1).paddingSymmetric( + vertical: 8, + ); + } + return const SizedBox(); + } + Widget _buildFooter() { List labels = List.empty(growable: true); if (widget.item.editedAt != null) { @@ -273,6 +282,7 @@ class _PostItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildHeader().paddingSymmetric(horizontal: 12), + _buildHeaderDivider().paddingSymmetric(horizontal: 12), Stack( children: [ SizedContainer( @@ -365,6 +375,7 @@ class _PostItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildHeader(), + _buildHeaderDivider(), Stack( children: [ SizedContainer(