mirror of
https://github.com/yattee/yattee.git
synced 2026-04-10 01:26:57 +00:00
Show seek time preview when no storyboards available
Display a floating time pill above the seek bar during dragging (iOS) and dragging/hovering (macOS) when video has no storyboard thumbnails. Includes chapter name when available.
This commit is contained in:
@@ -883,6 +883,8 @@ struct PlayerControlsView: View {
|
||||
.overlay {
|
||||
if !playerState.isLive, let storyboard = playerState.preferredStoryboard {
|
||||
seekPreviewOverlay(storyboard: storyboard, geometry: geometry)
|
||||
} else if !playerState.isLive, isDragging {
|
||||
seekTimePreviewOverlay(geometry: geometry)
|
||||
}
|
||||
}
|
||||
.gesture(
|
||||
@@ -953,6 +955,25 @@ struct PlayerControlsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func seekTimePreviewOverlay(geometry: GeometryProxy) -> some View {
|
||||
let seekTime = dragProgress * playerState.duration
|
||||
let previewWidth: CGFloat = 80
|
||||
let halfWidth = previewWidth / 2
|
||||
let xPosition = max(halfWidth, min(geometry.size.width - halfWidth, geometry.size.width * dragProgress))
|
||||
let yPosition: CGFloat = -20
|
||||
|
||||
SeekTimePreviewView(
|
||||
seekTime: seekTime,
|
||||
buttonBackground: activeLayout.globalSettings.buttonBackground,
|
||||
theme: activeLayout.globalSettings.theme,
|
||||
chapters: playerState.chapters
|
||||
)
|
||||
.position(x: xPosition, y: yPosition)
|
||||
.transition(.opacity.combined(with: .scale(scale: 0.9)))
|
||||
.animation(.easeInOut(duration: 0.15), value: isDragging)
|
||||
}
|
||||
|
||||
private var displayProgress: Double {
|
||||
(isDragging || isPendingSeek) ? dragProgress : playerState.progress
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user