mirror of
https://github.com/yattee/yattee.git
synced 2026-06-27 17:14:19 +00:00
Cancel tvOS scrub with Menu button instead of seeking
Pressing Menu while scrubbing now discards the pending scrub and leaves playback time unchanged, instead of committing the seek via the focus-loss path.
This commit is contained in:
@@ -36,6 +36,9 @@ struct TVPlayerProgressBar: View {
|
||||
/// Called when the bar is focused (not scrubbing) and user presses left/right.
|
||||
/// Parameter: `forward` — true for right, false for left.
|
||||
var onRemoteSeek: ((Bool) -> Void)? = nil
|
||||
/// Parent bumps this to request the bar to cancel any in-progress scrub
|
||||
/// without performing a seek (used for the Menu button).
|
||||
var cancelScrubTrigger: UUID? = nil
|
||||
|
||||
/// Track focus state internally.
|
||||
@FocusState private var isFocused: Bool
|
||||
@@ -117,6 +120,10 @@ struct TVPlayerProgressBar: View {
|
||||
commitScrub()
|
||||
}
|
||||
}
|
||||
.onChange(of: cancelScrubTrigger) { _, newValue in
|
||||
guard newValue != nil, isScrubbing else { return }
|
||||
cancelScrub()
|
||||
}
|
||||
.animation(.easeInOut(duration: 0.2), value: isFocused)
|
||||
.animation(.easeInOut(duration: 0.1), value: isScrubbing)
|
||||
}
|
||||
@@ -389,6 +396,26 @@ struct TVPlayerProgressBar: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func cancelScrub() {
|
||||
seekTask?.cancel()
|
||||
seekTask = nil
|
||||
|
||||
let wasScrubbing = isScrubbing
|
||||
|
||||
withAnimation(.easeOut(duration: 0.15)) {
|
||||
scrubTime = nil
|
||||
isScrubbing = false
|
||||
}
|
||||
panAccumulator = 0
|
||||
dpadStreakCount = 0
|
||||
lastDPadTime = nil
|
||||
lastDPadDirection = nil
|
||||
|
||||
if wasScrubbing {
|
||||
onScrubbingChanged?(false)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Pan Gesture View
|
||||
|
||||
Reference in New Issue
Block a user