Solian/lib/widgets/posts/post_warped_list.dart

48 lines
1.4 KiB
Dart
Raw Normal View History

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 {
final bool isShowEmbed;
final bool isClickable;
final bool isNestedClickable;
final bool isPinned;
final PagingController<int, Post> controller;
2024-07-31 17:21:27 +00:00
const PostWarpedListWidget({
super.key,
required this.controller,
this.isShowEmbed = true,
this.isClickable = true,
this.isNestedClickable = true,
this.isPinned = true,
});
@override
Widget build(BuildContext context) {
return PagedSliverList<int, Post>.separated(
2024-07-11 16:44:57 +00:00
addRepaintBoundaries: true,
pagingController: controller,
builderDelegate: PagedChildBuilderDelegate<Post>(
itemBuilder: (context, item, index) {
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,
onUpdate: () {
controller.refresh();
},
);
},
),
separatorBuilder: (_, __) => const Divider(thickness: 0.3, height: 0.3),
);
}
}