From d4b779080a93f69e951593a68d5c0a32f8136ac3 Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 22 Aug 2025 12:58:08 +0200 Subject: [PATCH] Fix header string interpolation: simplify accessibilityLabel to avoid unterminated string; use '\(headerOtherPeersCount) people' --- bitchat/Views/ContentView.swift | 49 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index 8940663d..0487cd0a 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -867,28 +867,31 @@ struct ContentView: View { Spacer() // Channel badge + dynamic spacing + people counter + // Precompute header count and color outside the ViewBuilder expressions + #if os(iOS) + let cc = channelPeopleCountAndColor() + let headerCountColor: Color = cc.1 + let headerOtherPeersCount: Int = { + if case .location = locationManager.selectedChannel { + return viewModel.visibleGeohashPeople().count + } + return cc.0 + }() + #else + let peerCounts = viewModel.allPeers.reduce(into: (others: 0, mesh: 0)) { counts, peer in + guard peer.id != viewModel.meshService.myPeerID else { return } + let isMeshConnected = peer.isConnected + if isMeshConnected { counts.mesh += 1; counts.others += 1 } + else if peer.isMutualFavorite { counts.others += 1 } + } + let headerOtherPeersCount = peerCounts.others + // Darker, more neutral blue (less purple hue) + let meshBlue = Color(hue: 0.60, saturation: 0.85, brightness: 0.82) + let headerCountColor: Color = (peerCounts.mesh > 0) ? meshBlue : Color.secondary + #endif + HStack(spacing: 10) { // Unread icon immediately to the left of the channel badge (independent from channel button) - #if os(iOS) - let cc = channelPeopleCountAndColor() - var otherPeersCount = cc.0 - let countColor = cc.1 - // Ensure geohash count matches the actual pruned list used in the sidebar - if case .location = locationManager.selectedChannel { - otherPeersCount = viewModel.visibleGeohashPeople().count - } - #else - let peerCounts = viewModel.allPeers.reduce(into: (others: 0, mesh: 0)) { counts, peer in - guard peer.id != viewModel.meshService.myPeerID else { return } - let isMeshConnected = peer.isConnected - if isMeshConnected { counts.mesh += 1; counts.others += 1 } - else if peer.isMutualFavorite { counts.others += 1 } - } - let otherPeersCount = peerCounts.others - // Darker, more neutral blue (less purple hue) - let meshBlue = Color(hue: 0.60, saturation: 0.85, brightness: 0.82) - let countColor: Color = (peerCounts.mesh > 0) ? meshBlue : Color.secondary - #endif // Unread indicator #if os(iOS) @@ -932,12 +935,12 @@ struct ContentView: View { // People icon with count Image(systemName: "person.2.fill") .font(.system(size: 11)) - .accessibilityLabel("\(otherPeersCount) \(otherPeersCount == 1 ? "person" : "people")") - Text("\(otherPeersCount)") + .accessibilityLabel("\(headerOtherPeersCount) people") + Text("\(headerOtherPeersCount)") .font(.system(size: 12, design: .monospaced)) .accessibilityHidden(true) } - .foregroundColor(countColor) + .foregroundColor(headerCountColor) } .onTapGesture { withAnimation(.easeInOut(duration: 0.2)) {