ui: open YouTube URLs inline on the welcome screen

This commit is contained in:
2026-10-12 14:45:02 +02:00
parent 2a75d55c98
commit e3e6a66216
2 changed files with 38 additions and 5 deletions
+37 -4
View File
@@ -1257,6 +1257,9 @@ private struct PlayerContent: View {
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@State private var showsRemainingTime = false
@State private var dropTargeted = false
@State private var showsYouTubeInput = false
@State private var youTubeURL = ""
@FocusState private var youTubeInputFocused: Bool
@State private var controlSize = CGSize(width: 440, height: 68)
// Relative offsets preserve the dragged position across resize/fullscreen.
@State private var controlOffset = CGSize.zero
@@ -1541,26 +1544,56 @@ private struct PlayerContent: View {
}
Spacer(minLength: 0)
}
HStack(spacing: 0) {
HStack(spacing: 10) {
Button(action: model.openPanel) {
Label("Open File…", systemImage: "doc")
.frame(maxWidth: .infinity, minHeight: 40)
.contentShape(Rectangle())
}
Divider().frame(height: 20).accessibilityHidden(true)
Button(action: model.openYouTubePanel) {
.background(Color(SunsetPalette.actionFill), in: RoundedRectangle(cornerRadius: 8))
Button {
showsYouTubeInput = true
youTubeInputFocused = true
} label: {
Label("YouTube URL…", systemImage: "link")
.frame(maxWidth: .infinity, minHeight: 40)
.contentShape(Rectangle())
}
.accessibilityLabel("Open YouTube URL…")
.background(Color(SunsetPalette.actionFill), in: RoundedRectangle(cornerRadius: 8))
}
.font(.system(size: 13, weight: .medium))
.foregroundStyle(Color(SunsetPalette.text))
.imageScale(.large)
.buttonStyle(.plain)
.disabled(!model.canOpen)
.background(Color(SunsetPalette.actionFill), in: RoundedRectangle(cornerRadius: 8))
if showsYouTubeInput {
HStack(spacing: 8) {
TextField("YouTube video URL", text: $youTubeURL)
.textFieldStyle(.plain)
.focused($youTubeInputFocused)
.accessibilityLabel("YouTube video URL")
.onAppear { youTubeInputFocused = true }
.onSubmit { model.openYouTube(youTubeURL) }
Button {
model.openYouTube(youTubeURL)
} label: {
Image(systemName: "arrow.right")
.frame(width: 24, height: 24)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.accessibilityLabel("Open YouTube Video")
.help("Open YouTube Video")
.disabled(youTubeURL.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
}
.font(.system(size: 13))
.foregroundStyle(Color(SunsetPalette.text))
.padding(.horizontal, 12)
.frame(height: 40)
.background(Color(SunsetPalette.actionFill), in: RoundedRectangle(cornerRadius: 8))
.disabled(!model.canOpen)
}
Text("Drop a media file or YouTube link here")
.font(.system(size: 12))
.foregroundStyle(Color(SunsetPalette.secondaryText))