🐛 Fix some bugs
This commit is contained in:
@@ -120,7 +120,8 @@ mixin AsyncPaginationController<T> on AsyncNotifier<PaginationState<T>>
|
|||||||
@override
|
@override
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
state = AsyncData(
|
state = AsyncData(
|
||||||
state.value!.copyWith(
|
PaginationState(
|
||||||
|
items: [],
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
isReloading: true,
|
isReloading: true,
|
||||||
totalCount: null,
|
totalCount: null,
|
||||||
@@ -131,8 +132,9 @@ mixin AsyncPaginationController<T> on AsyncNotifier<PaginationState<T>>
|
|||||||
|
|
||||||
final newItems = await fetch();
|
final newItems = await fetch();
|
||||||
|
|
||||||
|
if (!ref.mounted) return;
|
||||||
state = AsyncData(
|
state = AsyncData(
|
||||||
state.value!.copyWith(
|
PaginationState(
|
||||||
items: newItems,
|
items: newItems,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isReloading: false,
|
isReloading: false,
|
||||||
@@ -152,6 +154,7 @@ mixin AsyncPaginationController<T> on AsyncNotifier<PaginationState<T>>
|
|||||||
|
|
||||||
final newItems = await fetch();
|
final newItems = await fetch();
|
||||||
|
|
||||||
|
if (!ref.mounted) return;
|
||||||
state = AsyncData(
|
state = AsyncData(
|
||||||
state.value!.copyWith(
|
state.value!.copyWith(
|
||||||
items: [...state.value!.items, ...newItems],
|
items: [...state.value!.items, ...newItems],
|
||||||
@@ -168,9 +171,10 @@ mixin AsyncPaginationFilter<F, T> on AsyncPaginationController<T>
|
|||||||
if (currentFilter == filter) return;
|
if (currentFilter == filter) return;
|
||||||
|
|
||||||
state = AsyncData(
|
state = AsyncData(
|
||||||
state.value!.copyWith(
|
PaginationState(
|
||||||
isReloading: true,
|
items: [],
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
|
isReloading: true,
|
||||||
totalCount: null,
|
totalCount: null,
|
||||||
hasMore: true,
|
hasMore: true,
|
||||||
cursor: null,
|
cursor: null,
|
||||||
@@ -180,8 +184,9 @@ mixin AsyncPaginationFilter<F, T> on AsyncPaginationController<T>
|
|||||||
|
|
||||||
final newItems = await fetch();
|
final newItems = await fetch();
|
||||||
|
|
||||||
|
if (!ref.mounted) return;
|
||||||
state = AsyncData(
|
state = AsyncData(
|
||||||
state.value!.copyWith(
|
PaginationState(
|
||||||
items: newItems,
|
items: newItems,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isReloading: false,
|
isReloading: false,
|
||||||
|
|||||||
@@ -391,6 +391,8 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
? null // Post list handles its own refreshing
|
? null // Post list handles its own refreshing
|
||||||
: ref.watch(activityListProvider.notifier);
|
: ref.watch(activityListProvider.notifier);
|
||||||
|
|
||||||
|
final activityState = ref.watch(activityListProvider);
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
children: [
|
children: [
|
||||||
@@ -403,6 +405,10 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
const SliverGap(12),
|
const SliverGap(12),
|
||||||
|
if (activityState.value?.isLoading ?? false)
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: LinearProgressIndicator().padding(bottom: 8),
|
||||||
|
),
|
||||||
SliverToBoxAdapter(child: filterBar),
|
SliverToBoxAdapter(child: filterBar),
|
||||||
const SliverGap(8),
|
const SliverGap(8),
|
||||||
bodyView,
|
bodyView,
|
||||||
@@ -604,14 +610,27 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
final notifier = ref.watch(activityListProvider.notifier);
|
final notifier = ref.watch(activityListProvider.notifier);
|
||||||
|
|
||||||
|
final activityState = ref.watch(activityListProvider);
|
||||||
|
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: ClipRRect(
|
child: Stack(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
children: [
|
||||||
child: ExtendedRefreshIndicator(
|
ClipRRect(
|
||||||
onRefresh: notifier.refresh,
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
child: CustomScrollView(slivers: [SliverGap(8), bodyView]),
|
child: ExtendedRefreshIndicator(
|
||||||
),
|
onRefresh: notifier.refresh,
|
||||||
).padding(horizontal: 8),
|
child: CustomScrollView(slivers: [SliverGap(8), bodyView]),
|
||||||
|
),
|
||||||
|
).padding(horizontal: 8),
|
||||||
|
if (activityState.isLoading)
|
||||||
|
Positioned.fill(
|
||||||
|
child: Container(
|
||||||
|
color: Colors.grey.withOpacity(0.3),
|
||||||
|
child: const Center(child: CircularProgressIndicator()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user