refactor(menubar): 精简内存卡片并对齐双列底部

This commit is contained in:
2026-11-09 00:05:25 +08:00
parent 28112bcf2e
commit 1afe82b233
15 changed files with 119 additions and 40 deletions
+1 -21
View File
@@ -7,7 +7,7 @@ struct MemoryDetailsView: View {
private let labels: [LocalizedStringKey] = ["memory.app", "memory.wired", "memory.compressed", "memory.available"]
var body: some View {
VStack(alignment: .leading, spacing: 4) {
VStack(alignment: .leading, spacing: 3) {
CardSeparator()
CapacityBar(values: values.map { Double($0) }, colors: colors, total: Double(memory.total))
HStack(spacing: 4) {
@@ -15,29 +15,9 @@ struct MemoryDetailsView: View {
CapacityField(title: labels[index], value: MetricFormat.memory(values[index]), color: colors[index])
}
}
CardSeparator()
HStack(alignment: .top, spacing: 8) {
CardField(title: "memory.pressure") { pressure }
Divider().frame(height: 32)
CardField(title: "memory.cached") {
MetricText(value: MetricFormat.memory(memory.cached))
}
Divider().frame(height: 32)
CardField(title: "memory.swap") {
MetricText(value: MetricFormat.memory(memory.swapUsed))
}
}.font(PanelStyle.label).lineLimit(1)
}
.accessibilityElement(children: .contain)
.accessibilityLabel(Text("memory.distribution"))
}
@ViewBuilder private var pressure: some View {
switch memory.pressure {
case 1: Text("pressure.normal").foregroundStyle(Color("MetricCPU"))
case 2: Text("pressure.warning").foregroundStyle(.orange)
case 4: Text("pressure.critical").foregroundStyle(.red)
default: Text(verbatim: "--").foregroundStyle(.secondary)
}
}
}