Add separate glass capsule for chapter title above seek preview

Extract chapter title from inside the storyboard preview into a
standalone ChapterCapsuleView with its own glass capsule background.
The capsule follows the seek position horizontally but independently
clamps to screen edges using alignmentGuide, allowing it to be wider
than the storyboard thumbnail without going offscreen.
This commit is contained in:
Arkadiusz Fal
2026-03-28 14:00:48 +01:00
parent 3d1974930b
commit e50817c043
5 changed files with 133 additions and 78 deletions

View File

@@ -12,11 +12,6 @@ struct SeekTimePreviewView: View {
let seekTime: TimeInterval
let buttonBackground: ButtonBackgroundStyle
let theme: ControlsTheme
let chapters: [VideoChapter]
private var currentChapter: VideoChapter? {
chapters.last { $0.startTime <= seekTime }
}
private var formattedTime: String {
let totalSeconds = Int(seekTime)
@@ -32,30 +27,18 @@ struct SeekTimePreviewView: View {
}
var body: some View {
VStack(spacing: 4) {
if let chapter = currentChapter {
Text(chapter.title)
.font(.caption)
.fontWeight(.medium)
.lineLimit(1)
.truncationMode(.tail)
.foregroundStyle(.white)
.shadow(color: .black.opacity(0.8), radius: 2, x: 0, y: 1)
}
Text(formattedTime)
.font(.system(size: 16, weight: .medium))
.monospacedDigit()
.foregroundStyle(.white)
}
.padding(.vertical, 8)
.padding(.horizontal, 12)
.glassBackground(
buttonBackground.glassStyle ?? .regular,
in: .rect(cornerRadius: 8),
fallback: .ultraThinMaterial,
colorScheme: .dark
)
.shadow(radius: 4)
Text(formattedTime)
.font(.system(size: 16, weight: .medium))
.monospacedDigit()
.foregroundStyle(.white)
.padding(.vertical, 8)
.padding(.horizontal, 12)
.glassBackground(
buttonBackground.glassStyle ?? .regular,
in: .rect(cornerRadius: 8),
fallback: .ultraThinMaterial,
colorScheme: .dark
)
.shadow(radius: 4)
}
}