mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-24 14:02:53 +01:00
5a2478c791
* Initial support * UI Adjustments * WIP icons * More UI
62 lines
1.7 KiB
Swift
62 lines
1.7 KiB
Swift
import DesignSystem
|
|
import Models
|
|
import NukeUI
|
|
import SwiftUI
|
|
|
|
struct InstanceInfoView: View {
|
|
@Environment(Theme.self) private var theme
|
|
|
|
let instance: Instance
|
|
|
|
var body: some View {
|
|
Form {
|
|
InstanceInfoSection(instance: instance)
|
|
}
|
|
.navigationTitle("instance.info.navigation-title")
|
|
#if !os(visionOS)
|
|
.scrollContentBackground(.hidden)
|
|
.background(theme.secondaryBackgroundColor)
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public struct InstanceInfoSection: View {
|
|
@Environment(Theme.self) private var theme
|
|
|
|
let instance: Instance
|
|
|
|
public var body: some View {
|
|
Section("instance.info.section.info") {
|
|
LabeledContent("instance.info.name", value: instance.title)
|
|
Text(instance.shortDescription)
|
|
LabeledContent("instance.info.email", value: instance.email)
|
|
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))
|
|
}
|
|
#if !os(visionOS)
|
|
.listRowBackground(theme.primaryBackgroundColor)
|
|
#endif
|
|
|
|
if let rules = instance.rules {
|
|
Section("instance.info.section.rules") {
|
|
ForEach(rules) { rule in
|
|
Text(rule.text.trimmingCharacters(in: .whitespacesAndNewlines))
|
|
}
|
|
}
|
|
#if !os(visionOS)
|
|
.listRowBackground(theme.primaryBackgroundColor)
|
|
#endif
|
|
}
|
|
}
|
|
|
|
private func format(_ int: Int) -> String {
|
|
let formatter = NumberFormatter()
|
|
formatter.numberStyle = .decimal
|
|
return formatter.string(from: NSNumber(value: int))!
|
|
}
|
|
}
|