import SwiftUI /// Presentation only: reuse the current snapshot without additional sampling on hover. struct MemoryHeaderInfo { let memory: MemoryMetrics? let locale: Locale var bundle: Bundle = .main private var pressure: (key: String?, color: Color) { switch memory?.pressure { case 1: ("pressure.normal", Color("MetricCPU")) case 2: ("pressure.warning", .orange) case 4: ("pressure.critical", .red) default: (nil, .secondary) } } var title: String { pressure.key.map(localized) ?? "--" } var badgeTitle: String { pressure.key == nil ? "--" : localized("memory.pressurePrefix") + title } var color: Color { pressure.color } var help: String { "\(localized("memory.pressure")): \(title)\n" + "\(localized("memory.cached")): \(MetricFormat.memory(memory?.cached))\n" + "\(localized("memory.swap")): \(MetricFormat.memory(memory?.swapUsed))" } private func localized(_ key: String) -> String { AppLocalization.string(key, locale: locale, bundle: bundle) } }