Phase 0: menu-bar scaffold, permissions, backend health check
Native SwiftUI menu-bar app (LSUIElement, macOS 13+), generated from project.yml via XcodeGen. Includes: - PermissionsManager (Microphone / Screen Recording / Accessibility) + UI - SparkControlHealth: GET /api/status over self-signed TLS (InsecureTrustDelegate) - AppSettings persistence (host, TLS-skip, output folder, adapter toggles) - Menu-bar panel + Settings, app sandbox & hardened runtime off (LAN tool)
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
|
||||
/// Settings panel (pushed from the menu-bar panel).
|
||||
struct SettingsView: View {
|
||||
@EnvironmentObject private var settings: AppSettings
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section("SparkControl backend") {
|
||||
TextField("Base URL", text: $settings.backendBaseURL)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
Toggle("Skip TLS verification (self-signed cert)",
|
||||
isOn: $settings.skipTLSVerification)
|
||||
}
|
||||
|
||||
Section("Output") {
|
||||
HStack {
|
||||
Text(settings.outputFolderPath)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
.foregroundStyle(.secondary)
|
||||
Spacer()
|
||||
Button("Choose…", action: chooseFolder)
|
||||
}
|
||||
}
|
||||
|
||||
Section("Adapters") {
|
||||
Text("Inert in Phase 0 — these toggles only persist for now.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
ForEach(AppSettings.adapterKeys, id: \.key) { adapter in
|
||||
Toggle(adapter.label, isOn: binding(for: adapter.key))
|
||||
}
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.frame(width: 320)
|
||||
.navigationTitle("Settings")
|
||||
}
|
||||
|
||||
private func binding(for key: String) -> Binding<Bool> {
|
||||
Binding(
|
||||
get: { settings.adapterEnabled[key] ?? true },
|
||||
set: { settings.adapterEnabled[key] = $0 }
|
||||
)
|
||||
}
|
||||
|
||||
private func chooseFolder() {
|
||||
let panel = NSOpenPanel()
|
||||
panel.canChooseDirectories = true
|
||||
panel.canChooseFiles = false
|
||||
panel.allowsMultipleSelection = false
|
||||
panel.prompt = "Choose"
|
||||
panel.directoryURL = settings.outputFolderURL
|
||||
|
||||
// The app is a menu-bar accessory and this is invoked from the transient
|
||||
// MenuBarExtra(.window) popover. Use the async begin(...) API rather than
|
||||
// runModal() — a nested modal loop can let the popover dismiss the panel
|
||||
// out from under it. Activate first so the panel comes to the front.
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
panel.begin { response in
|
||||
guard response == .OK, let url = panel.url else { return }
|
||||
settings.outputFolderPath = url.path
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user