42 lines
1.5 KiB
Swift
42 lines
1.5 KiB
Swift
import SwiftUI
|
|
|
|
struct StorageDetailsView: View {
|
|
let disk: DiskMetrics?
|
|
let health: DiskHealthMetrics?
|
|
let showVolumes: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
HStack(spacing: 8) {
|
|
VStack(spacing: 4) {
|
|
field("memory.available", value: MetricFormat.bytes(disk?.available))
|
|
field("disk.powerOnHours", value: health?.powerOnHours.map { "\($0) h" } ?? "--")
|
|
}
|
|
Divider().frame(height: 32)
|
|
VStack(spacing: 4) {
|
|
field("disk.remainingLife", value: MetricFormat.percent(health?.remainingLife))
|
|
Button(action: showVolumes) {
|
|
HStack(spacing: 3) {
|
|
Text("disk.localVolumes")
|
|
Spacer(minLength: 3)
|
|
Image(systemName: "chevron.right").font(.system(size: 8))
|
|
}.contentShape(.rect)
|
|
}
|
|
.buttonStyle(.plain).help(Text("disk.viewDetails"))
|
|
.frame(height: 14)
|
|
}
|
|
}.font(PanelStyle.label).lineLimit(1)
|
|
}
|
|
}
|
|
|
|
private func field(_ title: LocalizedStringKey, value: String) -> some View {
|
|
HStack(spacing: 3) {
|
|
Text(title).foregroundStyle(.secondary).help(Text(title))
|
|
Spacer(minLength: 3)
|
|
MetricText(value: value).font(PanelStyle.value)
|
|
}
|
|
.frame(height: 14)
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
}
|