33 lines
1.3 KiB
Swift
33 lines
1.3 KiB
Swift
import SwiftUI
|
|
|
|
struct MemoryDetailsView: View {
|
|
let memory: MemoryMetrics
|
|
private var values: [UInt64] { [memory.app, memory.wired, memory.compressed] }
|
|
private let labels: [LocalizedStringKey] = ["memory.appShort", "memory.wiredShort", "memory.compressedShort"]
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
HStack(spacing: 3) {
|
|
ForEach(0..<3) { index in
|
|
if index > 0 { Text("·").foregroundStyle(.secondary) }
|
|
HStack(spacing: 2) {
|
|
Text(labels[index])
|
|
MetricText(value: String(format: "%.1f", Double(values[index]) / 1_073_741_824))
|
|
}
|
|
.help(Text(MetricFormat.memory(values[index])))
|
|
}
|
|
Text(verbatim: "GiB")
|
|
}
|
|
.font(.system(size: 8)).foregroundStyle(.secondary)
|
|
.lineLimit(1).minimumScaleFactor(0.75)
|
|
HStack(spacing: 4) {
|
|
Text("memory.available").foregroundStyle(.secondary)
|
|
MetricText(value: MetricFormat.memory(memory.available))
|
|
}.font(.system(size: 9)).lineLimit(1)
|
|
}
|
|
.help(Text("memory.distributionHelp"))
|
|
.accessibilityElement(children: .contain)
|
|
.accessibilityLabel(Text("memory.distribution"))
|
|
}
|
|
}
|