mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-10-18 07:33:46 +00:00
feat: summarize mesh bridge status in settings
the bridge settings card only exposed a toggle and a no-cell caption, so the active rendezvous cell, how many people are reachable via the bridge, and whether composing stays nearby-only all had to be inferred from the header icons. add a BridgeStatusSummary formatter and render it as a one-line status under the toggle.
This commit is contained in:
parent
f0249d9cd7
commit
b60a9eb66e
63
bitchat/Services/Gateway/BridgeStatusSummary.swift
Normal file
63
bitchat/Services/Gateway/BridgeStatusSummary.swift
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// BridgeStatusSummary.swift
|
||||
// bitchat
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// For more information, see <https://unlicense.org>
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// One-line mesh bridge status for the settings pane.
|
||||
enum BridgeStatusSummary {
|
||||
static func formatted(
|
||||
enabled: Bool,
|
||||
cell: String?,
|
||||
bridgedCount: Int,
|
||||
nearbyOnly: Bool
|
||||
) -> String {
|
||||
if !enabled {
|
||||
return String(
|
||||
localized: "app_info.settings.bridge.status.off",
|
||||
defaultValue: "bridge off — only radio-range mesh traffic",
|
||||
comment: "Bridge status line when the mesh bridge toggle is off"
|
||||
)
|
||||
}
|
||||
let cellPart = cell.map {
|
||||
String(
|
||||
format: String(
|
||||
localized: "app_info.settings.bridge.status.cell",
|
||||
defaultValue: "rendezvous #%@",
|
||||
comment: "Bridge status fragment showing rendezvous cell; %@ is geohash"
|
||||
),
|
||||
locale: .current,
|
||||
$0
|
||||
)
|
||||
} ?? String(
|
||||
localized: "app_info.settings.bridge.status.no_cell",
|
||||
defaultValue: "no rendezvous cell",
|
||||
comment: "Bridge status fragment when no cell is active"
|
||||
)
|
||||
let peoplePart = String(
|
||||
format: String(
|
||||
localized: "app_info.settings.bridge.status.people",
|
||||
defaultValue: "%lld people via bridge",
|
||||
comment: "Bridge status fragment counting bridged participants; %lld is count"
|
||||
),
|
||||
locale: .current,
|
||||
bridgedCount
|
||||
)
|
||||
let composePart = nearbyOnly
|
||||
? String(
|
||||
localized: "app_info.settings.bridge.status.compose_nearby",
|
||||
defaultValue: "compose: nearby only",
|
||||
comment: "Bridge status fragment when outgoing mesh messages stay on radio"
|
||||
)
|
||||
: String(
|
||||
localized: "app_info.settings.bridge.status.compose_bridged",
|
||||
defaultValue: "compose: bridged",
|
||||
comment: "Bridge status fragment when outgoing mesh messages cross the bridge"
|
||||
)
|
||||
return [cellPart, peoplePart, composePart].joined(separator: " · ")
|
||||
}
|
||||
}
|
||||
@ -78,6 +78,14 @@ struct AppInfoView: View {
|
||||
)
|
||||
}
|
||||
static let bridgeNoCell = String(localized: "app_info.settings.bridge.no_cell", defaultValue: "no rendezvous cell yet — needs location access or a nearby bridge peer", comment: "Caption under the mesh bridge toggle when the bridge is on but has no geohash cell to meet on")
|
||||
static func bridgeStatusSummary(enabled: Bool, cell: String?, bridgedCount: Int, nearbyOnly: Bool) -> String {
|
||||
BridgeStatusSummary.formatted(
|
||||
enabled: enabled,
|
||||
cell: cell,
|
||||
bridgedCount: bridgedCount,
|
||||
nearbyOnly: nearbyOnly
|
||||
)
|
||||
}
|
||||
|
||||
// Moved from LocationChannelsSheet; keys unchanged. (The former
|
||||
// internet-gateway toggle is gone: the bridge switch drives all
|
||||
@ -440,6 +448,17 @@ struct AppInfoView: View {
|
||||
.bitchatFont(size: 11)
|
||||
.foregroundColor(secondaryTextColor)
|
||||
}
|
||||
Text(
|
||||
verbatim: Strings.Settings.bridgeStatusSummary(
|
||||
enabled: bridgeService.isEnabled,
|
||||
cell: bridgeService.activeCell,
|
||||
bridgedCount: bridgeService.bridgedPeerCount,
|
||||
nearbyOnly: bridgeService.nearbyOnly
|
||||
)
|
||||
)
|
||||
.bitchatFont(size: 11)
|
||||
.foregroundColor(secondaryTextColor)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
|
||||
settingsCard {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user