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/providers/last_read.dart';
import 'package:solian/theme.dart'; import 'package:solian/theme.dart';
import 'package:solian/widgets/loading_indicator.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_item.dart';
import 'package:solian/widgets/posts/post_replies.dart'; import 'package:solian/widgets/posts/post_replies.dart';
@ -40,7 +41,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
Get.find<LastReadProvider>().feedLastReadAt = _item?.id; Get.find<LastReadProvider>().feedLastReadAt = _item?.id;
setState(() => _isBusy = false); if (mounted) setState(() => _isBusy = false);
} }
@override @override
@ -67,6 +68,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: PostItem( child: PostItem(
key: ValueKey(_item),
item: _item!, item: _item!,
isClickable: false, isClickable: false,
isOverrideEmbedClickable: true, isOverrideEmbedClickable: true,
@ -79,6 +81,24 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
vertical: 8, vertical: 8,
) )
: EdgeInsets.zero, : 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( SliverToBoxAdapter(

View File

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

View File

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