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) { ViewThatFits(in: .horizontal) { classification(0..<3, unit: true).fixedSize(horizontal: true, vertical: true) VStack(alignment: .leading, spacing: 4) { classification(0..<2, unit: false) classification(2..<3, unit: true) } } HStack(spacing: 4) { Text("memory.available").foregroundStyle(.secondary) MetricText(value: MetricFormat.memory(memory.available)).fontWeight(.medium) }.frame(height: 16) } .font(.system(size: 10)).lineLimit(1) .help(Text("memory.distributionHelp")) .accessibilityElement(children: .contain) .accessibilityLabel(Text("memory.distribution")) } private func classification(_ indices: Range, unit: Bool) -> some View { HStack(spacing: 4) { ForEach(Array(indices), id: \.self) { index in if index > indices.lowerBound { Text("ยท").foregroundStyle(.secondary) } HStack(spacing: 3) { Text(labels[index]).foregroundStyle(.secondary) MetricText(value: String(format: "%.1f", Double(values[index]) / 1_073_741_824)) .fontWeight(.medium).foregroundStyle(.primary) } .help(Text(MetricFormat.memory(values[index]))) } if unit { Text(verbatim: "GiB").foregroundStyle(.secondary) } }.frame(height: 16) } }