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