62 lines
1.8 KiB
Swift
62 lines
1.8 KiB
Swift
import SwiftUI
|
|
|
|
struct SettingsView: View {
|
|
@ObservedObject var model: AppModel
|
|
@ObservedObject private var settings: AppSettings
|
|
@State private var apiKey = ""
|
|
|
|
init(model: AppModel) {
|
|
self.model = model
|
|
settings = model.settings
|
|
}
|
|
|
|
var body: some View {
|
|
Form {
|
|
Section("Transcription") {
|
|
TextField("Endpoint", text: $settings.endpoint, prompt: Text("https://api.example.com"))
|
|
TextField("Model", text: $settings.model)
|
|
SecureField("API key", text: $apiKey)
|
|
.onChange(of: apiKey) { _, value in settings.apiKey = value }
|
|
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: 470)
|
|
.onAppear { apiKey = settings.apiKey }
|
|
}
|
|
}
|