fix(player): 修复进度条拖动树稳定性

This commit is contained in:
Zhou Weidong committed 2026-10-22 20:26:58 +08:00
1 parent 5af6caea6e
commit cf6d12b7c8
6 files changed
+216 -23

No files matched your search

+3
View File
@@ -304,11 +304,13 @@ class _PlayerPageState extends State<PlayerPage>
}
void _setScrubbing(bool value) {
if (!mounted) return;
if (_scrubbing == value) return;
setState(() => _scrubbing = value);
}
void _finishFeedScrub(bool wasVisible) {
if (!mounted) return;
setState(() {
_scrubbing = false;
_chromeVisible = wasVisible;
@@ -322,6 +324,7 @@ class _PlayerPageState extends State<PlayerPage>
}
void _restoreFeedChrome() {
if (!mounted) return;
setState(() {
_scrubbing = false;
_chromeVisible = true;
+41 -17
View File
@@ -25,6 +25,7 @@ const double _railRight = 8;
const double _railGap = 12;
const double _bottomInfoInset = 32;
const double _railBottomOffset = 60;
const Duration _overlayFadeDuration = Duration(milliseconds: 120);
const List<Shadow> _boostTextShadows = [
Shadow(color: AppColors.shadow, blurRadius: 5, offset: Offset(0, 1)),
];
@@ -137,25 +138,46 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
),
),
),
if (widget.boosting)
Positioned(left: 0, right: 0, bottom: 20, child: _boostHint())
else if (widget.visible && !_scrubbing)
Positioned(
left: _pageHorizontal,
right: _railRight,
bottom: _bottomInfoInset,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child: _bottomInfo()),
const SizedBox(width: _railGap),
Padding(
padding: const EdgeInsets.only(bottom: _railBottomOffset),
child: _rail(),
),
],
Positioned(
left: _pageHorizontal,
right: _railRight,
bottom: _bottomInfoInset,
child: AnimatedOpacity(
key: const Key('home-feed-content-opacity'),
duration: _overlayFadeDuration,
opacity: widget.visible && !_scrubbing && !widget.boosting
? 1
: 0,
child: IgnorePointer(
key: const Key('home-feed-content-ignore'),
ignoring: !widget.visible || _scrubbing || widget.boosting,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child: _bottomInfo()),
const SizedBox(width: _railGap),
Padding(
padding: const EdgeInsets.only(bottom: _railBottomOffset),
child: _rail(),
),
],
),
),
),
),
Positioned(
left: 0,
right: 0,
bottom: 20,
child: AnimatedOpacity(
duration: _overlayFadeDuration,
opacity: widget.boosting ? 1 : 0,
child: IgnorePointer(
ignoring: !widget.boosting,
child: _boostHint(),
),
),
),
Positioned(
left: 0,
right: 0,
@@ -177,6 +199,7 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
}
void _startScrub() {
if (!mounted) return;
_wasVisibleBeforeScrub = widget.visible;
if (!_scrubbing) setState(() => _scrubbing = true);
widget.onScrubVisibilityChanged?.call(true);
@@ -184,6 +207,7 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
}
void _endScrub() {
if (!mounted) return;
final wasVisible = _wasVisibleBeforeScrub;
if (_scrubbing) setState(() => _scrubbing = false);
widget.onScrubVisibilityChanged?.call(false);
@@ -256,7 +256,7 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
}
void _startScrub(double fraction) {
if (_dragging) return;
if (!mounted || _dragging) return;
setState(() {
_dragging = true;
_preview = fraction.clamp(0.0, 1.0).toDouble();
@@ -265,12 +265,12 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
}
void _update(double fraction) {
if (!_dragging) return;
if (!mounted || !_dragging) return;
setState(() => _preview = fraction.clamp(0.0, 1.0).toDouble());
}
void _finishScrub() {
if (!_dragging) return;
if (!mounted || !_dragging) return;
final fraction = _preview;
setState(() {
_dragging = false;