♻️ Replaced all list with own pagination list

This commit is contained in:
2025-12-06 02:29:11 +08:00
parent c4ac256896
commit fd79c11d18
25 changed files with 1028 additions and 3073 deletions

View File

@@ -14,9 +14,10 @@ class PostShuffleScreen extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final postListState = ref.watch(postListNotifierProvider(shuffle: true));
const params = PostListQuery(shuffle: true);
final postListState = ref.watch(postListNotifierProvider(params));
final postListNotifier = ref.watch(
postListNotifierProvider(shuffle: true).notifier,
postListNotifierProvider(params).notifier,
);
final cardSwiperController = useMemoized(() => CardSwiperController(), []);
@@ -37,12 +38,13 @@ class PostShuffleScreen extends HookConsumerWidget {
kBottomControlHeight + MediaQuery.of(context).padding.bottom,
),
child: Builder(
key: ValueKey(postListState.value?.items.length ?? 0),
key: ValueKey(postListState.valueOrNull?.length ?? 0),
builder: (context) {
if ((postListState.value?.items.length ?? 0) > 0) {
final items = postListState.valueOrNull ?? [];
if (items.isNotEmpty) {
return CardSwiper(
controller: cardSwiperController,
cardsCount: postListState.value!.items.length,
cardsCount: items.length,
isLoop: false,
cardBuilder: (
context,
@@ -60,9 +62,7 @@ class PostShuffleScreen extends HookConsumerWidget {
borderRadius: const BorderRadius.all(
Radius.circular(8),
),
child: PostActionableItem(
item: postListState.value!.items[index],
),
child: PostActionableItem(item: items[index]),
),
),
),
@@ -70,8 +70,8 @@ class PostShuffleScreen extends HookConsumerWidget {
);
},
onEnd: () async {
if (postListState.value?.hasMore ?? true) {
postListNotifier.forceRefresh();
if (!postListNotifier.fetchedAll) {
postListNotifier.fetchFurther();
}
},
);