Files
voice-cat/clients/apple/macOS/VoiceCatMac/Sheets/InputSheet.swift
Talon 33169b01fa 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.
2026-06-18 15:26:47 +02:00

80 lines
2.6 KiB
Swift

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)
}
}