🐛 Fix post item color mismatch

This commit is contained in:
LittleSheep 2024-08-02 05:10:10 +08:00
parent 5b6a5d9046
commit bc3401a897
5 changed files with 31 additions and 10 deletions

View File

@ -24,7 +24,8 @@ class PostItem extends StatefulWidget {
final bool isShowEmbed; final bool isShowEmbed;
final bool isFullDate; final bool isFullDate;
final bool isContentSelectable; final bool isContentSelectable;
final String? overrideAttachmentParent; final String? attachmentParent;
final Color? backgroundColor;
const PostItem({ const PostItem({
super.key, super.key,
@ -36,7 +37,8 @@ class PostItem extends StatefulWidget {
this.isShowEmbed = true, this.isShowEmbed = true,
this.isFullDate = false, this.isFullDate = false,
this.isContentSelectable = false, this.isContentSelectable = false,
this.overrideAttachmentParent, this.attachmentParent,
this.backgroundColor,
}); });
@override @override
@ -186,7 +188,7 @@ class _PostItemState extends State<PostItem> {
child: PostItem( child: PostItem(
item: widget.item.replyTo!, item: widget.item.replyTo!,
isCompact: true, isCompact: true,
overrideAttachmentParent: widget.item.id.toString(), attachmentParent: widget.item.id.toString(),
).paddingSymmetric(vertical: 8), ).paddingSymmetric(vertical: 8),
), ),
], ],
@ -198,7 +200,9 @@ class _PostItemState extends State<PostItem> {
post: widget.item.replyTo!, 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, openColor: Theme.of(context).colorScheme.surface,
); );
} }
@ -229,7 +233,7 @@ class _PostItemState extends State<PostItem> {
child: PostItem( child: PostItem(
item: widget.item.repostTo!, item: widget.item.repostTo!,
isCompact: true, isCompact: true,
overrideAttachmentParent: widget.item.id.toString(), attachmentParent: widget.item.id.toString(),
).paddingSymmetric(vertical: 8), ).paddingSymmetric(vertical: 8),
), ),
], ],
@ -241,7 +245,9 @@ class _PostItemState extends State<PostItem> {
post: widget.item.repostTo!, 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, openColor: Theme.of(context).colorScheme.surface,
); );
} }
@ -369,7 +375,9 @@ class _PostItemState extends State<PostItem> {
post: item, 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, openColor: Theme.of(context).colorScheme.surface,
); );
} }

View File

@ -11,6 +11,7 @@ class PostListWidget extends StatelessWidget {
final bool isClickable; final bool isClickable;
final bool isNestedClickable; final bool isNestedClickable;
final PagingController<int, Post> controller; final PagingController<int, Post> controller;
final Color? backgroundColor;
const PostListWidget({ const PostListWidget({
super.key, super.key,
@ -18,6 +19,7 @@ class PostListWidget extends StatelessWidget {
this.isShowEmbed = true, this.isShowEmbed = true,
this.isClickable = true, this.isClickable = true,
this.isNestedClickable = true, this.isNestedClickable = true,
this.backgroundColor,
}); });
@override @override
@ -32,6 +34,7 @@ class PostListWidget extends StatelessWidget {
isNestedClickable: isNestedClickable, isNestedClickable: isNestedClickable,
isClickable: isClickable, isClickable: isClickable,
item: item, item: item,
backgroundColor: backgroundColor,
onUpdate: () { onUpdate: () {
controller.refresh(); controller.refresh();
}, },
@ -50,6 +53,7 @@ class PostListEntryWidget extends StatelessWidget {
final bool isClickable; final bool isClickable;
final Post item; final Post item;
final Function onUpdate; final Function onUpdate;
final Color? backgroundColor;
const PostListEntryWidget({ const PostListEntryWidget({
super.key, super.key,
@ -59,6 +63,7 @@ class PostListEntryWidget extends StatelessWidget {
required this.isClickable, required this.isClickable,
required this.item, required this.item,
required this.onUpdate, required this.onUpdate,
this.backgroundColor,
}); });
@override @override
@ -69,6 +74,7 @@ class PostListEntryWidget extends StatelessWidget {
item: item, item: item,
isShowEmbed: isShowEmbed, isShowEmbed: isShowEmbed,
isClickable: isNestedClickable, isClickable: isNestedClickable,
backgroundColor: backgroundColor,
).paddingSymmetric(vertical: 8), ).paddingSymmetric(vertical: 8),
onLongPress: () { onLongPress: () {
final AuthProvider auth = Get.find(); final AuthProvider auth = Get.find();

View File

@ -102,7 +102,6 @@ class _PostQuickActionState extends State<PostQuickAction> {
onPressed: () { onPressed: () {
showModalBottomSheet( showModalBottomSheet(
useRootNavigator: true, useRootNavigator: true,
backgroundColor: Theme.of(context).colorScheme.surface,
context: context, context: context,
builder: (context) { builder: (context) {
return PostReplyListPopup(item: widget.item); return PostReplyListPopup(item: widget.item);

View File

@ -8,10 +8,12 @@ import 'package:solian/widgets/posts/post_list.dart';
class PostReplyList extends StatefulWidget { class PostReplyList extends StatefulWidget {
final Post item; final Post item;
final Color? backgroundColor;
const PostReplyList({ const PostReplyList({
super.key, super.key,
required this.item, required this.item,
this.backgroundColor,
}); });
@override @override
@ -45,7 +47,6 @@ class _PostReplyListState extends State<PostReplyList> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_pagingController.addPageRequestListener(getReplies); _pagingController.addPageRequestListener(getReplies);
} }
@ -54,6 +55,7 @@ class _PostReplyListState extends State<PostReplyList> {
return PostListWidget( return PostListWidget(
isShowEmbed: false, isShowEmbed: false,
controller: _pagingController, controller: _pagingController,
backgroundColor: widget.backgroundColor,
); );
} }
} }
@ -74,7 +76,12 @@ class PostReplyListPopup extends StatelessWidget {
).paddingOnly(left: 24, right: 24, top: 32, bottom: 16), ).paddingOnly(left: 24, right: 24, top: 32, bottom: 16),
Expanded( Expanded(
child: CustomScrollView( child: CustomScrollView(
slivers: [PostReplyList(item: item)], slivers: [
PostReplyList(
item: item,
backgroundColor: Theme.of(context).colorScheme.surfaceContainerLow,
),
],
), ),
), ),
], ],

View File

@ -24,6 +24,7 @@ class PostSingleDisplay extends StatelessWidget {
isShowEmbed: true, isShowEmbed: true,
isNestedClickable: true, isNestedClickable: true,
onUpdate: onUpdate, onUpdate: onUpdate,
backgroundColor: Theme.of(context).colorScheme.surfaceContainerLow,
), ),
), ),
), ),