feat: add SettingsView with API key, shortcut, mode, and latency
This commit is contained in:
parent
b26995b15b
commit
dbe3294201
1 changed files with 68 additions and 0 deletions
68
MyVoxtral/MyVoxtral/Views/SettingsView.swift
Normal file
68
MyVoxtral/MyVoxtral/Views/SettingsView.swift
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct SettingsView: View {
|
||||||
|
@ObservedObject var settings = AppSettings.shared
|
||||||
|
@State private var isRecordingShortcut = false
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Form {
|
||||||
|
Section("API") {
|
||||||
|
SecureField("Mistral API Key", text: $settings.apiKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
Section("Output") {
|
||||||
|
Picker("Mode", selection: $settings.outputMode) {
|
||||||
|
ForEach(OutputMode.allCases, id: \.self) { mode in
|
||||||
|
Text(mode.rawValue).tag(mode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.pickerStyle(.segmented)
|
||||||
|
|
||||||
|
if settings.outputMode == .cursorInjection && !CursorInjector.isAccessibilityGranted {
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "exclamationmark.triangle.fill")
|
||||||
|
.foregroundStyle(.yellow)
|
||||||
|
Text("Accessibility permission required")
|
||||||
|
.font(.caption)
|
||||||
|
Button("Grant") {
|
||||||
|
CursorInjector.promptAccessibilityPermission()
|
||||||
|
}
|
||||||
|
.font(.caption)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section("Shortcut") {
|
||||||
|
HStack {
|
||||||
|
Text("Toggle Recording:")
|
||||||
|
Spacer()
|
||||||
|
Button(isRecordingShortcut ? "Press keys..." : settings.shortcutDisplayString) {
|
||||||
|
isRecordingShortcut = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section("Latency") {
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
Text("Streaming delay: \(settings.streamingDelayMs)ms")
|
||||||
|
.font(.caption)
|
||||||
|
Slider(
|
||||||
|
value: Binding(
|
||||||
|
get: { Double(settings.streamingDelayMs) },
|
||||||
|
set: { settings.streamingDelayMs = Int($0) }
|
||||||
|
),
|
||||||
|
in: 240...2400,
|
||||||
|
step: 120
|
||||||
|
)
|
||||||
|
HStack {
|
||||||
|
Text("Fast").font(.caption2).foregroundStyle(.secondary)
|
||||||
|
Spacer()
|
||||||
|
Text("Accurate").font(.caption2).foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.formStyle(.grouped)
|
||||||
|
.frame(width: 360, height: 340)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue