Files
Kymo/kymo/Features/MenuBar/MemoryDetailsView.swift
T

23 lines
974 B
Swift

import SwiftUI
struct MemoryDetailsView: View {
let memory: MemoryMetrics
private var colors: [Color] { [Color("MemoryApplication"), Color("MemoryWired"), Color("MemoryCompressed"), Color("MemoryAvailable")] }
private var values: [UInt64] { [memory.app, memory.wired, memory.compressed, memory.available] }
private let labels: [LocalizedStringKey] = ["memory.app", "memory.wired", "memory.compressed", "memory.available"]
var body: some View {
VStack(alignment: .leading, spacing: 3) {
CapacityBar(values: values.map { Double($0) }, colors: colors, total: Double(memory.total))
HStack(spacing: 4) {
ForEach(0..<4) { index in
CapacityField(title: labels[index], value: MetricFormat.memory(values[index]), color: colors[index])
}
}
}
.accessibilityElement(children: .contain)
.accessibilityLabel(Text("memory.distribution"))
}
}