fix(home): 优化短剧列表下拉刷新体验

This commit is contained in:
Zhou Weidong committed 2026-10-22 19:11:30 +08:00
1 parent f69a27bb80
commit 7945f3ffed
8 files changed
+247 -201

No files matched your search

+25 -11
View File
@@ -10,7 +10,7 @@ import '../theme/app_colors.dart';
const double _maxPullDistance = 96;
const double _refreshThreshold = 56;
const double _indicatorHeight = 56;
const double _indicatorMaxOffset = 10;
const double _indicatorDisplacement = 40;
const Duration _arrowTurnDuration = Duration(milliseconds: 160);
const Duration _settleDuration = Duration(milliseconds: 200);
@@ -26,7 +26,7 @@ class AppPullToRefresh extends StatefulWidget {
});
static const AlwaysScrollableScrollPhysics physics =
AlwaysScrollableScrollPhysics(parent: ClampingScrollPhysics());
AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics());
final Widget child;
final Future<void> Function() onRefresh;
@@ -146,10 +146,13 @@ class _AppPullToRefreshState extends State<AppPullToRefresh>
onNotification: _onScroll,
child: AnimatedBuilder(
animation: _offsetController,
child: Listener(
onPointerUp: (_) => _release(),
onPointerCancel: (_) => _release(),
child: widget.child,
child: ScrollConfiguration(
behavior: const _NoScrollbarScrollBehavior(),
child: Listener(
onPointerUp: (_) => _release(),
onPointerCancel: (_) => _release(),
child: widget.child,
),
),
builder: (context, child) {
final offset = _offsetController.value;
@@ -160,7 +163,7 @@ class _AppPullToRefreshState extends State<AppPullToRefresh>
key: const Key('pull-refresh-content'),
offset: Offset(0, offset),
child: IgnorePointer(
ignoring: _refreshing || _retracting,
ignoring: offset > 0 || _refreshing || _retracting,
child: child,
),
),
@@ -185,7 +188,7 @@ class _AppPullToRefreshState extends State<AppPullToRefresh>
child: Opacity(
opacity: progress,
child: Transform.translate(
offset: Offset(0, _indicatorMaxOffset * progress),
offset: Offset(0, _indicatorDisplacement * progress),
child: Align(
alignment: Alignment.topCenter,
child: Padding(
@@ -206,7 +209,7 @@ class _AppPullToRefreshState extends State<AppPullToRefresh>
dimension: 18,
child: CircularProgressIndicator(
strokeWidth: 2,
color: AppColors.blue,
color: AppColors.navSelected,
),
),
l10n.refreshingLabel,
@@ -220,7 +223,7 @@ class _AppPullToRefreshState extends State<AppPullToRefresh>
child: Icon(
Icons.arrow_downward_rounded,
size: 18,
color: AppColors.blue,
color: AppColors.navSelected,
),
),
armed ? l10n.releaseToRefresh : l10n.pullToRefresh,
@@ -236,7 +239,7 @@ class _AppPullToRefreshState extends State<AppPullToRefresh>
Text(
text,
style: const TextStyle(
color: AppColors.blue,
color: AppColors.navSelected,
fontSize: 13,
fontWeight: FontWeight.w600,
),
@@ -245,3 +248,14 @@ class _AppPullToRefreshState extends State<AppPullToRefresh>
);
}
}
class _NoScrollbarScrollBehavior extends MaterialScrollBehavior {
const _NoScrollbarScrollBehavior();
@override
Widget buildScrollbar(
BuildContext context,
Widget child,
ScrollableDetails details,
) => child;
}