Instance Info refinements: (#1012)

- Format stats with thousandseparators
- Format instance version in monospace
This commit is contained in:
Ico Davids 2023-02-22 19:16:08 +01:00 committed by GitHub
parent a4910037b8
commit 4bad875835
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,10 +28,12 @@ public struct InstanceInfoSection: View {
LabeledContent("instance.info.name", value: instance.title)
Text(instance.shortDescription)
LabeledContent("instance.info.email", value: instance.email)
LabeledContent("instance.info.version", value: instance.version)
LabeledContent("instance.info.users", value: "\(instance.stats.userCount)")
LabeledContent("instance.info.posts", value: "\(instance.stats.statusCount)")
LabeledContent("instance.info.domains", value: "\(instance.stats.domainCount)")
LabeledContent("instance.info.version") {
Text(instance.version).monospaced()
}
LabeledContent("instance.info.users", value: format(instance.stats.userCount))
LabeledContent("instance.info.posts", value: format(instance.stats.statusCount))
LabeledContent("instance.info.domains", value: format(instance.stats.domainCount))
}
.listRowBackground(theme.primaryBackgroundColor)
@ -44,4 +46,10 @@ public struct InstanceInfoSection: View {
.listRowBackground(theme.primaryBackgroundColor)
}
}
private func format(_ int: Int) -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
return formatter.string(from: NSNumber(value: int))!
}
}