2024-07-07 03:46:48 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
|
|
|
import 'package:solian/models/post.dart';
|
|
|
|
import 'package:solian/widgets/posts/post_list.dart';
|
|
|
|
|
2024-07-31 17:21:27 +00:00
|
|
|
class PostWarpedListWidget extends StatelessWidget {
|
2024-07-07 03:46:48 +00:00
|
|
|
final bool isShowEmbed;
|
|
|
|
final bool isClickable;
|
|
|
|
final bool isNestedClickable;
|
2024-07-26 10:23:51 +00:00
|
|
|
final bool isPinned;
|
2024-07-23 10:09:41 +00:00
|
|
|
final PagingController<int, Post> controller;
|
2024-08-04 10:13:59 +00:00
|
|
|
final Function? onUpdate;
|
2024-07-07 03:46:48 +00:00
|
|
|
|
2024-07-31 17:21:27 +00:00
|
|
|
const PostWarpedListWidget({
|
2024-07-07 03:46:48 +00:00
|
|
|
super.key,
|
|
|
|
required this.controller,
|
|
|
|
this.isShowEmbed = true,
|
|
|
|
this.isClickable = true,
|
|
|
|
this.isNestedClickable = true,
|
2024-07-26 10:23:51 +00:00
|
|
|
this.isPinned = true,
|
2024-08-04 10:13:59 +00:00
|
|
|
this.onUpdate,
|
2024-07-07 03:46:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-07-23 10:09:41 +00:00
|
|
|
return PagedSliverList<int, Post>.separated(
|
2024-07-11 16:44:57 +00:00
|
|
|
addRepaintBoundaries: true,
|
2024-07-07 03:46:48 +00:00
|
|
|
pagingController: controller,
|
2024-07-23 10:09:41 +00:00
|
|
|
builderDelegate: PagedChildBuilderDelegate<Post>(
|
2024-07-07 03:46:48 +00:00
|
|
|
itemBuilder: (context, item, index) {
|
2024-07-26 10:23:51 +00:00
|
|
|
if (item.pinnedAt != null && !isPinned) {
|
|
|
|
return const SizedBox();
|
|
|
|
}
|
2024-07-26 06:21:00 +00:00
|
|
|
return PostListEntryWidget(
|
2024-07-31 17:21:27 +00:00
|
|
|
renderOrder: index,
|
2024-07-26 06:21:00 +00:00
|
|
|
isShowEmbed: isShowEmbed,
|
|
|
|
isNestedClickable: isNestedClickable,
|
|
|
|
isClickable: isClickable,
|
|
|
|
item: item,
|
2024-08-04 10:13:59 +00:00
|
|
|
onUpdate: onUpdate ?? () {},
|
2024-07-07 03:46:48 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
separatorBuilder: (_, __) => const Divider(thickness: 0.3, height: 0.3),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|