♻️ Rebuilt fetching state machine
This commit is contained in:
@@ -18,7 +18,8 @@ final indexedCloudFileListProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
IndexedCloudFileListNotifier.new,
|
IndexedCloudFileListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class IndexedCloudFileListNotifier extends AsyncNotifier<List<FileListItem>>
|
class IndexedCloudFileListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<FileListItem>>
|
||||||
with AsyncPaginationController<FileListItem> {
|
with AsyncPaginationController<FileListItem> {
|
||||||
String _currentPath = '/';
|
String _currentPath = '/';
|
||||||
String? _poolId;
|
String? _poolId;
|
||||||
@@ -51,6 +52,19 @@ class IndexedCloudFileListNotifier extends AsyncNotifier<List<FileListItem>>
|
|||||||
ref.invalidateSelf();
|
ref.invalidateSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<FileListItem>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: null,
|
||||||
|
hasMore: false,
|
||||||
|
cursor: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<FileListItem>> fetch() async {
|
Future<List<FileListItem>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
@@ -96,7 +110,8 @@ final unindexedFileListProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
UnindexedFileListNotifier.new,
|
UnindexedFileListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class UnindexedFileListNotifier extends AsyncNotifier<List<FileListItem>>
|
class UnindexedFileListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<FileListItem>>
|
||||||
with AsyncPaginationController<FileListItem> {
|
with AsyncPaginationController<FileListItem> {
|
||||||
String? _poolId;
|
String? _poolId;
|
||||||
bool _recycled = false;
|
bool _recycled = false;
|
||||||
@@ -131,6 +146,19 @@ class UnindexedFileListNotifier extends AsyncNotifier<List<FileListItem>>
|
|||||||
|
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<FileListItem>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<FileListItem>> fetch() async {
|
Future<List<FileListItem>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
|
|||||||
@@ -2,6 +2,42 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
|
||||||
|
class PaginationState<T> {
|
||||||
|
final List<T> items;
|
||||||
|
final bool isLoading;
|
||||||
|
final bool isReloading;
|
||||||
|
final int? totalCount;
|
||||||
|
final bool hasMore;
|
||||||
|
final String? cursor;
|
||||||
|
|
||||||
|
const PaginationState({
|
||||||
|
required this.items,
|
||||||
|
required this.isLoading,
|
||||||
|
required this.isReloading,
|
||||||
|
required this.totalCount,
|
||||||
|
required this.hasMore,
|
||||||
|
required this.cursor,
|
||||||
|
});
|
||||||
|
|
||||||
|
PaginationState<T> copyWith({
|
||||||
|
List<T>? items,
|
||||||
|
bool? isLoading,
|
||||||
|
bool? isReloading,
|
||||||
|
int? totalCount,
|
||||||
|
bool? hasMore,
|
||||||
|
String? cursor,
|
||||||
|
}) {
|
||||||
|
return PaginationState<T>(
|
||||||
|
items: items ?? this.items,
|
||||||
|
isLoading: isLoading ?? this.isLoading,
|
||||||
|
isReloading: isReloading ?? this.isReloading,
|
||||||
|
totalCount: totalCount ?? this.totalCount,
|
||||||
|
hasMore: hasMore ?? this.hasMore,
|
||||||
|
cursor: cursor ?? this.cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract class PaginationController<T> {
|
abstract class PaginationController<T> {
|
||||||
int? get totalCount;
|
int? get totalCount;
|
||||||
int get fetchedCount;
|
int get fetchedCount;
|
||||||
@@ -27,51 +63,84 @@ abstract class PaginationFiltered<F> {
|
|||||||
Future<void> applyFilter(F filter);
|
Future<void> applyFilter(F filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin AsyncPaginationController<T> on AsyncNotifier<List<T>>
|
mixin AsyncPaginationController<T> on AsyncNotifier<PaginationState<T>>
|
||||||
implements PaginationController<T> {
|
implements PaginationController<T> {
|
||||||
@override
|
@override
|
||||||
int? totalCount;
|
int? totalCount;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get fetchedCount => isReloading ? 0 : state.value?.length ?? 0;
|
int get fetchedCount =>
|
||||||
|
state.value?.isReloading == true ? 0 : state.value?.items.length ?? 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get fetchedAll =>
|
bool get fetchedAll =>
|
||||||
!hasMore || (totalCount != null && fetchedCount >= totalCount!);
|
!(state.value?.hasMore ?? true) ||
|
||||||
|
((state.value?.totalCount != null &&
|
||||||
|
fetchedCount >= state.value!.totalCount!));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isLoading = false;
|
bool get isLoading => state.value?.isLoading ?? false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isReloading = false;
|
bool get isReloading => state.value?.isReloading ?? false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hasMore = true;
|
bool get hasMore => state.value?.hasMore ?? true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? cursor;
|
String? get cursor => state.value?.cursor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FutureOr<List<T>> build() async {
|
set hasMore(bool value) {
|
||||||
cursor = null;
|
if (state is AsyncData) {
|
||||||
return fetch();
|
state = AsyncData((state as AsyncData).value.copyWith(hasMore: value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
set cursor(String? value) {
|
||||||
|
if (state is AsyncData) {
|
||||||
|
state = AsyncData((state as AsyncData).value.copyWith(cursor: value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<T>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
isLoading = true;
|
state = AsyncData(
|
||||||
isReloading = true;
|
state.value!.copyWith(
|
||||||
totalCount = null;
|
isLoading: true,
|
||||||
hasMore = true;
|
isReloading: true,
|
||||||
cursor = null;
|
totalCount: null,
|
||||||
state = AsyncLoading<List<T>>();
|
hasMore: true,
|
||||||
|
cursor: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final newState = await AsyncValue.guard<List<T>>(() async {
|
final newItems = await fetch();
|
||||||
return await fetch();
|
|
||||||
});
|
state = AsyncData(
|
||||||
isReloading = false;
|
state.value!.copyWith(
|
||||||
isLoading = false;
|
items: newItems,
|
||||||
state = newState;
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -79,16 +148,16 @@ mixin AsyncPaginationController<T> on AsyncNotifier<List<T>>
|
|||||||
if (fetchedAll) return;
|
if (fetchedAll) return;
|
||||||
if (isLoading) return;
|
if (isLoading) return;
|
||||||
|
|
||||||
isLoading = true;
|
state = AsyncData(state.value!.copyWith(isLoading: true));
|
||||||
state = AsyncLoading<List<T>>();
|
|
||||||
|
|
||||||
final newState = await AsyncValue.guard<List<T>>(() async {
|
final newItems = await fetch();
|
||||||
final elements = await fetch();
|
|
||||||
return [...?state.value, ...elements];
|
|
||||||
});
|
|
||||||
|
|
||||||
isLoading = false;
|
state = AsyncData(
|
||||||
state = newState;
|
state.value!.copyWith(
|
||||||
|
items: [...state.value!.items, ...newItems],
|
||||||
|
isLoading: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,20 +166,29 @@ mixin AsyncPaginationFilter<F, T> on AsyncPaginationController<T>
|
|||||||
@override
|
@override
|
||||||
Future<void> applyFilter(F filter) async {
|
Future<void> applyFilter(F filter) async {
|
||||||
if (currentFilter == filter) return;
|
if (currentFilter == filter) return;
|
||||||
// Reset the data
|
|
||||||
isReloading = true;
|
state = AsyncData(
|
||||||
isLoading = true;
|
state.value!.copyWith(
|
||||||
totalCount = null;
|
isReloading: true,
|
||||||
hasMore = true;
|
isLoading: true,
|
||||||
cursor = null;
|
totalCount: null,
|
||||||
state = AsyncLoading<List<T>>();
|
hasMore: true,
|
||||||
|
cursor: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
currentFilter = filter;
|
currentFilter = filter;
|
||||||
|
|
||||||
final newState = await AsyncValue.guard<List<T>>(() async {
|
final newItems = await fetch();
|
||||||
return await fetch();
|
|
||||||
});
|
state = AsyncData(
|
||||||
isLoading = false;
|
state.value!.copyWith(
|
||||||
isReloading = false;
|
items: newItems,
|
||||||
state = newState;
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// Post Categories Notifier
|
// Post Categories Notifier
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/post_category.dart';
|
import 'package:island/models/post_category.dart';
|
||||||
import 'package:island/models/post_tag.dart';
|
import 'package:island/models/post_tag.dart';
|
||||||
@@ -8,11 +10,25 @@ import 'package:island/pods/paging.dart';
|
|||||||
final postCategoriesProvider =
|
final postCategoriesProvider =
|
||||||
AsyncNotifierProvider.autoDispose<
|
AsyncNotifierProvider.autoDispose<
|
||||||
PostCategoriesNotifier,
|
PostCategoriesNotifier,
|
||||||
List<SnPostCategory>
|
PaginationState<SnPostCategory>
|
||||||
>(PostCategoriesNotifier.new);
|
>(PostCategoriesNotifier.new);
|
||||||
|
|
||||||
class PostCategoriesNotifier extends AsyncNotifier<List<SnPostCategory>>
|
class PostCategoriesNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnPostCategory>>
|
||||||
with AsyncPaginationController<SnPostCategory> {
|
with AsyncPaginationController<SnPostCategory> {
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnPostCategory>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnPostCategory>> fetch() async {
|
Future<List<SnPostCategory>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
@@ -30,12 +46,26 @@ class PostCategoriesNotifier extends AsyncNotifier<List<SnPostCategory>>
|
|||||||
|
|
||||||
// Post Tags Notifier
|
// Post Tags Notifier
|
||||||
final postTagsProvider =
|
final postTagsProvider =
|
||||||
AsyncNotifierProvider.autoDispose<PostTagsNotifier, List<SnPostTag>>(
|
AsyncNotifierProvider.autoDispose<
|
||||||
PostTagsNotifier.new,
|
PostTagsNotifier,
|
||||||
);
|
PaginationState<SnPostTag>
|
||||||
|
>(PostTagsNotifier.new);
|
||||||
|
|
||||||
class PostTagsNotifier extends AsyncNotifier<List<SnPostTag>>
|
class PostTagsNotifier extends AsyncNotifier<PaginationState<SnPostTag>>
|
||||||
with AsyncPaginationController<SnPostTag> {
|
with AsyncPaginationController<SnPostTag> {
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnPostTag>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnPostTag>> fetch() async {
|
Future<List<SnPostTag>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/post.dart';
|
import 'package:island/models/post.dart';
|
||||||
@@ -39,7 +41,7 @@ final postListProvider = AsyncNotifierProvider.autoDispose.family(
|
|||||||
PostListNotifier.new,
|
PostListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class PostListNotifier extends AsyncNotifier<List<SnPost>>
|
class PostListNotifier extends AsyncNotifier<PaginationState<SnPost>>
|
||||||
with
|
with
|
||||||
AsyncPaginationController<SnPost>,
|
AsyncPaginationController<SnPost>,
|
||||||
AsyncPaginationFilter<PostListQuery, SnPost> {
|
AsyncPaginationFilter<PostListQuery, SnPost> {
|
||||||
@@ -53,9 +55,17 @@ class PostListNotifier extends AsyncNotifier<List<SnPost>>
|
|||||||
late PostListQuery currentFilter;
|
late PostListQuery currentFilter;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnPost>> build() async {
|
FutureOr<PaginationState<SnPost>> build() async {
|
||||||
currentFilter = config.initialFilter;
|
currentFilter = config.initialFilter;
|
||||||
return fetch();
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/activity.dart';
|
import 'package:island/models/activity.dart';
|
||||||
import 'package:island/pods/network.dart';
|
import 'package:island/pods/network.dart';
|
||||||
@@ -7,12 +9,26 @@ final activityListProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
ActivityListNotifier.new,
|
ActivityListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class ActivityListNotifier extends AsyncNotifier<List<SnTimelineEvent>>
|
class ActivityListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnTimelineEvent>>
|
||||||
with
|
with
|
||||||
AsyncPaginationController<SnTimelineEvent>,
|
AsyncPaginationController<SnTimelineEvent>,
|
||||||
AsyncPaginationFilter<String?, SnTimelineEvent> {
|
AsyncPaginationFilter<String?, SnTimelineEvent> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnTimelineEvent>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? currentFilter;
|
String? currentFilter;
|
||||||
|
|
||||||
@@ -54,9 +70,9 @@ class ActivityListNotifier extends AsyncNotifier<List<SnTimelineEvent>>
|
|||||||
final currentState = state.value;
|
final currentState = state.value;
|
||||||
if (currentState == null) return;
|
if (currentState == null) return;
|
||||||
|
|
||||||
final updatedItems = [...currentState];
|
final updatedItems = [...currentState.items];
|
||||||
updatedItems[index] = activity;
|
updatedItems[index] = activity;
|
||||||
|
|
||||||
state = AsyncData(updatedItems);
|
state = AsyncData(currentState.copyWith(items: updatedItems));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
@@ -28,10 +30,23 @@ final socialCreditHistoryNotifierProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
);
|
);
|
||||||
|
|
||||||
class SocialCreditHistoryNotifier
|
class SocialCreditHistoryNotifier
|
||||||
extends AsyncNotifier<List<SnSocialCreditRecord>>
|
extends AsyncNotifier<PaginationState<SnSocialCreditRecord>>
|
||||||
with AsyncPaginationController<SnSocialCreditRecord> {
|
with AsyncPaginationController<SnSocialCreditRecord> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnSocialCreditRecord>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnSocialCreditRecord>> fetch() async {
|
Future<List<SnSocialCreditRecord>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
@@ -14,14 +16,30 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
import 'package:island/widgets/paging/pagination_list.dart';
|
import 'package:island/widgets/paging/pagination_list.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
final levelingHistoryNotifierProvider = AsyncNotifierProvider.autoDispose(
|
final levelingHistoryNotifierProvider =
|
||||||
LevelingHistoryNotifier.new,
|
AsyncNotifierProvider.autoDispose<
|
||||||
);
|
LevelingHistoryNotifier,
|
||||||
|
PaginationState<SnExperienceRecord>
|
||||||
|
>(LevelingHistoryNotifier.new);
|
||||||
|
|
||||||
class LevelingHistoryNotifier extends AsyncNotifier<List<SnExperienceRecord>>
|
class LevelingHistoryNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnExperienceRecord>>
|
||||||
with AsyncPaginationController<SnExperienceRecord> {
|
with AsyncPaginationController<SnExperienceRecord> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnExperienceRecord>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnExperienceRecord>> fetch() async {
|
Future<List<SnExperienceRecord>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -29,12 +31,28 @@ Future<List<SnRelationship>> sentFriendRequest(Ref ref) async {
|
|||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
final relationshipListNotifierProvider = AsyncNotifierProvider.autoDispose(
|
final relationshipListNotifierProvider =
|
||||||
RelationshipListNotifier.new,
|
AsyncNotifierProvider.autoDispose<
|
||||||
);
|
RelationshipListNotifier,
|
||||||
|
PaginationState<SnRelationship>
|
||||||
|
>(RelationshipListNotifier.new);
|
||||||
|
|
||||||
class RelationshipListNotifier extends AsyncNotifier<List<SnRelationship>>
|
class RelationshipListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnRelationship>>
|
||||||
with AsyncPaginationController<SnRelationship> {
|
with AsyncPaginationController<SnRelationship> {
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnRelationship>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnRelationship>> fetch() async {
|
Future<List<SnRelationship>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
|
|||||||
@@ -588,7 +588,8 @@ final chatMemberListProvider = AsyncNotifierProvider.autoDispose.family(
|
|||||||
ChatMemberListNotifier.new,
|
ChatMemberListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class ChatMemberListNotifier extends AsyncNotifier<List<SnChatMember>>
|
class ChatMemberListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnChatMember>>
|
||||||
with AsyncPaginationController<SnChatMember> {
|
with AsyncPaginationController<SnChatMember> {
|
||||||
static const pageSize = 20;
|
static const pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -96,13 +96,27 @@ Future<SnActorStatusResponse> publisherActorStatus(
|
|||||||
final publisherMemberListNotifierProvider = AsyncNotifierProvider.family
|
final publisherMemberListNotifierProvider = AsyncNotifierProvider.family
|
||||||
.autoDispose(PublisherMemberListNotifier.new);
|
.autoDispose(PublisherMemberListNotifier.new);
|
||||||
|
|
||||||
class PublisherMemberListNotifier extends AsyncNotifier<List<SnPublisherMember>>
|
class PublisherMemberListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnPublisherMember>>
|
||||||
with AsyncPaginationController<SnPublisherMember> {
|
with AsyncPaginationController<SnPublisherMember> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
final String arg;
|
final String arg;
|
||||||
PublisherMemberListNotifier(this.arg);
|
PublisherMemberListNotifier(this.arg);
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnPublisherMember>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnPublisherMember>> fetch() async {
|
Future<List<SnPublisherMember>> fetch() async {
|
||||||
final apiClient = ref.read(apiClientProvider);
|
final apiClient = ref.read(apiClientProvider);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ final pollListNotifierProvider = AsyncNotifierProvider.family.autoDispose(
|
|||||||
PollListNotifier.new,
|
PollListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class PollListNotifier extends AsyncNotifier<List<SnPollWithStats>>
|
class PollListNotifier extends AsyncNotifier<PaginationState<SnPollWithStats>>
|
||||||
with AsyncPaginationController<SnPollWithStats> {
|
with AsyncPaginationController<SnPollWithStats> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ final siteListNotifierProvider = AsyncNotifierProvider.family.autoDispose(
|
|||||||
SiteListNotifier.new,
|
SiteListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class SiteListNotifier extends AsyncNotifier<List<SnPublicationSite>>
|
class SiteListNotifier extends AsyncNotifier<PaginationState<SnPublicationSite>>
|
||||||
with AsyncPaginationController<SnPublicationSite> {
|
with AsyncPaginationController<SnPublicationSite> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ final stickerPacksProvider = AsyncNotifierProvider.family.autoDispose(
|
|||||||
StickerPacksNotifier.new,
|
StickerPacksNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class StickerPacksNotifier extends AsyncNotifier<List<SnStickerPack>>
|
class StickerPacksNotifier extends AsyncNotifier<PaginationState<SnStickerPack>>
|
||||||
with AsyncPaginationController<SnStickerPack> {
|
with AsyncPaginationController<SnStickerPack> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -412,11 +412,11 @@ class NotificationsCard extends HookConsumerWidget {
|
|||||||
loading: () => const SkeletonNotificationTile(),
|
loading: () => const SkeletonNotificationTile(),
|
||||||
error: (error, stack) => Center(child: Text('Error: $error')),
|
error: (error, stack) => Center(child: Text('Error: $error')),
|
||||||
data: (notificationList) {
|
data: (notificationList) {
|
||||||
if (notificationList.isEmpty) {
|
if (notificationList.items.isEmpty) {
|
||||||
return Center(child: Text('noNotificationsYet').tr());
|
return Center(child: Text('noNotificationsYet').tr());
|
||||||
}
|
}
|
||||||
// Get the most recent notification (first in the list)
|
// Get the most recent notification (first in the list)
|
||||||
final recentNotification = notificationList.first;
|
final recentNotification = notificationList.items.first;
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ final articlesListNotifierProvider = AsyncNotifierProvider.family.autoDispose(
|
|||||||
ArticlesListNotifier.new,
|
ArticlesListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class ArticlesListNotifier extends AsyncNotifier<List<SnWebArticle>>
|
class ArticlesListNotifier extends AsyncNotifier<PaginationState<SnWebArticle>>
|
||||||
with AsyncPaginationController<SnWebArticle> {
|
with AsyncPaginationController<SnWebArticle> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ final marketplaceWebFeedContentNotifierProvider = AsyncNotifierProvider.family
|
|||||||
.autoDispose(MarketplaceWebFeedContentNotifier.new);
|
.autoDispose(MarketplaceWebFeedContentNotifier.new);
|
||||||
|
|
||||||
class MarketplaceWebFeedContentNotifier
|
class MarketplaceWebFeedContentNotifier
|
||||||
extends AsyncNotifier<List<SnWebArticle>>
|
extends AsyncNotifier<PaginationState<SnWebArticle>>
|
||||||
with AsyncPaginationController<SnWebArticle> {
|
with AsyncPaginationController<SnWebArticle> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ final marketplaceWebFeedsNotifierProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
MarketplaceWebFeedsNotifier.new,
|
MarketplaceWebFeedsNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class MarketplaceWebFeedsNotifier extends AsyncNotifier<List<SnWebFeed>>
|
class MarketplaceWebFeedsNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnWebFeed>>
|
||||||
with
|
with
|
||||||
AsyncPaginationController<SnWebFeed>,
|
AsyncPaginationController<SnWebFeed>,
|
||||||
AsyncPaginationFilter<String?, SnWebFeed> {
|
AsyncPaginationFilter<String?, SnWebFeed> {
|
||||||
|
|||||||
@@ -164,10 +164,24 @@ final notificationListProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
NotificationListNotifier.new,
|
NotificationListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class NotificationListNotifier extends AsyncNotifier<List<SnNotification>>
|
class NotificationListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnNotification>>
|
||||||
with AsyncPaginationController<SnNotification> {
|
with AsyncPaginationController<SnNotification> {
|
||||||
static const int pageSize = 5;
|
static const int pageSize = 5;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnNotification>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnNotification>> fetch() async {
|
Future<List<SnNotification>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class PostSearchScreen extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (searchState.value?.isEmpty == true &&
|
if (searchState.value?.items.isEmpty == true &&
|
||||||
searchController.text.isNotEmpty &&
|
searchController.text.isNotEmpty &&
|
||||||
!searchState.isLoading)
|
!searchState.isLoading)
|
||||||
SliverFillRemaining(
|
SliverFillRemaining(
|
||||||
@@ -290,7 +290,7 @@ class PostSearchScreen extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (searchState.value?.isEmpty == true &&
|
if (searchState.value?.items.isEmpty == true &&
|
||||||
searchController.text.isNotEmpty &&
|
searchController.text.isNotEmpty &&
|
||||||
!searchState.isLoading)
|
!searchState.isLoading)
|
||||||
SliverFillRemaining(
|
SliverFillRemaining(
|
||||||
|
|||||||
@@ -492,11 +492,10 @@ class _RealmActionMenu extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final realmMemberListNotifierProvider = AsyncNotifierProvider.autoDispose
|
final realmMemberListNotifierProvider = AsyncNotifierProvider.autoDispose
|
||||||
.family<RealmMemberListNotifier, List<SnRealmMember>, String>(
|
.family(RealmMemberListNotifier.new);
|
||||||
RealmMemberListNotifier.new,
|
|
||||||
);
|
|
||||||
|
|
||||||
class RealmMemberListNotifier extends AsyncNotifier<List<SnRealmMember>>
|
class RealmMemberListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnRealmMember>>
|
||||||
with AsyncPaginationController<SnRealmMember> {
|
with AsyncPaginationController<SnRealmMember> {
|
||||||
String arg;
|
String arg;
|
||||||
RealmMemberListNotifier(this.arg);
|
RealmMemberListNotifier(this.arg);
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ sealed class MarketplaceStickerQuery with _$MarketplaceStickerQuery {
|
|||||||
final marketplaceStickerPacksNotifierProvider =
|
final marketplaceStickerPacksNotifierProvider =
|
||||||
AsyncNotifierProvider.autoDispose(MarketplaceStickerPacksNotifier.new);
|
AsyncNotifierProvider.autoDispose(MarketplaceStickerPacksNotifier.new);
|
||||||
|
|
||||||
class MarketplaceStickerPacksNotifier extends AsyncNotifier<List<SnStickerPack>>
|
class MarketplaceStickerPacksNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnStickerPack>>
|
||||||
with
|
with
|
||||||
AsyncPaginationController<SnStickerPack>,
|
AsyncPaginationController<SnStickerPack>,
|
||||||
AsyncPaginationFilter<MarketplaceStickerQuery, SnStickerPack> {
|
AsyncPaginationFilter<MarketplaceStickerQuery, SnStickerPack> {
|
||||||
|
|||||||
@@ -963,7 +963,8 @@ final transactionListProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
TransactionListNotifier.new,
|
TransactionListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class TransactionListNotifier extends AsyncNotifier<List<SnTransaction>>
|
class TransactionListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnTransaction>>
|
||||||
with AsyncPaginationController<SnTransaction> {
|
with AsyncPaginationController<SnTransaction> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
@@ -992,7 +993,7 @@ final walletFundsProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
WalletFundsNotifier.new,
|
WalletFundsNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class WalletFundsNotifier extends AsyncNotifier<List<SnWalletFund>>
|
class WalletFundsNotifier extends AsyncNotifier<PaginationState<SnWalletFund>>
|
||||||
with AsyncPaginationController<SnWalletFund> {
|
with AsyncPaginationController<SnWalletFund> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
@@ -1020,7 +1021,7 @@ final walletFundRecipientsProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
);
|
);
|
||||||
|
|
||||||
class WalletFundRecipientsNotifier
|
class WalletFundRecipientsNotifier
|
||||||
extends AsyncNotifier<List<SnWalletFundRecipient>>
|
extends AsyncNotifier<PaginationState<SnWalletFundRecipient>>
|
||||||
with AsyncPaginationController<SnWalletFundRecipient> {
|
with AsyncPaginationController<SnWalletFundRecipient> {
|
||||||
static const int _pageSize = 20;
|
static const int _pageSize = 20;
|
||||||
|
|
||||||
@@ -1484,7 +1485,7 @@ class WalletScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
return funds.when(
|
return funds.when(
|
||||||
data: (fundList) {
|
data: (fundList) {
|
||||||
if (fundList.isEmpty) {
|
if (fundList.items.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -1514,9 +1515,9 @@ class WalletScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
itemCount: fundList.length,
|
itemCount: fundList.items.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final fund = fundList[index];
|
final fund = fundList.items[index];
|
||||||
final claimedCount = fund.recipients
|
final claimedCount = fund.recipients
|
||||||
.where((r) => r.isReceived)
|
.where((r) => r.isReceived)
|
||||||
.length;
|
.length;
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ final chatCloudFileListNotifierProvider = AsyncNotifierProvider.autoDispose(
|
|||||||
ChatCloudFileListNotifier.new,
|
ChatCloudFileListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class ChatCloudFileListNotifier extends AsyncNotifier<List<SnCloudFile>>
|
class ChatCloudFileListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnCloudFile>>
|
||||||
with AsyncPaginationController<SnCloudFile> {
|
with AsyncPaginationController<SnCloudFile> {
|
||||||
@override
|
@override
|
||||||
Future<List<SnCloudFile>> fetch() async {
|
Future<List<SnCloudFile>> fetch() async {
|
||||||
@@ -31,8 +32,7 @@ class ChatCloudFileListNotifier extends AsyncNotifier<List<SnCloudFile>>
|
|||||||
queryParameters: queryParameters,
|
queryParameters: queryParameters,
|
||||||
);
|
);
|
||||||
|
|
||||||
final List<SnCloudFile> items =
|
final List<SnCloudFile> items = (response.data as List)
|
||||||
(response.data as List)
|
|
||||||
.map((e) => SnCloudFile.fromJson(e as Map<String, dynamic>))
|
.map((e) => SnCloudFile.fromJson(e as Map<String, dynamic>))
|
||||||
.toList();
|
.toList();
|
||||||
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
|
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
|
||||||
@@ -83,26 +83,22 @@ class ChatLinkAttachment extends HookConsumerWidget {
|
|||||||
width: 48,
|
width: 48,
|
||||||
child: switch (itemType) {
|
child: switch (itemType) {
|
||||||
'image' => CloudImageWidget(file: item),
|
'image' => CloudImageWidget(file: item),
|
||||||
'audio' =>
|
'audio' => const Icon(
|
||||||
const Icon(
|
|
||||||
Symbols.audio_file,
|
Symbols.audio_file,
|
||||||
fill: 1,
|
fill: 1,
|
||||||
).center(),
|
).center(),
|
||||||
'video' =>
|
'video' => const Icon(
|
||||||
const Icon(
|
|
||||||
Symbols.video_file,
|
Symbols.video_file,
|
||||||
fill: 1,
|
fill: 1,
|
||||||
).center(),
|
).center(),
|
||||||
_ =>
|
_ => const Icon(
|
||||||
const Icon(
|
|
||||||
Symbols.body_system,
|
Symbols.body_system,
|
||||||
fill: 1,
|
fill: 1,
|
||||||
).center(),
|
).center(),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title:
|
title: item.name.isEmpty
|
||||||
item.name.isEmpty
|
|
||||||
? Text('untitled').tr().italic()
|
? Text('untitled').tr().italic()
|
||||||
: Text(item.name),
|
: Text(item.name),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -128,8 +124,7 @@ class ChatLinkAttachment extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTapOutside:
|
onTapOutside: (_) =>
|
||||||
(_) =>
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
),
|
),
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import 'package:super_sliver_list/super_sliver_list.dart';
|
|||||||
import 'package:visibility_detector/visibility_detector.dart';
|
import 'package:visibility_detector/visibility_detector.dart';
|
||||||
|
|
||||||
class PaginationList<T> extends HookConsumerWidget {
|
class PaginationList<T> extends HookConsumerWidget {
|
||||||
final ProviderListenable<AsyncValue<List<T>>> provider;
|
final ProviderListenable<AsyncValue<PaginationState<T>>> provider;
|
||||||
final Refreshable<PaginationController<T>> notifier;
|
final Refreshable<PaginationController<T>> notifier;
|
||||||
final Widget? Function(BuildContext, int, T) itemBuilder;
|
final Widget? Function(BuildContext, int, T) itemBuilder;
|
||||||
final Widget? Function(BuildContext, int, T)? seperatorBuilder;
|
final Widget? Function(BuildContext, int, T)? seperatorBuilder;
|
||||||
@@ -48,7 +48,8 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
|
|
||||||
// For sliver cases, avoid animation to prevent complex sliver issues
|
// For sliver cases, avoid animation to prevent complex sliver issues
|
||||||
if (isSliver) {
|
if (isSliver) {
|
||||||
if ((data.isLoading || noti.isLoading) && data.value?.isEmpty == true) {
|
if ((data.isLoading || data.value?.isLoading == true) &&
|
||||||
|
data.value?.items.isEmpty == true) {
|
||||||
final content = List<Widget>.generate(
|
final content = List<Widget>.generate(
|
||||||
10,
|
10,
|
||||||
(_) => Skeletonizer(
|
(_) => Skeletonizer(
|
||||||
@@ -77,9 +78,9 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final listView = SuperSliverList.separated(
|
final listView = SuperSliverList.separated(
|
||||||
itemCount: (data.value?.length ?? 0) + 1,
|
itemCount: (data.value?.items.length ?? 0) + 1,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
if (idx == data.value?.length) {
|
if (idx == data.value?.items.length) {
|
||||||
return PaginationListFooter(
|
return PaginationListFooter(
|
||||||
noti: noti,
|
noti: noti,
|
||||||
data: data,
|
data: data,
|
||||||
@@ -87,13 +88,13 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
skeletonMaxWidth: footerSkeletonMaxWidth,
|
skeletonMaxWidth: footerSkeletonMaxWidth,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final entry = data.value?[idx];
|
final entry = data.value?.items[idx];
|
||||||
if (entry != null) return itemBuilder(context, idx, entry);
|
if (entry != null) return itemBuilder(context, idx, entry);
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) {
|
separatorBuilder: (context, index) {
|
||||||
if (seperatorBuilder != null) {
|
if (seperatorBuilder != null) {
|
||||||
final entry = data.value?[index];
|
final entry = data.value?.items[index];
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
return seperatorBuilder!(context, index, entry) ??
|
return seperatorBuilder!(context, index, entry) ??
|
||||||
const SizedBox();
|
const SizedBox();
|
||||||
@@ -114,7 +115,8 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
|
|
||||||
// For non-sliver cases, use AnimatedSwitcher for smooth transitions
|
// For non-sliver cases, use AnimatedSwitcher for smooth transitions
|
||||||
Widget buildContent() {
|
Widget buildContent() {
|
||||||
if ((data.isLoading || noti.isLoading) && data.value?.isEmpty == true) {
|
if ((data.isLoading || data.value?.isLoading == true) &&
|
||||||
|
data.value?.items.isEmpty == true) {
|
||||||
final content = List<Widget>.generate(
|
final content = List<Widget>.generate(
|
||||||
10,
|
10,
|
||||||
(_) => Skeletonizer(
|
(_) => Skeletonizer(
|
||||||
@@ -147,9 +149,9 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
|
|
||||||
final listView = SuperListView.separated(
|
final listView = SuperListView.separated(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
itemCount: (data.value?.length ?? 0) + 1,
|
itemCount: (data.value?.items.length ?? 0) + 1,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
if (idx == data.value?.length) {
|
if (idx == data.value?.items.length) {
|
||||||
return PaginationListFooter(
|
return PaginationListFooter(
|
||||||
noti: noti,
|
noti: noti,
|
||||||
data: data,
|
data: data,
|
||||||
@@ -157,13 +159,13 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
skeletonMaxWidth: footerSkeletonMaxWidth,
|
skeletonMaxWidth: footerSkeletonMaxWidth,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final entry = data.value?[idx];
|
final entry = data.value?.items[idx];
|
||||||
if (entry != null) return itemBuilder(context, idx, entry);
|
if (entry != null) return itemBuilder(context, idx, entry);
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) {
|
separatorBuilder: (context, index) {
|
||||||
if (seperatorBuilder != null) {
|
if (seperatorBuilder != null) {
|
||||||
final entry = data.value?[index];
|
final entry = data.value?.items[index];
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
return seperatorBuilder!(context, index, entry) ??
|
return seperatorBuilder!(context, index, entry) ??
|
||||||
const SizedBox();
|
const SizedBox();
|
||||||
@@ -193,7 +195,7 @@ class PaginationList<T> extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PaginationWidget<T> extends HookConsumerWidget {
|
class PaginationWidget<T> extends HookConsumerWidget {
|
||||||
final ProviderListenable<AsyncValue<List<T>>> provider;
|
final ProviderListenable<AsyncValue<PaginationState<T>>> provider;
|
||||||
final Refreshable<PaginationController<T>> notifier;
|
final Refreshable<PaginationController<T>> notifier;
|
||||||
final Widget Function(List<T>, Widget) contentBuilder;
|
final Widget Function(List<T>, Widget) contentBuilder;
|
||||||
final bool isRefreshable;
|
final bool isRefreshable;
|
||||||
@@ -220,7 +222,8 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
|
|
||||||
// For sliver cases, avoid animation to prevent complex sliver issues
|
// For sliver cases, avoid animation to prevent complex sliver issues
|
||||||
if (isSliver) {
|
if (isSliver) {
|
||||||
if ((data.isLoading || noti.isLoading) && data.value?.isEmpty == true) {
|
if ((data.isLoading || data.value?.isLoading == true) &&
|
||||||
|
data.value?.items.isEmpty == true) {
|
||||||
final content = List<Widget>.generate(
|
final content = List<Widget>.generate(
|
||||||
10,
|
10,
|
||||||
(_) => Skeletonizer(
|
(_) => Skeletonizer(
|
||||||
@@ -254,7 +257,7 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
skeletonChild: footerSkeletonChild,
|
skeletonChild: footerSkeletonChild,
|
||||||
skeletonMaxWidth: footerSkeletonMaxWidth,
|
skeletonMaxWidth: footerSkeletonMaxWidth,
|
||||||
);
|
);
|
||||||
final content = contentBuilder(data.value ?? [], footer);
|
final content = contentBuilder(data.value?.items ?? [], footer);
|
||||||
|
|
||||||
return isRefreshable
|
return isRefreshable
|
||||||
? ExtendedRefreshIndicator(onRefresh: noti.refresh, child: content)
|
? ExtendedRefreshIndicator(onRefresh: noti.refresh, child: content)
|
||||||
@@ -263,7 +266,8 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
|
|
||||||
// For non-sliver cases, use AnimatedSwitcher for smooth transitions
|
// For non-sliver cases, use AnimatedSwitcher for smooth transitions
|
||||||
Widget buildContent() {
|
Widget buildContent() {
|
||||||
if ((data.isLoading || noti.isLoading) && data.value?.isEmpty == true) {
|
if ((data.isLoading || data.value?.isLoading == true) &&
|
||||||
|
data.value?.items.isEmpty == true) {
|
||||||
final content = List<Widget>.generate(
|
final content = List<Widget>.generate(
|
||||||
10,
|
10,
|
||||||
(_) => Skeletonizer(
|
(_) => Skeletonizer(
|
||||||
@@ -300,7 +304,7 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
skeletonChild: footerSkeletonChild,
|
skeletonChild: footerSkeletonChild,
|
||||||
skeletonMaxWidth: footerSkeletonMaxWidth,
|
skeletonMaxWidth: footerSkeletonMaxWidth,
|
||||||
);
|
);
|
||||||
final content = contentBuilder(data.value ?? [], footer);
|
final content = contentBuilder(data.value?.items ?? [], footer);
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
key: const ValueKey('data'),
|
key: const ValueKey('data'),
|
||||||
@@ -319,7 +323,7 @@ class PaginationWidget<T> extends HookConsumerWidget {
|
|||||||
|
|
||||||
class PaginationListFooter<T> extends HookConsumerWidget {
|
class PaginationListFooter<T> extends HookConsumerWidget {
|
||||||
final PaginationController<T> noti;
|
final PaginationController<T> noti;
|
||||||
final AsyncValue<List<T>> data;
|
final AsyncValue<PaginationState<T>> data;
|
||||||
final Widget? skeletonChild;
|
final Widget? skeletonChild;
|
||||||
final double? skeletonMaxWidth;
|
final double? skeletonMaxWidth;
|
||||||
final bool isSliver;
|
final bool isSliver;
|
||||||
@@ -347,7 +351,7 @@ class PaginationListFooter<T> extends HookConsumerWidget {
|
|||||||
child: skeletonChild ?? _DefaultSkeletonChild(maxWidth: skeletonMaxWidth),
|
child: skeletonChild ?? _DefaultSkeletonChild(maxWidth: skeletonMaxWidth),
|
||||||
);
|
);
|
||||||
final child = hasBeenVisible.value
|
final child = hasBeenVisible.value
|
||||||
? data.isLoading
|
? (data.isLoading || data.value?.isLoading == true)
|
||||||
? placeholder
|
? placeholder
|
||||||
: Row(
|
: Row(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
@@ -363,7 +367,9 @@ class PaginationListFooter<T> extends HookConsumerWidget {
|
|||||||
key: Key("pagination-list-${noti.hashCode}"),
|
key: Key("pagination-list-${noti.hashCode}"),
|
||||||
onVisibilityChanged: (VisibilityInfo info) {
|
onVisibilityChanged: (VisibilityInfo info) {
|
||||||
hasBeenVisible.value = true;
|
hasBeenVisible.value = true;
|
||||||
if (!noti.fetchedAll && !data.isLoading && !data.hasError) {
|
if (!noti.fetchedAll &&
|
||||||
|
!(data.isLoading || data.value?.isLoading == true) &&
|
||||||
|
!data.hasError) {
|
||||||
if (context.mounted) noti.fetchFurther();
|
if (context.mounted) noti.fetchFurther();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,12 +15,11 @@ import 'package:island/widgets/poll/poll_stats_widget.dart';
|
|||||||
import 'package:island/widgets/response.dart';
|
import 'package:island/widgets/response.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
final pollFeedbackNotifierProvider = AsyncNotifierProvider.autoDispose
|
final pollFeedbackNotifierProvider = AsyncNotifierProvider.autoDispose.family(
|
||||||
.family<PollFeedbackNotifier, List<SnPollAnswer>, String>(
|
|
||||||
PollFeedbackNotifier.new,
|
PollFeedbackNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class PollFeedbackNotifier extends AsyncNotifier<List<SnPollAnswer>>
|
class PollFeedbackNotifier extends AsyncNotifier<PaginationState<SnPollAnswer>>
|
||||||
with AsyncPaginationController<SnPollAnswer> {
|
with AsyncPaginationController<SnPollAnswer> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
@@ -70,7 +69,8 @@ class PollFeedbackSheet extends HookConsumerWidget {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
_PollAnswerTile(answer: answer, poll: data),
|
_PollAnswerTile(answer: answer, poll: data),
|
||||||
if (index < (ref.read(provider).value?.length ?? 0) - 1)
|
if (index <
|
||||||
|
(ref.read(provider).value?.items.length ?? 0) - 1)
|
||||||
const Divider(height: 1).padding(vertical: 4),
|
const Divider(height: 1).padding(vertical: 4),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,9 +44,7 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
// Link/Select existing fund list
|
// Link/Select existing fund list
|
||||||
fundsData.when(
|
fundsData.when(
|
||||||
data:
|
data: (funds) => funds.items.isEmpty
|
||||||
(funds) =>
|
|
||||||
funds.isEmpty
|
|
||||||
? Center(
|
? Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -54,16 +52,12 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
Icon(
|
Icon(
|
||||||
Symbols.money_bag,
|
Symbols.money_bag,
|
||||||
size: 48,
|
size: 48,
|
||||||
color:
|
color: Theme.of(context).colorScheme.outline,
|
||||||
Theme.of(
|
|
||||||
context,
|
|
||||||
).colorScheme.outline,
|
|
||||||
),
|
),
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
Text(
|
Text(
|
||||||
'noFundsCreated'.tr(),
|
'noFundsCreated'.tr(),
|
||||||
style:
|
style: Theme.of(
|
||||||
Theme.of(
|
|
||||||
context,
|
context,
|
||||||
).textTheme.titleMedium,
|
).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
@@ -72,16 +66,14 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
itemCount: funds.length,
|
itemCount: funds.items.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final fund = funds[index];
|
final fund = funds.items[index];
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.only(bottom: 8),
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap:
|
onTap: () => Navigator.of(context).pop(fund),
|
||||||
() =>
|
|
||||||
Navigator.of(context).pop(fund),
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -92,8 +84,7 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
Symbols.money_bag,
|
Symbols.money_bag,
|
||||||
color:
|
color: Theme.of(
|
||||||
Theme.of(
|
|
||||||
context,
|
context,
|
||||||
).colorScheme.primary,
|
).colorScheme.primary,
|
||||||
fill: 1,
|
fill: 1,
|
||||||
@@ -104,12 +95,10 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
'${fund.totalAmount.toStringAsFixed(2)} ${fund.currency}',
|
'${fund.totalAmount.toStringAsFixed(2)} ${fund.currency}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight:
|
fontWeight: FontWeight.bold,
|
||||||
FontWeight.bold,
|
color: Theme.of(
|
||||||
color:
|
context,
|
||||||
Theme.of(context)
|
).colorScheme.primary,
|
||||||
.colorScheme
|
|
||||||
.primary,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -120,29 +109,22 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
vertical: 4,
|
vertical: 4,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color:
|
color: _getFundStatusColor(
|
||||||
_getFundStatusColor(
|
|
||||||
context,
|
context,
|
||||||
fund.status,
|
fund.status,
|
||||||
).withOpacity(0.1),
|
).withOpacity(0.1),
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius.circular(
|
BorderRadius.circular(12),
|
||||||
12,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
_getFundStatusText(
|
_getFundStatusText(fund.status),
|
||||||
fund.status,
|
|
||||||
),
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: _getFundStatusColor(
|
||||||
_getFundStatusColor(
|
|
||||||
context,
|
context,
|
||||||
fund.status,
|
fund.status,
|
||||||
),
|
),
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight:
|
fontWeight: FontWeight.w600,
|
||||||
FontWeight.w600,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -153,8 +135,7 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
const Gap(8),
|
const Gap(8),
|
||||||
Text(
|
Text(
|
||||||
fund.message!,
|
fund.message!,
|
||||||
style:
|
style: Theme.of(
|
||||||
Theme.of(
|
|
||||||
context,
|
context,
|
||||||
).textTheme.bodyMedium,
|
).textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
@@ -162,13 +143,13 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
const Gap(8),
|
const Gap(8),
|
||||||
Text(
|
Text(
|
||||||
'${'recipients'.tr()}: ${fund.recipients.where((r) => r.isReceived).length}/${fund.recipients.length}',
|
'${'recipients'.tr()}: ${fund.recipients.where((r) => r.isReceived).length}/${fund.recipients.length}',
|
||||||
style: Theme.of(
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodySmall
|
||||||
|
?.copyWith(
|
||||||
|
color: Theme.of(
|
||||||
context,
|
context,
|
||||||
).textTheme.bodySmall?.copyWith(
|
).colorScheme.onSurfaceVariant,
|
||||||
color:
|
|
||||||
Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSurfaceVariant,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -178,10 +159,10 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
loading:
|
loading: () =>
|
||||||
() => const Center(child: CircularProgressIndicator()),
|
const Center(child: CircularProgressIndicator()),
|
||||||
error:
|
error: (error, stack) =>
|
||||||
(error, stack) => Center(child: Text('Error: $error')),
|
Center(child: Text('Error: $error')),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Create new fund and return it
|
// Create new fund and return it
|
||||||
@@ -208,8 +189,7 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
Align(
|
Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: FilledButton.icon(
|
child: FilledButton.icon(
|
||||||
icon:
|
icon: isPushing.value
|
||||||
isPushing.value
|
|
||||||
? const SizedBox(
|
? const SizedBox(
|
||||||
width: 18,
|
width: 18,
|
||||||
height: 18,
|
height: 18,
|
||||||
@@ -220,22 +200,21 @@ class ComposeFundSheet extends HookConsumerWidget {
|
|||||||
)
|
)
|
||||||
: const Icon(Symbols.add_circle),
|
: const Icon(Symbols.add_circle),
|
||||||
label: Text('create'.tr()),
|
label: Text('create'.tr()),
|
||||||
onPressed:
|
onPressed: isPushing.value
|
||||||
isPushing.value
|
|
||||||
? null
|
? null
|
||||||
: () async {
|
: () async {
|
||||||
errorText.value = null;
|
errorText.value = null;
|
||||||
|
|
||||||
isPushing.value = true;
|
isPushing.value = true;
|
||||||
// Show modal bottom sheet with fund creation form and await result
|
// Show modal bottom sheet with fund creation form and await result
|
||||||
final result = await showModalBottomSheet<
|
final result =
|
||||||
|
await showModalBottomSheet<
|
||||||
Map<String, dynamic>
|
Map<String, dynamic>
|
||||||
>(
|
>(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder:
|
builder: (context) =>
|
||||||
(context) =>
|
|
||||||
const CreateFundSheet(),
|
const CreateFundSheet(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,11 @@ import 'package:material_symbols_icons/symbols.dart';
|
|||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
final cloudFileListNotifierProvider =
|
final cloudFileListNotifierProvider = AsyncNotifierProvider.autoDispose(
|
||||||
AsyncNotifierProvider.autoDispose<CloudFileListNotifier, List<SnCloudFile>>(
|
|
||||||
CloudFileListNotifier.new,
|
CloudFileListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class CloudFileListNotifier extends AsyncNotifier<List<SnCloudFile>>
|
class CloudFileListNotifier extends AsyncNotifier<PaginationState<SnCloudFile>>
|
||||||
with AsyncPaginationController<SnCloudFile> {
|
with AsyncPaginationController<SnCloudFile> {
|
||||||
@override
|
@override
|
||||||
Future<List<SnCloudFile>> fetch() async {
|
Future<List<SnCloudFile>> fetch() async {
|
||||||
@@ -83,26 +82,22 @@ class ComposeLinkAttachment extends HookConsumerWidget {
|
|||||||
width: 48,
|
width: 48,
|
||||||
child: switch (itemType) {
|
child: switch (itemType) {
|
||||||
'image' => CloudImageWidget(file: item),
|
'image' => CloudImageWidget(file: item),
|
||||||
'audio' =>
|
'audio' => const Icon(
|
||||||
const Icon(
|
|
||||||
Symbols.audio_file,
|
Symbols.audio_file,
|
||||||
fill: 1,
|
fill: 1,
|
||||||
).center(),
|
).center(),
|
||||||
'video' =>
|
'video' => const Icon(
|
||||||
const Icon(
|
|
||||||
Symbols.video_file,
|
Symbols.video_file,
|
||||||
fill: 1,
|
fill: 1,
|
||||||
).center(),
|
).center(),
|
||||||
_ =>
|
_ => const Icon(
|
||||||
const Icon(
|
|
||||||
Symbols.body_system,
|
Symbols.body_system,
|
||||||
fill: 1,
|
fill: 1,
|
||||||
).center(),
|
).center(),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title:
|
title: item.name.isEmpty
|
||||||
item.name.isEmpty
|
|
||||||
? Text('untitled').tr().italic()
|
? Text('untitled').tr().italic()
|
||||||
: Text(item.name),
|
: Text(item.name),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -128,8 +123,7 @@ class ComposeLinkAttachment extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTapOutside:
|
onTapOutside: (_) =>
|
||||||
(_) =>
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
),
|
),
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
|
|||||||
@@ -291,7 +291,9 @@ class ComposeSettingsSheet extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
hint: Text('categories'.tr(), style: TextStyle(fontSize: 15)),
|
hint: Text('categories'.tr(), style: TextStyle(fontSize: 15)),
|
||||||
items: (postCategories.value ?? <SnPostCategory>[]).map((item) {
|
items: (postCategories.value?.items ?? <SnPostCategory>[]).map((
|
||||||
|
item,
|
||||||
|
) {
|
||||||
return DropdownMenuItem(
|
return DropdownMenuItem(
|
||||||
value: item,
|
value: item,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@@ -337,7 +339,7 @@ class ComposeSettingsSheet extends HookConsumerWidget {
|
|||||||
value: currentCategories.isEmpty ? null : currentCategories.last,
|
value: currentCategories.isEmpty ? null : currentCategories.last,
|
||||||
onChanged: (_) {},
|
onChanged: (_) {},
|
||||||
selectedItemBuilder: (context) {
|
selectedItemBuilder: (context) {
|
||||||
return (postCategories.value ?? []).map((item) {
|
return (postCategories.value?.items ?? []).map((item) {
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -6,12 +6,11 @@ import 'package:island/pods/paging.dart';
|
|||||||
import 'package:island/widgets/content/sheet.dart';
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
import 'package:island/widgets/paging/pagination_list.dart';
|
import 'package:island/widgets/paging/pagination_list.dart';
|
||||||
|
|
||||||
final postAwardListNotifierProvider = AsyncNotifierProvider.autoDispose
|
final postAwardListNotifierProvider = AsyncNotifierProvider.autoDispose.family(
|
||||||
.family<PostAwardListNotifier, List<SnPostAward>, String>(
|
|
||||||
PostAwardListNotifier.new,
|
PostAwardListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class PostAwardListNotifier extends AsyncNotifier<List<SnPostAward>>
|
class PostAwardListNotifier extends AsyncNotifier<PaginationState<SnPostAward>>
|
||||||
with AsyncPaginationController<SnPostAward> {
|
with AsyncPaginationController<SnPostAward> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ class PostAwardHistorySheet extends HookConsumerWidget {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
PostAwardItem(award: award),
|
PostAwardItem(award: award),
|
||||||
if (index < (ref.read(provider).value?.length ?? 0) - 1)
|
if (index < (ref.read(provider).value?.items.length ?? 0) - 1)
|
||||||
const Divider(height: 1),
|
const Divider(height: 1),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ sealed class ReactionListQuery with _$ReactionListQuery {
|
|||||||
}) = _ReactionListQuery;
|
}) = _ReactionListQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
final reactionListNotifierProvider = AsyncNotifierProvider.autoDispose
|
final reactionListNotifierProvider = AsyncNotifierProvider.autoDispose.family(
|
||||||
.family<ReactionListNotifier, List<SnPostReaction>, ReactionListQuery>(
|
|
||||||
ReactionListNotifier.new,
|
ReactionListNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class ReactionListNotifier extends AsyncNotifier<List<SnPostReaction>>
|
class ReactionListNotifier
|
||||||
|
extends AsyncNotifier<PaginationState<SnPostReaction>>
|
||||||
with AsyncPaginationController<SnPostReaction> {
|
with AsyncPaginationController<SnPostReaction> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ final postRepliesProvider = AsyncNotifierProvider.autoDispose.family(
|
|||||||
PostRepliesNotifier.new,
|
PostRepliesNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class PostRepliesNotifier extends AsyncNotifier<List<SnPost>>
|
class PostRepliesNotifier extends AsyncNotifier<PaginationState<SnPost>>
|
||||||
with AsyncPaginationController<SnPost> {
|
with AsyncPaginationController<SnPost> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ class PostShuffleScreen extends HookConsumerWidget {
|
|||||||
kBottomControlHeight + MediaQuery.of(context).padding.bottom,
|
kBottomControlHeight + MediaQuery.of(context).padding.bottom,
|
||||||
),
|
),
|
||||||
child: Builder(
|
child: Builder(
|
||||||
key: ValueKey(postListState.value?.length ?? 0),
|
key: ValueKey(postListState.value?.items.length ?? 0),
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
final items = postListState.value ?? [];
|
final items = postListState.value?.items ?? [];
|
||||||
if (items.isNotEmpty) {
|
if (items.isNotEmpty) {
|
||||||
return CardSwiper(
|
return CardSwiper(
|
||||||
controller: cardSwiperController,
|
controller: cardSwiperController,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/realm.dart';
|
import 'package:island/models/realm.dart';
|
||||||
@@ -8,15 +10,30 @@ import 'package:island/widgets/realm/realm_list_tile.dart';
|
|||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
final realmListNotifierProvider = AsyncNotifierProvider.autoDispose
|
final realmListNotifierProvider = AsyncNotifierProvider.autoDispose
|
||||||
.family<RealmListNotifier, List<SnRealm>, String?>(RealmListNotifier.new);
|
.family<RealmListNotifier, PaginationState<SnRealm>, String?>(
|
||||||
|
RealmListNotifier.new,
|
||||||
|
);
|
||||||
|
|
||||||
class RealmListNotifier extends AsyncNotifier<List<SnRealm>>
|
class RealmListNotifier extends AsyncNotifier<PaginationState<SnRealm>>
|
||||||
with AsyncPaginationController<SnRealm> {
|
with AsyncPaginationController<SnRealm> {
|
||||||
String? arg;
|
String? arg;
|
||||||
RealmListNotifier(this.arg);
|
RealmListNotifier(this.arg);
|
||||||
|
|
||||||
static const int _pageSize = 20;
|
static const int _pageSize = 20;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<PaginationState<SnRealm>> build() async {
|
||||||
|
final items = await fetch();
|
||||||
|
return PaginationState(
|
||||||
|
items: items,
|
||||||
|
isLoading: false,
|
||||||
|
isReloading: false,
|
||||||
|
totalCount: totalCount,
|
||||||
|
hasMore: hasMore,
|
||||||
|
cursor: cursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<SnRealm>> fetch() async {
|
Future<List<SnRealm>> fetch() async {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
|
|||||||
@@ -7,13 +7,12 @@ import 'package:island/services/time.dart';
|
|||||||
import 'package:island/widgets/content/sheet.dart';
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
import 'package:island/widgets/paging/pagination_list.dart';
|
import 'package:island/widgets/paging/pagination_list.dart';
|
||||||
|
|
||||||
final thoughtSequenceListNotifierProvider = AsyncNotifierProvider.autoDispose<
|
final thoughtSequenceListNotifierProvider = AsyncNotifierProvider.autoDispose(
|
||||||
ThoughtSequenceListNotifier,
|
ThoughtSequenceListNotifier.new,
|
||||||
List<SnThinkingSequence>
|
);
|
||||||
>(ThoughtSequenceListNotifier.new);
|
|
||||||
|
|
||||||
class ThoughtSequenceListNotifier
|
class ThoughtSequenceListNotifier
|
||||||
extends AsyncNotifier<List<SnThinkingSequence>>
|
extends AsyncNotifier<PaginationState<SnThinkingSequence>>
|
||||||
with AsyncPaginationController<SnThinkingSequence> {
|
with AsyncPaginationController<SnThinkingSequence> {
|
||||||
static const int pageSize = 20;
|
static const int pageSize = 20;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user