Files
jourintownandintelligence 32e7f32e0a
Android / build-android (release) Successful in 2m18s
Build / build-amd64 (release) Successful in 34s
Build / build-arm64 (release) Canceled after 0s
Feat macos (#2)
---------

Co-authored-by: intelligence <intelligence@debian.local>
Co-authored-by: jourintown <jourintown@proton.me>
Reviewed-on: #2
2026-08-29 20:30:30 +02:00

78 lines
2.3 KiB
Swift

import SwiftUI
struct SettingsView: View {
@ObservedObject var model: AppModel
@ObservedObject private var settings: AppSettings
@State private var hostedKey = ""
@State private var localKey = ""
init(model: AppModel) {
self.model = model
settings = model.settings
}
var body: some View {
Form {
Section("Hosted") {
TextField(
"Endpoint", text: $settings.hostedEndpoint, prompt: Text("https://api.example.com"))
TextField("Model", text: $settings.hostedModel)
SecureField("API key", text: $hostedKey)
.onChange(of: hostedKey) { _, value in settings.hostedKey = value }
}
Section("Local fallback") {
Toggle("Hosted first, local fallback", isOn: $settings.hostedFirst)
TextField("Endpoint", text: $settings.localEndpoint)
TextField("Model", text: $settings.localModel)
SecureField("API key", text: $localKey)
.onChange(of: localKey) { _, value in settings.localKey = value }
}
Section("Transcript") {
TextField("Prompt", text: $settings.prompt, axis: .vertical)
.lineLimit(2...4)
Picker("Output", selection: $settings.destination) {
ForEach(TranscriptDestination.allCases) { destination in
Text(destination.label).tag(destination)
}
}
}
Section("Controls") {
LabeledContent("Record shortcut") {
HotkeyRecorder(shortcut: $settings.shortcut)
.frame(width: 132, height: 24)
}
if let shortcutError = model.shortcutError {
Text(shortcutError)
.font(.caption)
.foregroundStyle(.red)
}
Toggle(
"Start at login",
isOn: Binding(
get: { model.startsAtLogin },
set: model.setStartAtLogin
)
)
}
Section("Permissions") {
LabeledContent("Microphone") {
Button("Open settings", action: model.openMicrophoneSettings)
}
LabeledContent("Type at cursor") {
Button("Open Accessibility", action: model.openAccessibilitySettings)
}
}
}
.formStyle(.grouped)
.frame(width: 500, height: 620)
.onAppear {
hostedKey = settings.hostedKey
localKey = settings.localKey
}
}
}