43 lines
1.9 KiB
Swift
43 lines
1.9 KiB
Swift
import SwiftUI
|
|
|
|
struct StorageDetailsView: View {
|
|
let disk: DiskMetrics?
|
|
let health: DiskHealthMetrics?
|
|
let showVolumes: () -> Void
|
|
private let color = Color("MetricDisk")
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
CardSeparator()
|
|
CardSectionHeader(title: "disk.distribution", valueLabel: "disk.utilization",
|
|
value: MetricFormat.percent(disk?.usage), color: color)
|
|
CapacityBar(values: [Double(disk.map { $0.total - min($0.total, $0.available) } ?? 0), Double(disk?.available ?? 0)],
|
|
colors: [color, Color("MemoryAvailable")], total: Double(disk?.total ?? 1))
|
|
HStack(spacing: 4) {
|
|
CapacityField(title: "disk.used", value: MetricFormat.bytes(disk.map { $0.total - min($0.total, $0.available) }), color: color)
|
|
CapacityField(title: "memory.available", value: MetricFormat.bytes(disk?.available), color: Color("MemoryAvailable"))
|
|
}
|
|
CardSeparator()
|
|
HStack(alignment: .top, spacing: 8) {
|
|
CardField(title: "disk.remainingLife") {
|
|
MetricText(value: MetricFormat.percent(health?.remainingLife))
|
|
}
|
|
Divider().frame(height: 32)
|
|
CardField(title: "disk.powerOnHours") {
|
|
MetricText(value: health?.powerOnHours.map { "\($0) h" } ?? "--")
|
|
}
|
|
Divider().frame(height: 32)
|
|
CardField(title: "disk.localVolumes") {
|
|
Button(action: showVolumes) {
|
|
HStack(spacing: 2) {
|
|
Text("disk.viewDetails")
|
|
Image(systemName: "chevron.right").font(.system(size: 8))
|
|
}
|
|
}.buttonStyle(.plain)
|
|
}
|
|
}.font(PanelStyle.label).lineLimit(1)
|
|
}
|
|
}
|
|
|
|
}
|