Channel create/edit UIs only surfaced a subset of the core's vc_audio_config, and DRED was exposed nowhere. While adding it, found a latent ABI mismatch: both Swift AudioConfig and the C# VcAudioConfigNative blittable struct were one int short of the native vc_audio_config (missing the trailing `dred`), so native read past the managed struct in vc_create_channel/vc_edit_channel. - core marshaling: thread `dred` through Swift (Models/Marshaling/toNative) and C# (Structs/Models/Marshaling/VoiceCatClient) -- fixes the ABI gap + enables it - windows: add the one missing DRED checkbox to ChannelEditDialog - macos: ChannelEditSheet now exposes application, sample rate, packet loss, complexity, and DRED (was stereo/bitrate/frame/FEC/DTX only) - ios: rebuild ChannelEditView into a full create+edit form (all params); add SessionState.editChannel + an admin Edit swipe action (iOS had no edit UI) - guest nickname: add a dedicated `nickname` to SavedServer on macOS+iOS (backward-compatible Codable), shown in Guest mode, wired into the guest auth path -- guests could not set a display name on either before (only Windows) Verified: macOS + iOS (sim, arm64) xcodebuild BUILD SUCCEEDED; core ctest 22/23 (only external_pcm aborts on a pre-existing shutdown mutex race; no C++ changed).
108 lines
4.3 KiB
Swift
108 lines
4.3 KiB
Swift
import SwiftUI
|
|
|
|
struct AddServerView: View {
|
|
@Environment(AppState.self) private var appState
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
let editing: SavedServer?
|
|
|
|
@State private var host = ""
|
|
@State private var port = "7878"
|
|
@State private var authMode = SavedServer.AuthMode.guest
|
|
@State private var nickname = ""
|
|
@State private var username = ""
|
|
@State private var password = ""
|
|
@State private var savePassword = false
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
Form {
|
|
Section("Server") {
|
|
TextField("Hostname or IP", text: $host)
|
|
.textContentType(.URL)
|
|
.autocorrectionDisabled()
|
|
.textInputAutocapitalization(.never)
|
|
.accessibilityLabel("Server hostname or IP address")
|
|
TextField("Port", text: $port)
|
|
.keyboardType(.numberPad)
|
|
.accessibilityLabel("Port number")
|
|
}
|
|
|
|
Section("Authentication") {
|
|
Picker("Mode", selection: $authMode) {
|
|
Text("Guest").tag(SavedServer.AuthMode.guest)
|
|
Text("Account").tag(SavedServer.AuthMode.password)
|
|
}
|
|
.pickerStyle(.segmented)
|
|
.accessibilityLabel("Authentication mode")
|
|
|
|
if authMode == .guest {
|
|
TextField("Nickname (optional)", text: $nickname)
|
|
.autocorrectionDisabled()
|
|
.textInputAutocapitalization(.never)
|
|
.accessibilityLabel("Guest nickname, optional display name")
|
|
}
|
|
|
|
if authMode == .password {
|
|
TextField("Username", text: $username)
|
|
.textContentType(.username)
|
|
.autocorrectionDisabled()
|
|
.textInputAutocapitalization(.never)
|
|
.accessibilityLabel("Username")
|
|
SecureField("Password (optional)", text: $password)
|
|
.textContentType(.password)
|
|
.accessibilityLabel("Password, optional, leave blank to enter at connect time")
|
|
Toggle("Save password in Keychain", isOn: $savePassword)
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle(editing == nil ? "Add Server" : "Edit Server")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button("Cancel") { dismiss() }
|
|
}
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
Button("Save") { save() }
|
|
.disabled(host.trimmingCharacters(in: .whitespaces).isEmpty
|
|
|| UInt16(port) == nil)
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
if let s = editing {
|
|
host = s.host
|
|
port = "\(s.port)"
|
|
authMode = s.authMode
|
|
username = s.savedUsername
|
|
nickname = s.nickname ?? ""
|
|
}
|
|
}
|
|
}
|
|
|
|
private func save() {
|
|
let trimmedHost = host.trimmingCharacters(in: .whitespaces)
|
|
guard !trimmedHost.isEmpty, let portNum = UInt16(port) else { return }
|
|
|
|
let pw = (savePassword && authMode == .password && !password.isEmpty) ? password : nil
|
|
let trimmedNick = nickname.trimmingCharacters(in: .whitespaces)
|
|
let nick: String? = (authMode == .guest && !trimmedNick.isEmpty) ? trimmedNick : nil
|
|
|
|
if var s = editing {
|
|
s.host = trimmedHost
|
|
s.port = portNum
|
|
s.authMode = authMode
|
|
s.savedUsername = authMode == .password ? username : ""
|
|
s.nickname = nick
|
|
appState.updateServer(s, password: pw)
|
|
} else {
|
|
let s = SavedServer(host: trimmedHost, port: portNum,
|
|
authMode: authMode,
|
|
savedUsername: authMode == .password ? username : "",
|
|
nickname: nick)
|
|
appState.addServer(s, password: pw)
|
|
}
|
|
dismiss()
|
|
}
|
|
}
|