Add UI to configure Spotify Client ID in Settings

- Add expandable Configuration section in Spotify settings
- Store Client ID in UserDefaults
- Show Connect button only when Client ID is configured
- Add helper text pointing to Spotify Developer Dashboard

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-10 20:52:31 +00:00
parent 11ee893367
commit 89e985fd39
2 changed files with 45 additions and 6 deletions

View File

@@ -12,6 +12,8 @@ import SwiftUI
struct SettingsView: View {
@EnvironmentObject private var orchestrator: ContextOrchestrator
@EnvironmentObject private var spotifyAuth: SpotifyAuthManager
@State private var isConfigExpanded: Bool = false
@State private var clientIdInput: String = ""
var body: some View {
NavigationStack {
@@ -40,6 +42,26 @@ struct SettingsView: View {
}
Section {
DisclosureGroup("Configuration", isExpanded: $isConfigExpanded) {
TextField("Client ID", text: $clientIdInput)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.font(.system(.body, design: .monospaced))
Text("Get your Client ID from developer.spotify.com/dashboard")
.font(.caption)
.foregroundStyle(.secondary)
Button("Save") {
spotifyAuth.setClientId(clientIdInput)
isConfigExpanded = false
}
.disabled(clientIdInput.trimmingCharacters(in: .whitespaces).isEmpty)
}
.onAppear {
clientIdInput = spotifyAuth.clientId
}
if spotifyAuth.isConnected {
HStack {
Label("Connected", systemImage: "checkmark.circle.fill")
@@ -52,7 +74,7 @@ struct SettingsView: View {
orchestrator.musicSource = .appleMusic
}
}
} else {
} else if spotifyAuth.isConfigured {
Button {
spotifyAuth.startAuth()
} label: {
@@ -65,6 +87,10 @@ struct SettingsView: View {
}
}
.disabled(spotifyAuth.isAuthenticating)
} else {
Text("Enter your Client ID above to connect")
.font(.callout)
.foregroundStyle(.secondary)
}
if let error = spotifyAuth.error {
@@ -75,7 +101,7 @@ struct SettingsView: View {
} header: {
Text("Spotify")
} footer: {
if !spotifyAuth.isConnected {
if !spotifyAuth.isConnected && spotifyAuth.isConfigured {
Text("Connect your Spotify account to display current track on Glass.")
}
}