feat(ios): iPhone channel drill-down, fix chat compose box, unify chat+activity

- Channels tab is now a drill-down on iPhone: ChannelBrowserView lists top-level
  channels; ChannelDetailView shows the people in a channel, its sub-channels, and
  an explicit Join button (with password prompt). iPad split view unchanged.
- Extract self-contained UserRow (context menu + sheets) from UserListView so admin
  actions are reused in the drill-down.
- Fix off-screen chat compose box: pin VoiceControlsView via per-tab
  .safeAreaInset(edge: .bottom) instead of a floating overlay, so it reserves layout
  space above the tab bar (keeping the compose box visible, cooperating with keyboard
  avoidance) without covering the tab bar buttons.
- Collapse Activity into Chat like macOS/Windows: ChatView renders a merged,
  time-sorted timeline of messages + activity (activity rows in gray); remove the
  Activity tab and ActivityLogView.
- Label the RPSystemBroadcastPickerView inner UIButton for VoiceOver
  ("Share/Stop sharing screen audio") instead of relying on an outer SwiftUI label.
This commit is contained in:
2026-06-21 03:02:58 +02:00
parent c5ad080692
commit b07362e525
10 changed files with 419 additions and 187 deletions

View File

@@ -1,27 +1,61 @@
import SwiftUI
import VoiceCatCore
/// One row of the combined chat/activity timeline. Mirrors the macOS/Windows clients, which
/// collapse chat messages and activity events into a single scrolling log (chat in normal
/// text, activity events in gray).
private enum TimelineItem: Identifiable {
case message(ChatMessage)
case activity(ActivityEntry)
var id: UUID {
switch self {
case .message(let m): return m.id
case .activity(let a): return a.id
}
}
var timestamp: Date {
switch self {
case .message(let m): return m.timestamp
case .activity(let a): return a.timestamp
}
}
}
struct ChatView: View {
@Bindable var session: SessionState
@State private var composeText = ""
@State private var scope: VoiceCatTextScope = .channel
@State private var privateTargetId: UInt32 = 0
private var timeline: [TimelineItem] {
let merged = session.messages.map(TimelineItem.message)
+ session.activityLog.map(TimelineItem.activity)
return merged.sorted { $0.timestamp < $1.timestamp }
}
var body: some View {
VStack(spacing: 0) {
// Message list
// Combined chat + activity timeline
ScrollViewReader { proxy in
ScrollView {
LazyVStack(alignment: .leading, spacing: 8) {
ForEach(session.messages) { msg in
ChatBubble(message: msg)
.id(msg.id)
ForEach(timeline) { item in
switch item {
case .message(let msg):
ChatBubble(message: msg)
.id(item.id)
case .activity(let entry):
ActivityRow(entry: entry)
.id(item.id)
}
}
}
.padding()
}
.onChange(of: session.messages.count) { _, _ in
if let last = session.messages.last {
.onChange(of: session.messages.count + session.activityLog.count) { _, _ in
if let last = timeline.last {
proxy.scrollTo(last.id, anchor: .bottom)
}
}
@@ -92,3 +126,34 @@ private struct ChatBubble: View {
.accessibilityLabel("\(message.senderName) at \(timeString): \(message.text)")
}
}
/// A compact, gray activity row interleaved into the chat timeline (joins/leaves, talk state,
/// streams, server mute, etc.). Matches the "activity = gray" convention of the macOS/Windows
/// unified logs.
private struct ActivityRow: View {
let entry: ActivityEntry
private static let timeFormatter: DateFormatter = {
let fmt = DateFormatter()
fmt.dateStyle = .none
fmt.timeStyle = .short
return fmt
}()
private var timeString: String { Self.timeFormatter.string(from: entry.timestamp) }
var body: some View {
HStack(alignment: .top, spacing: 6) {
Text(timeString)
.font(.caption2)
.foregroundStyle(.tertiary)
.monospacedDigit()
Text(entry.text)
.font(.caption)
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, alignment: .leading)
.accessibilityElement(children: .combine)
.accessibilityLabel("\(timeString): \(entry.text)")
}
}