feat(macos): VoiceCatMac AppKit client + fix xcodebuild

The previous "shipped" claim was false — xcodebuild had never been run and
the macOS app source was never committed. This commit adds the 17 Swift
source files + xcodeproj and fixes three real defect classes so Debug and
Release both build clean:

1. MainWindowController.swift compile errors:
   - NSAccessibility.post arg order (element:notification:userInfo:)
   - NSAccessibilityPriorityMedium -> NSAccessibilityPriorityLevel.medium
   - StreamSummary.streamId -> .id (Identifiable conformance)
   - drop redundant VoiceCatResult.description extension
2. Linker: add -lc++ to OTHER_LDFLAGS (libvoicecat-fat.a is C++20; pure-Swift
   app target has no .cpp sources so libc++ wasn't pulled in — swift test
   passed because Package.swift testTarget has linkerSettings: c++).
3. Release config: add ONLY_ACTIVE_ARCH=YES (XCFramework only has arm64).

Verified: clean Debug + Release builds, otool -L shows libc++.1.dylib,
nm shows _vc_client_create/_vc_version_string, app launches and runs.
This commit is contained in:
2026-06-18 15:26:47 +02:00
parent b4766d2f24
commit 33169b01fa
23 changed files with 3616 additions and 4 deletions

View File

@@ -0,0 +1,209 @@
import AppKit
import VoiceCatCore
final class AccountsSheet: NSViewController {
private let client: VoiceCatClient
private var accounts: [Account] = []
private let tableView = NSTableView()
private let statusLabel = NSTextField(labelWithString: "Loading…")
init(client: VoiceCatClient) {
self.client = client
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 480, height: 340))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
refreshAccounts()
}
private func buildUI() {
let titleLabel = NSTextField(labelWithString: "Server Accounts")
titleLabel.font = .boldSystemFont(ofSize: 13)
let userCol = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("username"))
userCol.title = "Username"; userCol.width = 160
let adminCol = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("admin"))
adminCol.title = "Admin"; adminCol.width = 60
let createdCol = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("created"))
createdCol.title = "Created"; createdCol.width = 120
let loginCol = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("login"))
loginCol.title = "Last Login"; loginCol.width = 120
tableView.addTableColumn(userCol)
tableView.addTableColumn(adminCol)
tableView.addTableColumn(createdCol)
tableView.addTableColumn(loginCol)
tableView.dataSource = self; tableView.delegate = self
tableView.allowsMultipleSelection = false
tableView.setAccessibilityLabel("Server accounts")
let sv = NSScrollView()
sv.documentView = tableView; sv.hasVerticalScroller = true
sv.borderType = .bezelBorder
let refreshButton = NSButton(title: "Refresh", target: self, action: #selector(refreshClicked))
refreshButton.bezelStyle = .rounded
refreshButton.setAccessibilityLabel("Refresh account list")
let addButton = NSButton(title: "Add…", target: self, action: #selector(addClicked))
addButton.bezelStyle = .rounded
addButton.setAccessibilityLabel("Add new account")
let resetPwButton = NSButton(title: "Reset Password…", target: self, action: #selector(resetPwClicked))
resetPwButton.bezelStyle = .rounded
resetPwButton.setAccessibilityLabel("Reset selected account password")
let deleteButton = NSButton(title: "Delete…", target: self, action: #selector(deleteClicked))
deleteButton.bezelStyle = .rounded
deleteButton.setAccessibilityLabel("Delete selected account")
let doneButton = NSButton(title: "Done", target: self, action: #selector(doneClicked))
doneButton.bezelStyle = .rounded; doneButton.keyEquivalent = "\r"
doneButton.setAccessibilityLabel("Close accounts sheet")
statusLabel.textColor = .secondaryLabelColor
statusLabel.setAccessibilityLabel("Status")
let toolbar = NSStackView(views: [refreshButton, addButton, resetPwButton, deleteButton, NSView()])
toolbar.orientation = .horizontal; toolbar.spacing = 8
let bottomRow = NSStackView(views: [statusLabel, NSView(), doneButton])
bottomRow.orientation = .horizontal; bottomRow.spacing = 8
let stack = NSStackView(views: [titleLabel, sv, toolbar, bottomRow])
stack.orientation = .vertical; stack.spacing = 10
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
sv.heightAnchor.constraint(equalToConstant: 200),
])
client.onEvent = { [weak self] event in
if event.type == .accountList { self?.pullAccounts() }
}
}
private func refreshAccounts() {
statusLabel.stringValue = "Loading…"
client.requestAccountList()
}
private func pullAccounts() {
accounts = client.listAccounts()
tableView.reloadData()
statusLabel.stringValue = "\(accounts.count) account\(accounts.count == 1 ? "" : "s")"
}
@objc private func refreshClicked() { refreshAccounts() }
@objc private func addClicked() {
let sheet = InputSheet(title: "New Account", prompt: "Username:", defaultValue: "")
sheet.onComplete = { [weak self] username in
guard let self, let username, !username.isEmpty else { return }
let pwSheet = PasswordPromptSheet(prompt: "Password for \(username):")
pwSheet.onComplete = { [weak self] password in
guard let self, let password, !password.isEmpty else { return }
let r = self.client.createAccount(username, password: password)
if r == .ok {
self.statusLabel.stringValue = "Account '\(username)' created."
self.refreshAccounts()
} else {
self.statusLabel.stringValue = "Failed: \(r.description)"
}
}
self.presentAsSheet(pwSheet)
}
presentAsSheet(sheet)
}
@objc private func resetPwClicked() {
let row = tableView.selectedRow
guard row >= 0, row < accounts.count else { return }
let account = accounts[row]
let sheet = PasswordPromptSheet(prompt: "New password for \(account.username):")
sheet.onComplete = { [weak self] password in
guard let self, let password, !password.isEmpty else { return }
let r = self.client.resetPassword(account.username, newPassword: password)
self.statusLabel.stringValue = r == .ok
? "Password reset for '\(account.username)'."
: "Failed: \(r.description)"
}
presentAsSheet(sheet)
}
@objc private func deleteClicked() {
let row = tableView.selectedRow
guard row >= 0, row < accounts.count else { return }
let account = accounts[row]
let alert = NSAlert()
alert.messageText = "Delete account '\(account.username)'?"
alert.informativeText = "This cannot be undone."
alert.addButton(withTitle: "Delete"); alert.addButton(withTitle: "Cancel")
alert.alertStyle = .warning
guard let window = view.window else { return }
alert.beginSheetModal(for: window) { [weak self] response in
guard response == .alertFirstButtonReturn, let self else { return }
let r = self.client.deleteAccount(account.username)
self.statusLabel.stringValue = r == .ok
? "Account '\(account.username)' deleted."
: "Failed: \(r.description)"
if r == .ok { self.refreshAccounts() }
}
}
@objc private func doneClicked() { dismiss(nil) }
private func dateString(_ ms: UInt64) -> String {
guard ms > 0 else { return "" }
let date = Date(timeIntervalSince1970: Double(ms) / 1000.0)
return DateFormatter.localizedString(from: date, dateStyle: .short, timeStyle: .none)
}
}
// MARK: - NSTableViewDataSource / Delegate
extension AccountsSheet: NSTableViewDataSource, NSTableViewDelegate {
func numberOfRows(in tableView: NSTableView) -> Int { accounts.count }
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
let acc = accounts[row]
let id = tableColumn?.identifier ?? NSUserInterfaceItemIdentifier("cell")
let cell = tableView.makeView(withIdentifier: id, owner: nil) as? NSTableCellView
?? makeCell(id)
switch tableColumn?.identifier.rawValue {
case "username": cell.textField?.stringValue = acc.username
case "admin": cell.textField?.stringValue = acc.isAdmin ? "Yes" : ""
case "created": cell.textField?.stringValue = dateString(acc.createdAtUnixMs)
case "login": cell.textField?.stringValue = dateString(acc.lastLoginUnixMs)
default: break
}
return cell
}
private func makeCell(_ id: NSUserInterfaceItemIdentifier) -> NSTableCellView {
let cell = NSTableCellView(); cell.identifier = id
let tf = NSTextField(labelWithString: "")
tf.translatesAutoresizingMaskIntoConstraints = false
cell.addSubview(tf); cell.textField = tf
NSLayoutConstraint.activate([
tf.leadingAnchor.constraint(equalTo: cell.leadingAnchor, constant: 4),
tf.trailingAnchor.constraint(equalTo: cell.trailingAnchor, constant: -4),
tf.centerYAnchor.constraint(equalTo: cell.centerYAnchor),
])
return cell
}
}

View File

@@ -0,0 +1,154 @@
import AppKit
final class AddServerSheet: NSViewController {
var onComplete: ((SavedServer?) -> Void)?
private var editing: SavedServer?
private let hostField = NSTextField()
private let portField: NSTextField = {
let f = NSTextField()
f.stringValue = "7878"
return f
}()
private let authPicker = NSPopUpButton()
private let usernameField = NSTextField()
private let passwordField = NSSecureTextField()
private let savePwCheckbox = NSButton(checkboxWithTitle: "Save password in Keychain", target: nil, action: nil)
init(editing: SavedServer?) {
self.editing = editing
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 380, height: 260))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
if let s = editing {
hostField.stringValue = s.host
portField.stringValue = "\(s.port)"
authPicker.selectItem(withTitle: s.authMode == .guest ? "Guest" : "Account")
usernameField.stringValue = s.savedUsername ?? ""
updateAuthVisibility()
}
}
private func buildUI() {
let title = NSTextField(labelWithString: editing == nil ? "Add Server" : "Edit Server")
title.font = .boldSystemFont(ofSize: 14)
let hostLabel = NSTextField(labelWithString: "Host:")
let portLabel = NSTextField(labelWithString: "Port:")
let authLabel = NSTextField(labelWithString: "Auth:")
let userLabel = NSTextField(labelWithString: "Username:")
let pwLabel = NSTextField(labelWithString: "Password:")
hostField.placeholderString = "hostname or IP"
hostField.setAccessibilityLabel("Server hostname or IP address")
portField.setAccessibilityLabel("Server port")
authPicker.addItem(withTitle: "Guest")
authPicker.addItem(withTitle: "Account")
authPicker.target = self; authPicker.action = #selector(authChanged)
authPicker.setAccessibilityLabel("Authentication mode")
usernameField.placeholderString = "username"
usernameField.setAccessibilityLabel("Username")
passwordField.placeholderString = "leave blank to enter at connect"
passwordField.setAccessibilityLabel("Password (optional — enter at connect time if blank)")
savePwCheckbox.setAccessibilityLabel("Save password in system Keychain")
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
let saveButton = NSButton(title: "Save", target: self, action: #selector(saveClicked))
saveButton.bezelStyle = .rounded
saveButton.keyEquivalent = "\r"
saveButton.setAccessibilityLabel("Save server")
let grid = NSGridView(views: [
[hostLabel, hostField],
[portLabel, portField],
[authLabel, authPicker],
[userLabel, usernameField],
[pwLabel, passwordField],
[NSView(), savePwCheckbox],
])
grid.rowSpacing = 8
grid.columnSpacing = 8
grid.column(at: 0).xPlacement = .trailing
let buttonRow = NSStackView(views: [NSView(), cancelButton, saveButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
let stack = NSStackView(views: [title, grid, buttonRow])
stack.orientation = .vertical
stack.spacing = 16
stack.edgeInsets = NSEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
updateAuthVisibility()
}
@objc private func authChanged() { updateAuthVisibility() }
private func updateAuthVisibility() {
let isAccount = authPicker.titleOfSelectedItem == "Account"
usernameField.isEnabled = isAccount
passwordField.isEnabled = isAccount
savePwCheckbox.isEnabled = isAccount
}
@objc private func saveClicked() {
let host = hostField.stringValue.trimmingCharacters(in: .whitespaces)
guard !host.isEmpty else {
hostField.becomeFirstResponder(); return
}
let portStr = portField.stringValue.trimmingCharacters(in: .whitespaces)
guard let port = UInt16(portStr), port > 0 else {
portField.becomeFirstResponder(); return
}
let isGuest = authPicker.titleOfSelectedItem == "Guest"
var server = editing ?? SavedServer(host: host, port: port,
authMode: isGuest ? .guest : .password)
server.host = host; server.port = port
server.authMode = isGuest ? .guest : .password
server.savedUsername = isGuest ? nil : usernameField.stringValue.trimmingCharacters(in: .whitespaces)
if !isGuest && savePwCheckbox.state == .on {
let pw = passwordField.stringValue
if !pw.isEmpty {
let tag = server.keychainTag ?? "voicecat.server.\(server.id.uuidString)"
server.keychainTag = tag
ServerListStore.savePassword(pw, tag: tag)
}
} else if isGuest {
if let tag = server.keychainTag { ServerListStore.deletePassword(tag: tag) }
server.keychainTag = nil
}
dismiss(nil)
onComplete?(server)
}
@objc private func cancelClicked() {
dismiss(nil)
onComplete?(nil)
}
}

View File

@@ -0,0 +1,93 @@
import AppKit
final class BanUserSheet: NSViewController {
var onComplete: ((String?, UInt64) -> Void)?
private let targetNickname: String
private let reasonField = NSTextField()
private let durationPicker = NSSegmentedControl(
labels: ["1 hour", "24 hours", "7 days", "Permanent"],
trackingMode: .selectOne,
target: nil, action: nil
)
init(nickname: String) {
self.targetNickname = nickname
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 360, height: 160))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
}
private func buildUI() {
let titleLabel = NSTextField(labelWithString: "Ban \(targetNickname)")
titleLabel.font = .boldSystemFont(ofSize: 13)
let reasonLabel = NSTextField(labelWithString: "Reason:")
reasonField.placeholderString = "Ban reason (optional)"
reasonField.setAccessibilityLabel("Ban reason")
let durationLabel = NSTextField(labelWithString: "Duration:")
durationPicker.selectedSegment = 3
durationPicker.setAccessibilityLabel("Ban duration")
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
let banButton = NSButton(title: "Ban", target: self, action: #selector(banClicked))
banButton.bezelStyle = .rounded; banButton.keyEquivalent = "\r"
banButton.setAccessibilityLabel("Confirm ban")
let buttonRow = NSStackView(views: [NSView(), cancelButton, banButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
let grid = NSGridView(views: [
[reasonLabel, reasonField],
[durationLabel, durationPicker],
])
grid.rowSpacing = 8; grid.columnSpacing = 8
grid.column(at: 0).xPlacement = .trailing
let stack = NSStackView(views: [titleLabel, grid, buttonRow])
stack.orientation = .vertical; stack.spacing = 12
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
@objc private func banClicked() {
let reason = reasonField.stringValue.trimmingCharacters(in: .whitespaces)
let expiresUnixMs = expiryFromSelection()
dismiss(nil)
onComplete?(reason.isEmpty ? nil : reason, expiresUnixMs)
}
@objc private func cancelClicked() {
dismiss(nil)
}
private func expiryFromSelection() -> UInt64 {
let nowMs = UInt64(Date().timeIntervalSince1970 * 1000)
switch durationPicker.selectedSegment {
case 0: return nowMs + 3_600_000 // 1 hour
case 1: return nowMs + 86_400_000 // 24 hours
case 2: return nowMs + 604_800_000 // 7 days
default: return 0 // permanent (0 = no expiry)
}
}
}

View File

@@ -0,0 +1,202 @@
import AppKit
import VoiceCatCore
final class ChannelEditSheet: NSViewController {
var onComplete: ((ChannelEdit?) -> Void)?
private let channels: [Channel]
private var editing: ChannelEdit?
private let nameField = NSTextField()
private let topicField = NSTextField()
private let parentPicker = NSPopUpButton()
private let pwCheckbox = NSButton(checkboxWithTitle: "Password protected", target: nil, action: nil)
private let pwField = NSSecureTextField()
private let maxUsersField: NSTextField = {
let f = NSTextField(); f.stringValue = "0"; return f
}()
private let sortOrderField: NSTextField = {
let f = NSTextField(); f.stringValue = "0"; return f
}()
private let stereoCheckbox = NSButton(checkboxWithTitle: "Stereo", target: nil, action: nil)
private let bitrateField: NSTextField = {
let f = NSTextField(); f.stringValue = "64000"; return f
}()
private let fecCheckbox = NSButton(checkboxWithTitle: "FEC", target: nil, action: nil)
private let dtxCheckbox = NSButton(checkboxWithTitle: "DTX", target: nil, action: nil)
private let frameMsPicker = NSPopUpButton()
init(channels: [Channel], editing: ChannelEdit?) {
self.channels = channels
self.editing = editing
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 440, height: 360))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
populateIfEditing()
}
private func buildUI() {
let titleText = editing == nil ? "Create Channel" : "Edit Channel"
let titleLabel = NSTextField(labelWithString: titleText)
titleLabel.font = .boldSystemFont(ofSize: 13)
nameField.placeholderString = "Channel name"
nameField.setAccessibilityLabel("Channel name")
topicField.placeholderString = "Topic (optional)"
topicField.setAccessibilityLabel("Channel topic")
parentPicker.addItem(withTitle: "(root)")
parentPicker.menu?.items.last?.representedObject = nil as UInt32?
for ch in channels.sorted(by: { $0.name < $1.name }) {
let item = NSMenuItem(title: ch.name, action: nil, keyEquivalent: "")
item.representedObject = ch.id
parentPicker.menu?.addItem(item)
}
parentPicker.setAccessibilityLabel("Parent channel")
pwCheckbox.target = self; pwCheckbox.action = #selector(pwToggled)
pwField.placeholderString = "password (leave blank to keep existing)"
pwField.setAccessibilityLabel("Channel password")
pwField.isEnabled = false
maxUsersField.setAccessibilityLabel("Max users (0 = unlimited)")
sortOrderField.setAccessibilityLabel("Sort order")
for ms in ["20", "40", "60"] { frameMsPicker.addItem(withTitle: "\(ms) ms") }
frameMsPicker.setAccessibilityLabel("Opus frame duration")
fecCheckbox.state = .on
stereoCheckbox.setAccessibilityLabel("Stereo audio")
bitrateField.setAccessibilityLabel("Bitrate in bits per second")
fecCheckbox.setAccessibilityLabel("Forward error correction")
dtxCheckbox.setAccessibilityLabel("Discontinuous transmission")
let generalGrid = NSGridView(views: [
[NSTextField(labelWithString: "Name:"), nameField],
[NSTextField(labelWithString: "Topic:"), topicField],
[NSTextField(labelWithString: "Parent:"), parentPicker],
[pwCheckbox, pwField],
[NSTextField(labelWithString: "Max users:"), maxUsersField],
[NSTextField(labelWithString: "Sort order:"), sortOrderField],
])
generalGrid.rowSpacing = 8; generalGrid.columnSpacing = 8
generalGrid.column(at: 0).xPlacement = .trailing
let audioGrid = NSGridView(views: [
[NSTextField(labelWithString: "Bitrate:"), bitrateField],
[NSTextField(labelWithString: "Frame:"), frameMsPicker],
[stereoCheckbox, fecCheckbox],
[dtxCheckbox, NSView()],
])
audioGrid.rowSpacing = 8; audioGrid.columnSpacing = 8
audioGrid.column(at: 0).xPlacement = .trailing
let tabs = NSTabView()
let generalTab = NSTabViewItem(identifier: "general")
generalTab.label = "General"
generalTab.view = generalGrid
let audioTab = NSTabViewItem(identifier: "audio")
audioTab.label = "Audio"
audioTab.view = audioGrid
tabs.addTabViewItem(generalTab)
tabs.addTabViewItem(audioTab)
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
let saveButton = NSButton(title: editing == nil ? "Create" : "Save",
target: self, action: #selector(saveClicked))
saveButton.bezelStyle = .rounded; saveButton.keyEquivalent = "\r"
let buttonRow = NSStackView(views: [NSView(), cancelButton, saveButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
let stack = NSStackView(views: [titleLabel, tabs, buttonRow])
stack.orientation = .vertical
stack.spacing = 12
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
private func populateIfEditing() {
guard let e = editing else { return }
nameField.stringValue = e.name
topicField.stringValue = e.topic
if e.parentId != 0 {
for item in parentPicker.itemArray where (item.representedObject as? UInt32) == e.parentId {
parentPicker.select(item); break
}
}
pwCheckbox.state = e.passwordProtected ? .on : .off
pwField.isEnabled = e.passwordProtected
maxUsersField.stringValue = "\(e.maxUsers)"
sortOrderField.stringValue = "\(e.sortOrder)"
stereoCheckbox.state = e.audio.stereo ? .on : .off
bitrateField.stringValue = "\(e.audio.bitrateBps)"
fecCheckbox.state = e.audio.fec ? .on : .off
dtxCheckbox.state = e.audio.dtx ? .on : .off
let frameStr = "\(e.audio.frameMs) ms"
if let item = frameMsPicker.item(withTitle: frameStr) { frameMsPicker.select(item) }
}
@objc private func pwToggled() {
pwField.isEnabled = pwCheckbox.state == .on
}
@objc private func saveClicked() {
let name = nameField.stringValue.trimmingCharacters(in: .whitespaces)
guard !name.isEmpty else { nameField.becomeFirstResponder(); return }
let parentId = parentPicker.selectedItem?.representedObject as? UInt32 ?? 0
let maxUsers = UInt32(maxUsersField.stringValue) ?? 0
let sortOrder = UInt32(sortOrderField.stringValue) ?? 0
let bitrate = UInt32(bitrateField.stringValue) ?? 64000
let frameMsStr = frameMsPicker.titleOfSelectedItem?.replacingOccurrences(of: " ms", with: "") ?? "20"
let frameMs = UInt32(frameMsStr) ?? 20
let audio = AudioConfig(
stereo: stereoCheckbox.state == .on,
bitrateBps: bitrate,
frameMs: frameMs,
fec: fecCheckbox.state == .on,
dtx: dtxCheckbox.state == .on
)
let pwProtected = pwCheckbox.state == .on
let pw: String? = pwProtected ? (pwField.stringValue.isEmpty ? nil : pwField.stringValue) : nil
let result = ChannelEdit(
id: editing?.id ?? 0,
parentId: parentId,
name: name,
topic: topicField.stringValue,
passwordProtected: pwProtected,
password: pw,
maxUsers: maxUsers,
sortOrder: sortOrder,
audio: audio
)
dismiss(nil)
onComplete?(result)
}
@objc private func cancelClicked() {
dismiss(nil)
onComplete?(nil)
}
}

View File

@@ -0,0 +1,79 @@
import AppKit
final class InputSheet: NSViewController {
var onComplete: ((String?) -> Void)?
private let sheetTitle: String
private let prompt: String
private let defaultValue: String
private let inputField = NSTextField()
init(title: String, prompt: String, defaultValue: String = "") {
self.sheetTitle = title
self.prompt = prompt
self.defaultValue = defaultValue
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 320, height: 120))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
}
private func buildUI() {
let titleLabel = NSTextField(labelWithString: sheetTitle)
titleLabel.font = .boldSystemFont(ofSize: 13)
let promptLabel = NSTextField(labelWithString: prompt)
promptLabel.setAccessibilityLabel(prompt)
inputField.stringValue = defaultValue
inputField.setAccessibilityLabel(prompt)
inputField.target = self; inputField.action = #selector(okClicked)
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
let okButton = NSButton(title: "OK", target: self, action: #selector(okClicked))
okButton.bezelStyle = .rounded; okButton.keyEquivalent = "\r"
let buttonRow = NSStackView(views: [NSView(), cancelButton, okButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
let stack = NSStackView(views: [titleLabel, promptLabel, inputField, buttonRow])
stack.orientation = .vertical; stack.spacing = 8
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
override func viewDidAppear() {
super.viewDidAppear()
inputField.becomeFirstResponder()
inputField.selectText(nil)
}
@objc private func okClicked() {
let value = inputField.stringValue
dismiss(nil)
onComplete?(value)
}
@objc private func cancelClicked() {
dismiss(nil)
onComplete?(nil)
}
}

View File

@@ -0,0 +1,73 @@
import AppKit
import VoiceCatCore
final class MoveUserSheet: NSViewController {
var onComplete: ((UInt32?) -> Void)?
private let channels: [Channel]
private let currentChannelId: UInt32
private let picker = NSPopUpButton()
init(channels: [Channel], currentChannelId: UInt32) {
self.channels = channels.sorted(by: { $0.name < $1.name })
self.currentChannelId = currentChannelId
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 300, height: 100))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
}
private func buildUI() {
let label = NSTextField(labelWithString: "Move user to channel:")
label.setAccessibilityLabel("Select destination channel")
for ch in channels where ch.id != currentChannelId {
let item = NSMenuItem(title: ch.name, action: nil, keyEquivalent: "")
item.representedObject = ch.id
picker.menu?.addItem(item)
}
picker.setAccessibilityLabel("Destination channel")
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
let moveButton = NSButton(title: "Move", target: self, action: #selector(moveClicked))
moveButton.bezelStyle = .rounded; moveButton.keyEquivalent = "\r"
moveButton.setAccessibilityLabel("Move user to selected channel")
let buttonRow = NSStackView(views: [NSView(), cancelButton, moveButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
let stack = NSStackView(views: [label, picker, buttonRow])
stack.orientation = .vertical; stack.spacing = 10
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
@objc private func moveClicked() {
let channelId = picker.selectedItem?.representedObject as? UInt32
dismiss(nil)
onComplete?(channelId)
}
@objc private func cancelClicked() {
dismiss(nil)
onComplete?(nil)
}
}

View File

@@ -0,0 +1,76 @@
import AppKit
final class PasswordPromptSheet: NSViewController {
var onComplete: ((String?) -> Void)?
private let prompt: String
private let passwordField = NSSecureTextField()
init(prompt: String) {
self.prompt = prompt
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 320, height: 110))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
}
private func buildUI() {
let promptLabel = NSTextField(labelWithString: prompt)
promptLabel.lineBreakMode = .byWordWrapping
promptLabel.setAccessibilityLabel(prompt)
passwordField.placeholderString = "password"
passwordField.setAccessibilityLabel("Password")
passwordField.target = self; passwordField.action = #selector(okClicked)
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
cancelButton.setAccessibilityLabel("Cancel")
let okButton = NSButton(title: "OK", target: self, action: #selector(okClicked))
okButton.bezelStyle = .rounded
okButton.keyEquivalent = "\r"
okButton.setAccessibilityLabel("Submit password")
let buttonRow = NSStackView(views: [NSView(), cancelButton, okButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
let stack = NSStackView(views: [promptLabel, passwordField, buttonRow])
stack.orientation = .vertical
stack.spacing = 10
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
override func viewDidAppear() {
super.viewDidAppear()
passwordField.becomeFirstResponder()
}
@objc private func okClicked() {
let pw = passwordField.stringValue
dismiss(nil)
onComplete?(pw)
}
@objc private func cancelClicked() {
dismiss(nil)
onComplete?(nil)
}
}

View File

@@ -0,0 +1,123 @@
import AppKit
import VoiceCatCore
final class PerUserTuningSheet: NSViewController {
private let client: VoiceCatClient
private let userId: UInt32
private let nickname: String
private var streams: [StreamSummary] = []
private var rows: [StreamRow] = []
private struct StreamRow {
let streamId: UInt32
let label: String
let gainSlider: NSSlider
let muteCheckbox: NSButton
let nrCheckbox: NSButton
}
init(client: VoiceCatClient, userId: UInt32, nickname: String) {
self.client = client
self.userId = userId
self.nickname = nickname
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 400, height: 200))
}
override func viewDidLoad() {
super.viewDidLoad()
streams = client.listUserStreams(userId)
buildUI()
}
private func buildUI() {
let titleLabel = NSTextField(labelWithString: "Volume & Noise Settings — \(nickname)")
titleLabel.font = .boldSystemFont(ofSize: 13)
var rowViews: [NSView] = [titleLabel]
for stream in streams {
let (_, state) = client.getRemoteStream(userId: userId, streamId: stream.id)
let gain = state?.gain ?? 1.0
let muted = state?.muted ?? false
let nr = state?.noiseReduction ?? false
let gainSlider = NSSlider(value: Double(gain * 100), minValue: 0, maxValue: 200, target: self, action: #selector(sliderChanged))
gainSlider.tag = Int(stream.id)
gainSlider.numberOfTickMarks = 0
gainSlider.setAccessibilityLabel("Volume for \(stream.label): \(Int(gain * 100)) percent")
let muteCheckbox = NSButton(checkboxWithTitle: "Mute", target: self, action: #selector(muteChanged))
muteCheckbox.state = muted ? .on : .off
muteCheckbox.tag = Int(stream.id)
muteCheckbox.setAccessibilityLabel("Mute \(stream.label)")
let nrCheckbox = NSButton(checkboxWithTitle: "Noise reduction", target: self, action: #selector(nrChanged))
nrCheckbox.state = nr ? .on : .off
nrCheckbox.tag = Int(stream.id)
nrCheckbox.setAccessibilityLabel("Noise reduction for \(stream.label)")
let streamLabel = NSTextField(labelWithString: "\(stream.label):")
let gainLabel = NSTextField(labelWithString: "Volume:")
let row = NSStackView(views: [streamLabel, gainLabel, gainSlider, muteCheckbox, nrCheckbox])
row.orientation = .horizontal; row.spacing = 8
rowViews.append(row)
rows.append(StreamRow(streamId: stream.id, label: stream.label,
gainSlider: gainSlider, muteCheckbox: muteCheckbox,
nrCheckbox: nrCheckbox))
}
if streams.isEmpty {
rowViews.append(NSTextField(labelWithString: "This user has no active streams."))
}
let doneButton = NSButton(title: "Done", target: self, action: #selector(doneClicked))
doneButton.bezelStyle = .rounded; doneButton.keyEquivalent = "\r"
doneButton.setAccessibilityLabel("Close settings")
rowViews.append(NSStackView(views: [NSView(), doneButton]))
let stack = NSStackView(views: rowViews)
stack.orientation = .vertical
stack.spacing = 10
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
])
}
@objc private func sliderChanged(_ sender: NSSlider) {
apply(streamId: UInt32(sender.tag))
}
@objc private func muteChanged(_ sender: NSButton) {
apply(streamId: UInt32(sender.tag))
}
@objc private func nrChanged(_ sender: NSButton) {
apply(streamId: UInt32(sender.tag))
}
private func apply(streamId: UInt32) {
guard let row = rows.first(where: { $0.streamId == streamId }) else { return }
let gain = Float(row.gainSlider.doubleValue) / 100.0
let muted = row.muteCheckbox.state == .on
let nr = row.nrCheckbox.state == .on
client.setRemoteStream(userId: userId, streamId: streamId,
gain: gain, muted: muted, noiseReduction: nr)
row.gainSlider.setAccessibilityLabel("Volume for \(row.label): \(Int(row.gainSlider.doubleValue)) percent")
}
@objc private func doneClicked() { dismiss(nil) }
}

View File

@@ -0,0 +1,100 @@
import AppKit
import VoiceCatCore
final class PermissionsSheet: NSViewController {
var onComplete: ((Permissions?) -> Void)?
private let targetNickname: String
private let initial: Permissions
private let canCreateTempChannelCB = NSButton(checkboxWithTitle: "Create temporary channels", target: nil, action: nil)
private let canKickCB = NSButton(checkboxWithTitle: "Kick users", target: nil, action: nil)
private let canBanCB = NSButton(checkboxWithTitle: "Ban users", target: nil, action: nil)
private let canMoveUsersCB = NSButton(checkboxWithTitle: "Move users between channels", target: nil, action: nil)
private let canAdminAccountsCB = NSButton(checkboxWithTitle: "Manage accounts", target: nil, action: nil)
private let isAdminCB = NSButton(checkboxWithTitle: "Full administrator", target: nil, action: nil)
init(nickname: String, current: Permissions) {
self.targetNickname = nickname
self.initial = current
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 340, height: 250))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
applyInitial()
}
private func buildUI() {
let titleLabel = NSTextField(labelWithString: "Permissions — \(targetNickname)")
titleLabel.font = .boldSystemFont(ofSize: 13)
let checkboxes = [canCreateTempChannelCB, canKickCB, canBanCB,
canMoveUsersCB, canAdminAccountsCB, isAdminCB]
for cb in checkboxes {
cb.setAccessibilityLabel(cb.title)
}
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
let saveButton = NSButton(title: "Save", target: self, action: #selector(saveClicked))
saveButton.bezelStyle = .rounded; saveButton.keyEquivalent = "\r"
saveButton.setAccessibilityLabel("Save permissions for \(targetNickname)")
let buttonRow = NSStackView(views: [NSView(), cancelButton, saveButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
var views: [NSView] = [titleLabel]
views.append(contentsOf: checkboxes)
views.append(buttonRow)
let stack = NSStackView(views: views)
stack.orientation = .vertical; stack.spacing = 8
stack.alignment = .leading
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
private func applyInitial() {
canCreateTempChannelCB.state = initial.canCreateTempChannel ? .on : .off
canKickCB.state = initial.canKick ? .on : .off
canBanCB.state = initial.canBan ? .on : .off
canMoveUsersCB.state = initial.canMoveUsers ? .on : .off
canAdminAccountsCB.state = initial.canAdminAccounts ? .on : .off
isAdminCB.state = initial.isAdmin ? .on : .off
}
@objc private func saveClicked() {
let perms = Permissions(
canCreateTempChannel: canCreateTempChannelCB.state == .on,
canKick: canKickCB.state == .on,
canBan: canBanCB.state == .on,
canMoveUsers: canMoveUsersCB.state == .on,
canAdminAccounts: canAdminAccountsCB.state == .on,
isAdmin: isAdminCB.state == .on
)
dismiss(nil)
onComplete?(perms)
}
@objc private func cancelClicked() {
dismiss(nil)
onComplete?(nil)
}
}

View File

@@ -0,0 +1,113 @@
import AppKit
final class PttKeyCaptureSheet: NSViewController {
var onComplete: ((UInt16?) -> Void)?
private let currentKeyCode: UInt16
private var capturedKeyCode: UInt16?
private let instructionLabel = NSTextField(labelWithString: "Press the key you want to use for push-to-talk…")
private let captureView = KeyCaptureView()
init(currentKeyCode: UInt16) {
self.currentKeyCode = currentKeyCode
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 320, height: 140))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
}
private func buildUI() {
let titleLabel = NSTextField(labelWithString: "Set Push-to-Talk Key")
titleLabel.font = .boldSystemFont(ofSize: 13)
instructionLabel.textColor = .secondaryLabelColor
instructionLabel.lineBreakMode = .byWordWrapping
instructionLabel.setAccessibilityLabel("Waiting for key press")
captureView.setAccessibilityLabel("Key capture area — press any key")
captureView.setAccessibilityRole(.textArea)
captureView.onKeyPressed = { [weak self] keyCode in
self?.capturedKeyCode = keyCode
self?.instructionLabel.stringValue = "Key captured: \(keyCodeName(keyCode)). Click Set to confirm."
}
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
let setButton = NSButton(title: "Set", target: self, action: #selector(setClicked))
setButton.bezelStyle = .rounded; setButton.keyEquivalent = "\r"
setButton.setAccessibilityLabel("Set captured key as PTT key")
let buttonRow = NSStackView(views: [NSView(), cancelButton, setButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
captureView.translatesAutoresizingMaskIntoConstraints = false
captureView.wantsLayer = true
captureView.layer?.backgroundColor = NSColor.controlBackgroundColor.cgColor
captureView.layer?.cornerRadius = 4
let stack = NSStackView(views: [titleLabel, instructionLabel, captureView, buttonRow])
stack.orientation = .vertical; stack.spacing = 10
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
captureView.heightAnchor.constraint(equalToConstant: 28),
])
}
override func viewDidAppear() {
super.viewDidAppear()
view.window?.makeFirstResponder(captureView)
}
@objc private func setClicked() {
let key = capturedKeyCode
dismiss(nil)
onComplete?(key)
}
@objc private func cancelClicked() {
dismiss(nil)
onComplete?(nil)
}
}
// MARK: - Key capture view
private final class KeyCaptureView: NSView {
var onKeyPressed: ((UInt16) -> Void)?
override var acceptsFirstResponder: Bool { true }
override func keyDown(with event: NSEvent) {
onKeyPressed?(event.keyCode)
}
override func drawFocusRingMask() {
NSBezierPath(roundedRect: bounds, xRadius: 4, yRadius: 4).fill()
}
override var focusRingMaskBounds: NSRect { bounds }
}
private func keyCodeName(_ keyCode: UInt16) -> String {
let map: [UInt16: String] = [
0x60: "F5", 0x61: "F6", 0x62: "F7", 0x63: "F3", 0x64: "F8", 0x65: "F9",
0x67: "F11", 0x69: "F13", 0x6A: "F16", 0x6B: "F14", 0x6D: "F10", 0x6F: "F12",
0x71: "F15", 0x72: "Help", 0x73: "Home", 0x74: "PgUp", 0x75: "Del",
0x76: "F4", 0x77: "End", 0x78: "F2", 0x79: "PgDn", 0x7A: "F1",
]
return map[keyCode] ?? "Key\(keyCode)"
}

View File

@@ -0,0 +1,90 @@
import AppKit
import VoiceCatCore
final class ServerIdentitySheet: NSViewController {
var onComplete: ((Bool) -> Void)?
private let tofuStatus: VoiceCatTofuStatus
private let displayFingerprint: String
init(tofuStatus: VoiceCatTofuStatus, displayFingerprint: String) {
self.tofuStatus = tofuStatus
self.displayFingerprint = displayFingerprint
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 440, height: 220))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
}
private func buildUI() {
let isMismatch = tofuStatus == .mismatch
let titleText = isMismatch ? "Server Identity Mismatch — Possible MITM!" : "New Server Identity"
let titleLabel = NSTextField(labelWithString: titleText)
titleLabel.font = .boldSystemFont(ofSize: 14)
if isMismatch { titleLabel.textColor = .systemRed }
titleLabel.setAccessibilityLabel(titleText)
let bodyText: String
if isMismatch {
bodyText = "The server's identity has changed since you last connected. This may indicate a man-in-the-middle attack or that the server was reinstalled. Do NOT accept unless you know why the identity changed."
} else {
bodyText = "This is the first time you are connecting to this server. Verify the fingerprint below with the server administrator before accepting."
}
let bodyLabel = NSTextField(wrappingLabelWithString: bodyText)
bodyLabel.textColor = .labelColor
let fpLabel = NSTextField(labelWithString: "Server fingerprint:")
let fpField = NSTextField(labelWithString: displayFingerprint.isEmpty ? "(not available)" : displayFingerprint)
fpField.font = NSFont.monospacedSystemFont(ofSize: 11, weight: .regular)
fpField.isSelectable = true
fpField.setAccessibilityLabel("Server identity fingerprint: \(displayFingerprint)")
let rejectButton = NSButton(title: "Reject (Disconnect)", target: self, action: #selector(rejectClicked))
rejectButton.bezelStyle = .rounded
rejectButton.setAccessibilityLabel("Reject server identity and disconnect")
if isMismatch { rejectButton.keyEquivalent = "\r" }
let acceptButton = NSButton(title: "Accept", target: self, action: #selector(acceptClicked))
acceptButton.bezelStyle = .rounded
if !isMismatch { acceptButton.keyEquivalent = "\r" }
acceptButton.setAccessibilityLabel("Accept server identity and continue connecting")
let buttonRow = NSStackView(views: [NSView(), rejectButton, acceptButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
let fpRow = NSStackView(views: [fpLabel, fpField])
fpRow.orientation = .horizontal; fpRow.spacing = 8
let stack = NSStackView(views: [titleLabel, bodyLabel, fpRow, buttonRow])
stack.orientation = .vertical
stack.spacing = 12
stack.edgeInsets = NSEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
@objc private func acceptClicked() {
dismiss(nil)
onComplete?(true)
}
@objc private func rejectClicked() {
dismiss(nil)
onComplete?(false)
}
}