Feat macos (#2)
--------- Co-authored-by: intelligence <intelligence@debian.local> Co-authored-by: jourintown <jourintown@proton.me> Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
1 parent
136bf7cfa3
commit
32e7f32e0a
22 files changed
+1360
-7
No files matched your search
@@ -0,0 +1,77 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user