Skip to content

feat(player): 增加进度条悬停和拖动时间提示 - #2722

Merged
Predidit merged 8 commits into
Predidit:mainfrom
rua103:feat/player-hover-time
Oct 20, 2026
Merged

Predidit merged 8 commits into
Predidit:mainfrom
rua103:feat/player-hover-time

Conversation

@rua103

@rua103 rua103 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

描述

为播放器进度条增加鼠标悬停时间提示,方便定位要跳转的时间点。按住拖动时持续显示目标时间,移出轨道后仍保留提示,松开或取消拖动后隐藏。

关联的 Issues

暂无

PR 类型

  • Bug 修复
  • 添加新功能
  • 重构实现
  • 文档或格式
  • 其它

AI 辅助开发

  • 没有使用 AI 辅助
  • AI 辅助开发了部分功能,但是我已检查并理解 AI 所写的代码
  • 基本上都由 AI 实现,但是我非常了解 AI 的代码与写完的产物

AI 辅助模型:

OpenAI GPT-6.1 Sol(推理强度:ultra)

提交前检查

  • 我已经填写了 PR 模板中的所有内容
  • 我已经阅读了 贡献指引 ,并遵守指引进行开发
  • 这个 PR 的功能已经经过我的测试,并且我完全理解我(或 AI)做出的改动

附注

已完成人工核验。针对性测试 12/12、全量测试 225/225 通过;静态分析通过,仅有 17 条原有 info,无错误或警告。

@rua103 rua103 changed the title Feat/player hover time Feat(player) 增加进度条悬停和拖动时间提示 Oct 17, 2026
child: LayoutBuilder(
builder: (context, constraints) {
if (_constraints != null && _constraints != constraints) {
_cancelPointer();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Any constraint change aborts an in-progress drag, including changes caused by the drag itself

In compact mode, PlayerTransportBar lays out Row[playPause, Expanded(progress), timeLabel, fullscreen]. The timeLabel text is durationToString(currentPosition) / .... During a drag, onDragUpdate → updateInteractiveSeek writes the drag target into playback.currentPosition. On a video longer than an hour, dragging across the 1:00:00 mark switches the label from MM:SS to HH:MM:SS. That makes the label wider, so the Expanded progress bar gets new constraints. This builder then calls _cancelPointer(), which sets _cancelledPointer, fires onDragCancel (resetting the position to where the drag started), and drops every later update and the final seek. The user's drag silently snaps back.

Window resizes are already handled by didChangeMetrics, so this check could be limited to hiding the hover preview, or skip the cancel while _dragging (recomputing the drag preview geometry on the next update instead).


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@rua103 rua103 changed the title Feat(player) 增加进度条悬停和拖动时间提示 Feat(player): 增加进度条悬停和拖动时间提示 Oct 17, 2026
@kilo-code-bot

kilo-code-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Since c5da97d the PR has merged upstream main and rewritten the progress bar. player_progress_hover.dart and its test are gone. Hover, drag preview, gestures and painting now all live in one widget, PlayerProgressBar. Drag end goes through handleProgressBarDragEnd(cancelled) → finishInteractiveSeek.

Both earlier findings are resolved:

  • Constraint changes cancelling a drag: the code that caused this was in the hover file, which has been deleted. The track is now recomputed from LayoutBuilder constraints on every build, and the recognizer callbacks pick up the new track.
  • Label format vs reserved width: the side-label inset is now measured from durationToString(total), the same formatter used to paint the labels, so the reserved space and the painted labels can no longer drift apart.

What I checked:

  • Drag lifecycle: a tap still seeks, because the recognizer accepts the pointer immediately. Each drag start gets exactly one drag end, including when the bar is disposed mid-drag.
  • Hover preview: it is clamped to the bar and shown only for mouse input.
  • Painting: the painter and geometry keep the old package's defaults.
  • Semantics: the slider actions still seek through onSeek.
  • Stale references: nothing still refers to the removed audio_video_progress_bar package or the old callback names.

I left out some rare edge cases as too unlikely to flag. These need multi-touch with a cancelled pointer, the bar and the video swipe gesture used at the same moment, or a position label longer than the total while the duration is still 0.

Files Reviewed (5 files)
  • lib/pages/player/player_progress_bar.dart
  • lib/pages/player/player_item.dart
  • lib/pages/player/player_item_panel.dart
  • lib/pages/player/player_transport_bar.dart
  • pubspec.yaml
  • pubspec.lock (generated, skipped)
Previous Review Summaries (4 snapshots, latest commit c5da97d)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c5da97d)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

The changes since cc30f88 replace audio_video_progress_bar with a progress bar owned by the project, PlayerProgressBar. I checked these and they match the old package:

  • the eager drag recognizer
  • the default colors and radii
  • the cancel → onEnd ordering, where the pointer-cancel Listener still sets _cancelledPointer before the recognizer's seek
  • the !_dragging constraint guard
Issue Details (click to expand)

WARNING

File Line Issue
lib/pages/player/player_progress_bar.dart 233 Side labels are painted with durationToString (05:30). PlayerProgressTrackGeometry reserves width for the package format (5:30), so the painted labels are about one digit wider than the space reserved for them.

Fix these issues in Kilo Cloud

Files Reviewed (7 files)
  • lib/pages/player/player_progress_bar.dart - 1 issue
  • lib/pages/player/player_progress_hover.dart
  • lib/pages/player/player_item_panel.dart
  • lib/pages/player/player_transport_bar.dart
  • test/player_progress_hover_test.dart
  • pubspec.yaml
  • pubspec.lock (generated, skipped)

Previous review (commit cc30f88)

Status: No Issues Found | Recommendation: Merge

The incremental changes since e6b92ce are a refactor of PlayerProgressHover, and I found no new issues:

  • Hover and drag previews now go through one _updatePreview path.
  • Preview state is a single ({position, time}) record, replacing _position/_preview/_generation. Stale post-frame callbacks are now guarded by checking _preview.
  • CompositedTransformFollower + GlobalKey is replaced by OverlayPortal.overlayChildLayoutBuilder, which uses childPaintTransform/overlaySize.
  • Text measurement is shared in a _labelSize helper.

Behavior I checked is unchanged:

  • A held drag is still cancelled when the duration changes.
  • An active drag is not cancelled by a constraint change (!_dragging guard, line 329).
  • Previews are still limited to desktop, mouse, enabled and focused input.

The earlier WARNING on line 330 (a constraint change aborting a drag) stays fixed.

Files Reviewed (2 files)
  • lib/pages/player/player_progress_hover.dart
  • test/player_progress_hover_test.dart

Previous review (commit e6b92ce)

Status: No Issues Found | Recommendation: Merge

The previous WARNING on lib/pages/player/player_progress_hover.dart is fixed. The LayoutBuilder no longer cancels the pointer when constraints change during an active drag (!_dragging guard, line 371). Resizing the compact MM:SS → HH:MM:SS label therefore no longer aborts the seek. Window and metric changes still cancel through didChangeMetrics, and the new test compact time label resizing preserves drag covers both directions for mouse and touch.

Files Reviewed (2 files)
  • lib/pages/player/player_progress_hover.dart
  • test/player_progress_hover_test.dart

Previous review (commit 6884e4e)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
lib/pages/player/player_progress_hover.dart 370 The LayoutBuilder cancels the active drag whenever constraints change. In compact mode, dragging past 1:00:00 makes the timeLabel wider (MM:SS becomes HH:MM:SS), which changes the progress bar constraints. The drag then aborts and the seek is dropped.
Files Reviewed (4 files)
  • lib/pages/player/player_progress_hover.dart - 1 issue
  • lib/pages/player/player_item_panel.dart - 0 issues
  • lib/pages/player/player_item.dart - 0 issues
  • test/player_progress_hover_test.dart - 0 issues

Fix these issues in Kilo Cloud


Reviewed by claude-opus-5.5 · Input: 276 · Output: 15K · Cached: 887.1K

@rua103 rua103 changed the title Feat(player): 增加进度条悬停和拖动时间提示 feat(player): 增加进度条悬停和拖动时间提示 Oct 17, 2026
@Predidit

Copy link
Copy Markdown
Owner

考虑移除 audio_progress_bar 依赖并收敛代码边界

@Predidit

Copy link
Copy Markdown
Owner

我们已经几乎重复实现了 audio_progress_bar ,重复引入此依赖看上去不再合适

bufferedFraction: _fractionOf(widget.buffered),
dragging: _dragValue != null,
leftLabel: widget.sideLabels
? durationToString(widget.progress)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: The side labels use a different time format from the one PlayerProgressTrackGeometry measures

The painter draws durationToString(...), which zero-pads minutes and hours (05:30, 01:02:03). PlayerProgressTrackGeometry.labelWidth (player_progress_hover.dart:35-41) still measures the format of the replaced package (5:30, 1:02:03). When the progress is under 10 minutes or at least an hour, or the total is under 10 minutes, the painted label is one digit wider than the space reserved for it. That digit is roughly 7px at 12pt, while sideLabelPadding minus the thumb overhang leaves only about 7.5px. The thumb at the track ends and the right label then nearly touch or overlap. This also changes the visible label format from the package's 5:30 style.

Build both the painted labels and labelWidth from one shared formatter, so the geometry and the painter cannot drift apart.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@rua103

rua103 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

已按建议移除 audio_video_progress_bar 依赖:

  • 进度条改为项目内实现 PlayerProgressBar,不再 import 该包
  • pubspec.yaml / pubspec.lock 已删除依赖
  • 保留悬停/拖动时间预览、拖动取消、sides 布局和原有测试场景

请再看一下这版是否满足“收敛代码边界”的要求。

rua103 and others added 2 commits October 18, 2026 23:15
Upstream replaced the local `_desktop` getter with the shared
`isDesktop()` helper and added pause-on-danmaku-edit, while this branch
replaced `ProgressBar` with the in-tree `PlayerProgressBar`.

Only the import block conflicted: keep `utils/device.dart` for
`isDesktop()` and drop the now-unused `audio_video_progress_bar`.
@Predidit
Predidit merged commit dfcf962 into Predidit:main Oct 20, 2026
1 check passed
@rua103
rua103 deleted the feat/player-hover-time branch October 20, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants