IceCubes/IceCubesApp/App/Tabs/Settings/InstanceInfoView.swift

48 lines
1.3 KiB
Swift
Raw Normal View History

2022-12-29 14:07:58 +01:00
import DesignSystem
2023-01-17 11:36:01 +01:00
import Models
2022-12-29 14:07:58 +01:00
import NukeUI
2023-01-17 11:36:01 +01:00
import SwiftUI
2022-12-29 14:07:58 +01:00
struct InstanceInfoView: View {
@EnvironmentObject private var theme: Theme
2023-01-17 11:36:01 +01:00
2022-12-29 14:07:58 +01:00
let instance: Instance
2023-01-17 11:36:01 +01:00
2022-12-29 14:07:58 +01:00
var body: some View {
2023-01-06 17:14:34 +01:00
Form {
2023-01-07 18:12:56 +01:00
InstanceInfoSection(instance: instance)
2022-12-29 14:07:58 +01:00
}
.navigationTitle("instance.info.navigation-title")
2023-01-06 17:14:34 +01:00
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
2022-12-29 14:07:58 +01:00
}
}
2023-01-07 18:12:56 +01:00
public struct InstanceInfoSection: View {
@EnvironmentObject private var theme: Theme
2023-01-17 11:36:01 +01:00
2023-01-07 18:12:56 +01:00
let instance: Instance
2023-01-17 11:36:01 +01:00
2023-01-07 18:12:56 +01:00
public var body: some View {
Section("instance.info.section.info") {
LabeledContent("instance.info.name", value: instance.title)
2023-01-07 18:12:56 +01:00
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)")
2023-01-07 18:12:56 +01:00
}
.listRowBackground(theme.primaryBackgroundColor)
2023-01-17 11:36:01 +01:00
2023-01-18 19:10:45 +01:00
if let rules = instance.rules {
Section("instance.info.section.rules") {
2023-01-18 19:10:45 +01:00
ForEach(rules) { rule in
Text(rule.text)
}
2023-01-07 18:12:56 +01:00
}
2023-01-18 19:10:45 +01:00
.listRowBackground(theme.primaryBackgroundColor)
2023-01-07 18:12:56 +01:00
}
}
}