Post show more button

This commit is contained in:
LittleSheep 2024-10-14 22:58:37 +08:00
parent 48e3b510cf
commit 063c087089
3 changed files with 35 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import 'package:solian/providers/content/posts.dart';
import 'package:solian/providers/last_read.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/loading_indicator.dart';
import 'package:solian/widgets/posts/post_action.dart';
import 'package:solian/widgets/posts/post_item.dart';
import 'package:solian/widgets/posts/post_replies.dart';
@ -40,7 +41,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
Get.find<LastReadProvider>().feedLastReadAt = _item?.id;
setState(() => _isBusy = false);
if (mounted) setState(() => _isBusy = false);
}
@override
@ -67,6 +68,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
),
SliverToBoxAdapter(
child: PostItem(
key: ValueKey(_item),
item: _item!,
isClickable: false,
isOverrideEmbedClickable: true,
@ -79,6 +81,24 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
vertical: 8,
)
: EdgeInsets.zero,
onTapMore: () {
showModalBottomSheet(
useRootNavigator: true,
context: context,
builder: (context) => PostAction(
item: _item!,
noReact: true,
),
).then((value) {
if (value is Future) {
value.then((_) {
_getDetail();
});
} else if (value != null) {
_getDetail();
}
});
},
),
),
SliverToBoxAdapter(

View File

@ -38,6 +38,7 @@ class PostItem extends StatefulWidget {
final EdgeInsets? padding;
final Function? onComment;
final Function? onTapMore;
const PostItem({
super.key,
@ -55,6 +56,7 @@ class PostItem extends StatefulWidget {
this.attachmentParent,
this.padding,
this.onComment,
this.onTapMore,
});
@override
@ -99,6 +101,7 @@ class _PostItemState extends State<PostItem> {
_PostHeaderWidget(
isCompact: widget.isCompact,
isFullDate: widget.isFullDate,
onTapMore: widget.onTapMore,
item: item,
).paddingSymmetric(horizontal: 12),
_PostHeaderDividerWidget(item: item).paddingSymmetric(horizontal: 12),
@ -161,6 +164,7 @@ class _PostItemState extends State<PostItem> {
_PostHeaderWidget(
isCompact: widget.isCompact,
isFullDate: widget.isFullDate,
onTapMore: widget.onTapMore,
item: item,
),
_PostHeaderDividerWidget(item: item),
@ -588,10 +592,13 @@ class _PostHeaderWidget extends StatelessWidget {
final bool isFullDate;
final Post item;
final Function? onTapMore;
const _PostHeaderWidget({
required this.isCompact,
required this.isFullDate,
required this.item,
required this.onTapMore,
});
@override
@ -649,10 +656,12 @@ class _PostHeaderWidget extends StatelessWidget {
],
),
),
if (item.type == 'article')
Badge(
label: Text('article'.tr),
).paddingOnly(top: 3),
if (onTapMore != null)
IconButton(
color: Theme.of(context).colorScheme.primary,
icon: const Icon(Icons.more_vert),
onPressed: () => onTapMore!(),
),
],
),
const Gap(8),

View File

@ -105,6 +105,7 @@ class PostListEntryWidget extends StatelessWidget {
isClickable: isNestedClickable,
showFeaturedReply: showFeaturedReply,
padding: padding,
onTapMore: () => _openActions(context),
onComment: () {
AppRouter.instance
.pushNamed(