From bc3401a8972deba9849eb8c4a778feafe20de3c8 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 2 Aug 2024 05:10:10 +0800 Subject: [PATCH] :bug: Fix post item color mismatch --- lib/widgets/posts/post_item.dart | 22 +++++++++++++++------- lib/widgets/posts/post_list.dart | 6 ++++++ lib/widgets/posts/post_quick_action.dart | 1 - lib/widgets/posts/post_replies.dart | 11 +++++++++-- lib/widgets/posts/post_single_display.dart | 1 + 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/lib/widgets/posts/post_item.dart b/lib/widgets/posts/post_item.dart index e0c77d7..0b3dd34 100644 --- a/lib/widgets/posts/post_item.dart +++ b/lib/widgets/posts/post_item.dart @@ -24,7 +24,8 @@ class PostItem extends StatefulWidget { final bool isShowEmbed; final bool isFullDate; final bool isContentSelectable; - final String? overrideAttachmentParent; + final String? attachmentParent; + final Color? backgroundColor; const PostItem({ super.key, @@ -36,7 +37,8 @@ class PostItem extends StatefulWidget { this.isShowEmbed = true, this.isFullDate = false, this.isContentSelectable = false, - this.overrideAttachmentParent, + this.attachmentParent, + this.backgroundColor, }); @override @@ -186,7 +188,7 @@ class _PostItemState extends State { child: PostItem( item: widget.item.replyTo!, isCompact: true, - overrideAttachmentParent: widget.item.id.toString(), + attachmentParent: widget.item.id.toString(), ).paddingSymmetric(vertical: 8), ), ], @@ -198,7 +200,9 @@ class _PostItemState extends State { post: widget.item.replyTo!, ), ), - closedColor: Theme.of(context).colorScheme.surface, + closedElevation: 0, + openElevation: 0, + closedColor: widget.backgroundColor ?? Theme.of(context).colorScheme.surface, openColor: Theme.of(context).colorScheme.surface, ); } @@ -229,7 +233,7 @@ class _PostItemState extends State { child: PostItem( item: widget.item.repostTo!, isCompact: true, - overrideAttachmentParent: widget.item.id.toString(), + attachmentParent: widget.item.id.toString(), ).paddingSymmetric(vertical: 8), ), ], @@ -241,7 +245,9 @@ class _PostItemState extends State { post: widget.item.repostTo!, ), ), - closedColor: Theme.of(context).colorScheme.surface, + closedElevation: 0, + openElevation: 0, + closedColor: widget.backgroundColor ?? Theme.of(context).colorScheme.surface, openColor: Theme.of(context).colorScheme.surface, ); } @@ -369,7 +375,9 @@ class _PostItemState extends State { post: item, ), ), - closedColor: Theme.of(context).colorScheme.surface, + closedElevation: 0, + openElevation: 0, + closedColor: widget.backgroundColor ?? Theme.of(context).colorScheme.surface, openColor: Theme.of(context).colorScheme.surface, ); } diff --git a/lib/widgets/posts/post_list.dart b/lib/widgets/posts/post_list.dart index 1dfe5c3..5d6616e 100644 --- a/lib/widgets/posts/post_list.dart +++ b/lib/widgets/posts/post_list.dart @@ -11,6 +11,7 @@ class PostListWidget extends StatelessWidget { final bool isClickable; final bool isNestedClickable; final PagingController controller; + final Color? backgroundColor; const PostListWidget({ super.key, @@ -18,6 +19,7 @@ class PostListWidget extends StatelessWidget { this.isShowEmbed = true, this.isClickable = true, this.isNestedClickable = true, + this.backgroundColor, }); @override @@ -32,6 +34,7 @@ class PostListWidget extends StatelessWidget { isNestedClickable: isNestedClickable, isClickable: isClickable, item: item, + backgroundColor: backgroundColor, onUpdate: () { controller.refresh(); }, @@ -50,6 +53,7 @@ class PostListEntryWidget extends StatelessWidget { final bool isClickable; final Post item; final Function onUpdate; + final Color? backgroundColor; const PostListEntryWidget({ super.key, @@ -59,6 +63,7 @@ class PostListEntryWidget extends StatelessWidget { required this.isClickable, required this.item, required this.onUpdate, + this.backgroundColor, }); @override @@ -69,6 +74,7 @@ class PostListEntryWidget extends StatelessWidget { item: item, isShowEmbed: isShowEmbed, isClickable: isNestedClickable, + backgroundColor: backgroundColor, ).paddingSymmetric(vertical: 8), onLongPress: () { final AuthProvider auth = Get.find(); diff --git a/lib/widgets/posts/post_quick_action.dart b/lib/widgets/posts/post_quick_action.dart index 75f22f6..ff9d7c0 100644 --- a/lib/widgets/posts/post_quick_action.dart +++ b/lib/widgets/posts/post_quick_action.dart @@ -102,7 +102,6 @@ class _PostQuickActionState extends State { onPressed: () { showModalBottomSheet( useRootNavigator: true, - backgroundColor: Theme.of(context).colorScheme.surface, context: context, builder: (context) { return PostReplyListPopup(item: widget.item); diff --git a/lib/widgets/posts/post_replies.dart b/lib/widgets/posts/post_replies.dart index c098746..7de3be8 100644 --- a/lib/widgets/posts/post_replies.dart +++ b/lib/widgets/posts/post_replies.dart @@ -8,10 +8,12 @@ import 'package:solian/widgets/posts/post_list.dart'; class PostReplyList extends StatefulWidget { final Post item; + final Color? backgroundColor; const PostReplyList({ super.key, required this.item, + this.backgroundColor, }); @override @@ -45,7 +47,6 @@ class _PostReplyListState extends State { @override void initState() { super.initState(); - _pagingController.addPageRequestListener(getReplies); } @@ -54,6 +55,7 @@ class _PostReplyListState extends State { return PostListWidget( isShowEmbed: false, controller: _pagingController, + backgroundColor: widget.backgroundColor, ); } } @@ -74,7 +76,12 @@ class PostReplyListPopup extends StatelessWidget { ).paddingOnly(left: 24, right: 24, top: 32, bottom: 16), Expanded( child: CustomScrollView( - slivers: [PostReplyList(item: item)], + slivers: [ + PostReplyList( + item: item, + backgroundColor: Theme.of(context).colorScheme.surfaceContainerLow, + ), + ], ), ), ], diff --git a/lib/widgets/posts/post_single_display.dart b/lib/widgets/posts/post_single_display.dart index 9571fe5..32cb9a1 100644 --- a/lib/widgets/posts/post_single_display.dart +++ b/lib/widgets/posts/post_single_display.dart @@ -24,6 +24,7 @@ class PostSingleDisplay extends StatelessWidget { isShowEmbed: true, isNestedClickable: true, onUpdate: onUpdate, + backgroundColor: Theme.of(context).colorScheme.surfaceContainerLow, ), ), ),