refactor(menubar): 精简内存卡片并对齐双列底部
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user