pi-remote-ios/Sources/UI/Settings/SettingsView.swift

49 lines
1.6 KiB
Swift

// Sources/UI/Settings/SettingsView.swift
// T-2.11: Settings sheet Face ID toggle + credential info + unpair.
import LocalAuthentication
import SwiftUI
@MainActor
struct SettingsView: View {
let credential: SidecarCredential
@EnvironmentObject var appState: AppState
@Environment(\.dismiss) var dismiss
@AppStorage("faceid.enabled") private var faceIDEnabled = false
var body: some View {
NavigationView {
Form {
Section("Security") {
Toggle("Require Face ID", isOn: $faceIDEnabled)
if faceIDEnabled {
Text("Face ID is required on launch and after 60 seconds in background.")
.font(.caption)
.foregroundStyle(.secondary)
}
}
Section("Sidecar") {
LabeledContent("Name", value: credential.sidecarName)
LabeledContent("Host", value: "\(credential.host):\(credential.port)")
LabeledContent("Paired", value: credential.pairedAt.formatted(date: .abbreviated, time: .shortened))
}
Section("Danger") {
Button("Unpair", role: .destructive) {
appState.unpair()
dismiss()
}
}
}
.navigationTitle("Settings")
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Done") { dismiss() }
}
}
}
}
}