style: 统一下拉与加载指示器

This commit is contained in:
Zhou Weidong committed 2026-10-22 22:07:13 +08:00
1 parent 397483d339
commit 6f1da5aa39
26 files changed
+127 -241

No files matched your search

-2
View File
@@ -176,8 +176,6 @@ class _FavoritesBody extends StatelessWidget {
],
PagedListFooter(
loading: favorites.loadingMore,
hasMore: favorites.hasMore,
hasItems: favorites.cards.isNotEmpty,
errorMessage: favorites.loadMoreError == null
? null
: errorText(l10n, favorites.loadMoreError, l10n.favoritesError),
@@ -130,8 +130,6 @@ class FollowingPagedGrid extends StatelessWidget {
SliverToBoxAdapter(
child: PagedListFooter(
loading: loadingMore,
hasMore: hasMore,
hasItems: hasItems,
errorMessage: loadMoreError,
onRetry: onLoadMore,
),
@@ -218,8 +218,6 @@ class _HomeFeedGridState extends State<HomeFeedGrid> {
padding: const EdgeInsets.only(bottom: AppDimens.spaceXl),
child: PagedListFooter(
loading: widget.feedController.loadingMore,
hasMore: widget.feedController.hasMore,
hasItems: dramas.isNotEmpty,
errorMessage: widget.feedController.lastError == null
? null
: l10n.catalogError,
@@ -192,13 +192,9 @@ class _NewReleasesPageState extends State<NewReleasesPage> {
),
PagedLoadFooter(
loading: pager.loading,
hasMore: pager.hasMore,
hasItems: pager.items.isNotEmpty,
loadMoreKey: const Key(
'new-releases-load-more',
),
noMoreKey: const Key('new-releases-no-more'),
noMoreLabel: l10n.noMore,
),
],
),
+46 -25
View File
@@ -18,6 +18,8 @@ import '../../core/widgets/empty_state.dart';
import '../../core/widgets/plain_page_scaffold.dart';
import '../../l10n/app_localizations.dart';
const double _loadMoreThreshold = 240;
/// Anonymous system notice list with pagination and detail dialog.
class NoticesPage extends StatefulWidget {
const NoticesPage({super.key});
@@ -111,29 +113,55 @@ class _NoticesPageState extends State<NoticesPage> {
}
return AppPullToRefresh(
onRefresh: _controller.refresh,
child: ListView.separated(
key: const Key('notices-list'),
physics: AppPullToRefresh.physics,
padding: const EdgeInsets.fromLTRB(16, 12, 16, 28),
itemCount: _controller.notices.length + 1,
separatorBuilder: (_, _) => const SizedBox(height: 10),
itemBuilder: (context, index) {
if (index == _controller.notices.length) return _footer(l10n);
final notice = _controller.notices[index];
return _NoticeTile(
notice: notice,
onTap: () => _showDetails(notice, l10n),
);
},
child: NotificationListener<ScrollNotification>(
onNotification: _onScroll,
child: ListView.separated(
key: const Key('notices-list'),
physics: AppPullToRefresh.physics,
padding: const EdgeInsets.fromLTRB(16, 12, 16, 28),
itemCount: _controller.notices.length + 1,
separatorBuilder: (_, _) => const SizedBox(height: 10),
itemBuilder: (context, index) {
if (index == _controller.notices.length) return _footer(l10n);
final notice = _controller.notices[index];
return _NoticeTile(
notice: notice,
onTap: () => _showDetails(notice, l10n),
);
},
),
),
);
}
bool _onScroll(ScrollNotification notification) {
if (notification.depth != 0 ||
!_controller.hasMore ||
_controller.loadingMore) {
return false;
}
if (notification.metrics.extentAfter > _loadMoreThreshold) return false;
if (notification is ScrollUpdateNotification ||
notification is ScrollEndNotification ||
notification is OverscrollNotification) {
unawaited(_controller.loadMore());
}
return false;
}
Widget _footer(AppLocalizations l10n) {
if (_controller.loadingMore) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 12),
child: Center(child: CircularProgressIndicator()),
return const SizedBox(
height: AppDimens.loadMoreIndicatorHeight,
child: Center(
child: SizedBox.square(
dimension: AppDimens.refreshSpinnerSize,
child: CircularProgressIndicator(
strokeWidth: AppDimens.refreshSpinnerStroke,
color: AppColors.textPrimary,
),
),
),
);
}
if (_controller.loadMoreError != null) {
@@ -143,14 +171,7 @@ class _NoticesPageState extends State<NoticesPage> {
label: Text(l10n.retry),
);
}
if (_controller.hasMore) {
return TextButton(
key: const Key('notices-load-more'),
onPressed: _controller.loadMore,
child: Text(l10n.loadMore),
);
}
return const SizedBox(height: 8);
return const SizedBox.shrink();
}
Future<void> _showDetails(AppNotice notice, AppLocalizations l10n) {
-4
View File
@@ -153,11 +153,7 @@ class _RankingPageState extends State<RankingPage> {
],
PagedLoadFooter(
loading: pager.loading,
hasMore: pager.hasMore,
hasItems: pager.items.isNotEmpty,
loadMoreKey: const Key('ranking-load-more'),
noMoreKey: const Key('ranking-no-more'),
noMoreLabel: l10n.noMore,
),
],
),
@@ -115,8 +115,6 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
),
child: PagedListFooter(
loading: widget.feedController.loadingMore,
hasMore: widget.feedController.hasMore,
hasItems: dramas.isNotEmpty,
errorMessage:
widget.feedController.lastError == null
? null
@@ -145,8 +145,6 @@ class _WatchRecordsBodyState extends State<_WatchRecordsBody> {
],
PagedListFooter(
loading: controller.loadingMore,
hasMore: controller.hasMore,
hasItems: controller.records.isNotEmpty,
errorMessage: controller.loadMoreError == null
? null
: errorText(l10n, controller.loadMoreError, l10n.progressError),