mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 18:25: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()
|
Spacer()
|
||||||
|
|
||||||
// Channel badge + dynamic spacing + people counter
|
// 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) {
|
HStack(spacing: 10) {
|
||||||
// Unread icon immediately to the left of the channel badge (independent from channel button)
|
// 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
|
// Unread indicator
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@@ -932,12 +935,12 @@ struct ContentView: View {
|
|||||||
// People icon with count
|
// People icon with count
|
||||||
Image(systemName: "person.2.fill")
|
Image(systemName: "person.2.fill")
|
||||||
.font(.system(size: 11))
|
.font(.system(size: 11))
|
||||||
.accessibilityLabel("\(otherPeersCount) \(otherPeersCount == 1 ? "person" : "people")")
|
.accessibilityLabel("\(headerOtherPeersCount) people")
|
||||||
Text("\(otherPeersCount)")
|
Text("\(headerOtherPeersCount)")
|
||||||
.font(.system(size: 12, design: .monospaced))
|
.font(.system(size: 12, design: .monospaced))
|
||||||
.accessibilityHidden(true)
|
.accessibilityHidden(true)
|
||||||
}
|
}
|
||||||
.foregroundColor(countColor)
|
.foregroundColor(headerCountColor)
|
||||||
}
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
withAnimation(.easeInOut(duration: 0.2)) {
|
withAnimation(.easeInOut(duration: 0.2)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user