mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 17:45:19 +00:00
Fix header string interpolation: simplify accessibilityLabel to avoid unterminated string; use '\(headerOtherPeersCount) people'
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user