✨ Pinned post & Total vote counts
This commit is contained in:
@ -7,6 +7,7 @@ class FeedListWidget extends StatelessWidget {
|
||||
final bool isShowEmbed;
|
||||
final bool isClickable;
|
||||
final bool isNestedClickable;
|
||||
final bool isPinned;
|
||||
final PagingController<int, Post> controller;
|
||||
|
||||
const FeedListWidget({
|
||||
@ -15,6 +16,7 @@ class FeedListWidget extends StatelessWidget {
|
||||
this.isShowEmbed = true,
|
||||
this.isClickable = true,
|
||||
this.isNestedClickable = true,
|
||||
this.isPinned = true,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -24,6 +26,9 @@ class FeedListWidget extends StatelessWidget {
|
||||
pagingController: controller,
|
||||
builderDelegate: PagedChildBuilderDelegate<Post>(
|
||||
itemBuilder: (context, item, index) {
|
||||
if (item.pinnedAt != null && !isPinned) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return PostListEntryWidget(
|
||||
isShowEmbed: isShowEmbed,
|
||||
isNestedClickable: isNestedClickable,
|
||||
|
@ -31,7 +31,8 @@ class _PostActionState extends State<PostAction> {
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
setState(() {
|
||||
_canModifyContent = auth.userProfile.value!['id'] == widget.item.author.externalId;
|
||||
_canModifyContent =
|
||||
auth.userProfile.value!['id'] == widget.item.author.externalId;
|
||||
_isBusy = false;
|
||||
});
|
||||
}
|
||||
@ -98,6 +99,21 @@ class _PostActionState extends State<PostAction> {
|
||||
if (_canModifyContent && !widget.noReact)
|
||||
const Divider(thickness: 0.3, height: 0.3)
|
||||
.paddingSymmetric(vertical: 16),
|
||||
if (_canModifyContent)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: const Icon(Icons.push_pin),
|
||||
title: Text(
|
||||
widget.item.pinnedAt == null
|
||||
? 'pinPost'.tr
|
||||
: 'unpinPost'.tr,
|
||||
),
|
||||
onTap: () async {
|
||||
final client = Get.find<AuthProvider>().configureClient('interactive');
|
||||
await client.post('/posts/${widget.item.id}/pin', {});
|
||||
Navigator.pop(context, true);
|
||||
},
|
||||
),
|
||||
if (_canModifyContent)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
|
@ -112,6 +112,12 @@ class _PostItemState extends State<PostItem> {
|
||||
),
|
||||
));
|
||||
}
|
||||
if (widget.item.pinnedAt != null) {
|
||||
widgets.add(Text(
|
||||
'postPinned'.tr,
|
||||
style: TextStyle(fontSize: 12, color: _unFocusColor),
|
||||
));
|
||||
}
|
||||
|
||||
if (widgets.isEmpty) {
|
||||
return const SizedBox();
|
||||
|
Reference in New Issue
Block a user