tv-anarchy/Sources/TVAnarchyiOS/SettingsView.swift
Natalie f0669f1ca8 feat(ios): TVAnarchyiOS app target + UI tests
(cherry picked from commit 7f8f4b0dd92358ba687f8230a922d8f316cb06e9)
2026-06-09 05:50:26 -07:00

67 lines
2.6 KiB
Swift

// Connection + playback settings. Host/port point at the bridge (plum now, black
// later); the buffer slider maps to VLCKit --network-caching.
import SwiftUI
import LilithDesignTokens
struct SettingsView: View {
@EnvironmentObject private var settings: BridgeSettings
@Environment(\.dismiss) private var dismiss
@State private var portText = ""
var body: some View {
NavigationStack {
Form {
Section("Bridge") {
LabeledContent("Host") {
TextField("127.0.0.1", text: $settings.host)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.multilineTextAlignment(.trailing)
}
LabeledContent("Port") {
TextField("8787", text: $portText)
.keyboardType(.numberPad)
.multilineTextAlignment(.trailing)
.onChange(of: portText) { _, new in
if let p = Int(new), p > 0, p < 65536 { settings.port = p }
}
}
LabeledContent("Token") {
SecureField("optional", text: $settings.token)
.multilineTextAlignment(.trailing)
}
}
Section {
VStack(alignment: .leading) {
Text("Buffer: \(settings.networkCachingMs) ms")
Slider(
value: Binding(
get: { Double(settings.networkCachingMs) },
set: { settings.networkCachingMs = Int($0) }
),
in: 300...8000,
step: 100
)
}
} header: {
Text("Playback")
} footer: {
Text("Higher buffer absorbs more network jitter but makes seeking slower. 1500 ms is a good default over the mesh.")
}
}
.navigationTitle("Settings")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Done") { dismiss() }
}
}
.onAppear { portText = String(settings.port) }
}
.preferredColorScheme(.dark)
.tint(AppColors.primary)
}
}