feat(library): 收藏与观看历史支持分页

This commit is contained in:
Zhou Weidong committed 2026-10-22 12:34:27 +08:00
1 parent 63d3b0f7ca
commit 235b50598a
24 files changed
+1015 -105

No files matched your search

+38 -11
View File
@@ -16,6 +16,7 @@ import '../../core/theme/app_theme.dart';
import '../../core/widgets/app_pull_to_refresh.dart';
import '../../core/widgets/auth_gate.dart';
import '../../core/widgets/empty_state.dart';
import '../../core/widgets/paged_list_footer.dart';
import '../../core/widgets/remote_image.dart';
import '../../core/widgets/subpage_header.dart';
import '../../l10n/app_localizations.dart';
@@ -35,6 +36,7 @@ const double _metaFontSize = 11;
const double _titleFontSize = 15;
const int _maxTags = 2;
const double _emptyListHeight = 360;
const double _loadMoreThreshold = 240;
final RegExp _tagSplitter = RegExp(r'[,/、·]');
@@ -156,6 +158,15 @@ class _FavoritesBody extends StatelessWidget {
onRemove: () => _remove(context, drama.id),
),
],
PagedListFooter(
loading: favorites.loadingMore,
hasMore: favorites.hasMore,
hasItems: favorites.cards.isNotEmpty,
errorMessage: favorites.loadMoreError == null
? null
: errorText(l10n, favorites.loadMoreError, l10n.favoritesError),
onRetry: favorites.loadMore,
),
],
);
}
@@ -164,26 +175,42 @@ class _FavoritesBody extends StatelessWidget {
FavoriteController favorites, {
required List<Widget> children,
}) {
return AppPullToRefresh(
onRefresh: favorites.load,
child: ListView(
physics: AppPullToRefresh.physics,
padding: const EdgeInsets.fromLTRB(
_pageHorizontal,
4,
_pageHorizontal,
28,
return NotificationListener<ScrollNotification>(
onNotification: _onScroll,
child: AppPullToRefresh(
onRefresh: favorites.load,
child: ListView(
physics: AppPullToRefresh.physics,
padding: const EdgeInsets.fromLTRB(
_pageHorizontal,
4,
_pageHorizontal,
28,
),
children: children,
),
children: children,
),
);
}
bool _onScroll(ScrollNotification notification) {
if (notification.depth != 0) return false;
final reachedBottom =
notification.metrics.extentAfter <= _loadMoreThreshold;
if (reachedBottom &&
(notification is ScrollUpdateNotification ||
notification is ScrollEndNotification ||
notification is OverscrollNotification)) {
unawaited(favorites.loadMore());
}
return false;
}
Widget _summary(AppLocalizations l10n) {
return Align(
alignment: Alignment.centerLeft,
child: Text(
l10n.favoritesCount(favorites.cards.length),
l10n.favoritesCount(favorites.total),
key: const Key('favorites-count'),
style: const TextStyle(
color: AppColors.muted,