Full SwiftUI app at clients/apple/iOS/VoiceCatiOS.xcodeproj:
- 24 Swift source files: AppState + SessionState (@Observable @MainActor),
AudioSessionManager (AVAudioSession owner + interruption/route handling),
ServerListStore/SavedServer (App Group container + Keychain sharing),
and 14 SwiftUI views covering the full feature set
- NavigationSplitView on iPad, TabView on iPhone (horizontalSizeClass)
- Channel tree via OutlineGroup, user list with context menu admin actions
- PTT via DragGesture(minimumDistance: 0) + @GestureState
- onEvent closures hop to MainActor via Task { @MainActor in ... }
- App Group: group.cat.voice.VoiceCat (shared with future ReplayKit extension)
C ABI: add vc_audio_suspend / vc_audio_resume (AudioEngine::suspend/resume)
called by AudioSessionManager on AVAudioSession interruption events.
XCFramework: add ios-arm64 and ios-arm64-simulator slices to build-xcframework.sh;
Package.swift gains .iOS(.v17) platform; CMakePresets.json adds apple-ios /
apple-ios-sim presets with arm64-ios / arm64-ios-simulator vcpkg triplets.
Verified: xcodebuild -target VoiceCatiOS -sdk iphonesimulator26.5 BUILD SUCCEEDED.
59 lines
2.1 KiB
Swift
59 lines
2.1 KiB
Swift
import SwiftUI
|
|
import VoiceCatCore
|
|
|
|
struct BanUserView: View {
|
|
let user: User
|
|
@Bindable var session: SessionState
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
@State private var reason = ""
|
|
@State private var permanent = true
|
|
@State private var duration: Double = 60 // minutes
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
Form {
|
|
Section("Ban \(user.nickname)") {
|
|
TextField("Reason (optional)", text: $reason)
|
|
.accessibilityLabel("Ban reason, optional")
|
|
Toggle("Permanent", isOn: $permanent)
|
|
.accessibilityLabel("Permanent ban")
|
|
if !permanent {
|
|
HStack {
|
|
Text("Duration")
|
|
Slider(value: $duration, in: 1...10080, step: 1)
|
|
.accessibilityLabel("Ban duration in minutes")
|
|
Text(formattedDuration)
|
|
.monospacedDigit()
|
|
.frame(width: 60, alignment: .trailing)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("Ban User")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button("Cancel") { dismiss() }
|
|
}
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
Button("Ban", role: .destructive) {
|
|
let expiresMs: UInt64 = permanent ? 0
|
|
: UInt64(Date().timeIntervalSince1970 * 1000) + UInt64(duration * 60 * 1000)
|
|
session.banUser(user.id, reason: reason, expiresUnixMs: expiresMs)
|
|
dismiss()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private var formattedDuration: String {
|
|
let mins = Int(duration)
|
|
if mins < 60 { return "\(mins)m" }
|
|
let hours = mins / 60
|
|
if hours < 24 { return "\(hours)h" }
|
|
return "\(hours / 24)d"
|
|
}
|
|
}
|