mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 03:25:19 +00:00
UI: grey #abcd suffix in geohash peer list; keep base name (and '(you)') styled normally
This commit is contained in:
@@ -38,10 +38,24 @@ struct GeohashPeopleList: View {
|
|||||||
} else {
|
} else {
|
||||||
Image(systemName: "person.fill").font(.system(size: 10)).foregroundColor(textColor)
|
Image(systemName: "person.fill").font(.system(size: 10)).foregroundColor(textColor)
|
||||||
}
|
}
|
||||||
Text(person.displayName + (person.id == myHex ? " (you)" : ""))
|
let (base, suffix) = splitSuffix(from: person.displayName)
|
||||||
.font(.system(size: 14, design: .monospaced))
|
let isMe = person.id == myHex
|
||||||
.fontWeight(person.id == myHex ? .bold : .regular)
|
HStack(spacing: 0) {
|
||||||
.foregroundColor(textColor)
|
Text(base)
|
||||||
|
.font(.system(size: 14, design: .monospaced))
|
||||||
|
.fontWeight(isMe ? .bold : .regular)
|
||||||
|
.foregroundColor(textColor)
|
||||||
|
if !suffix.isEmpty {
|
||||||
|
Text(suffix)
|
||||||
|
.font(.system(size: 14, design: .monospaced))
|
||||||
|
.foregroundColor(Color.secondary.opacity(0.6))
|
||||||
|
}
|
||||||
|
if isMe {
|
||||||
|
Text(" (you)")
|
||||||
|
.font(.system(size: 14, design: .monospaced))
|
||||||
|
.foregroundColor(textColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
@@ -60,3 +74,17 @@ struct GeohashPeopleList: View {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Helper to split a trailing #abcd suffix
|
||||||
|
#if os(iOS)
|
||||||
|
private func splitSuffix(from name: String) -> (String, String) {
|
||||||
|
guard name.count >= 5 else { return (name, "") }
|
||||||
|
let suffix = String(name.suffix(5))
|
||||||
|
if suffix.first == "#", suffix.dropFirst().allSatisfy({ c in
|
||||||
|
("0"..."9").contains(String(c)) || ("a"..."f").contains(String(c)) || ("A"..."F").contains(String(c))
|
||||||
|
}) {
|
||||||
|
let base = String(name.dropLast(5))
|
||||||
|
return (base, suffix)
|
||||||
|
}
|
||||||
|
return (name, "")
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user