fix(ui): 缩小卡片并还原设计稿紧凑排布
This commit is contained in:
@@ -2,21 +2,32 @@ 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"]
|
||||
private let labels: [LocalizedStringKey] = ["memory.appShort", "memory.wiredShort", "memory.compressedShort"]
|
||||
private var colors: [Color] { [Color("MemoryApplication"), Color("MemoryWired"), Color("MemoryCompressed"), Color("MemoryAvailable")] }
|
||||
|
||||
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])
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(spacing: 3) {
|
||||
ForEach(0..<3) { index in
|
||||
if index > 0 { Text("·").foregroundStyle(.secondary) }
|
||||
HStack(spacing: 2) {
|
||||
Text(labels[index])
|
||||
MetricText(value: String(format: "%.1f", Double(values[index]) / 1_073_741_824))
|
||||
}
|
||||
.help(Text(MetricFormat.memory(values[index])))
|
||||
}
|
||||
Text(verbatim: "GiB")
|
||||
}
|
||||
.font(.system(size: 8)).foregroundStyle(.secondary)
|
||||
.lineLimit(1).minimumScaleFactor(0.75)
|
||||
CapacityBar(values: values.map { Double($0) }, colors: colors, total: Double(memory.total), height: 4)
|
||||
HStack(spacing: 4) {
|
||||
Text("memory.available").foregroundStyle(.secondary)
|
||||
MetricText(value: MetricFormat.memory(memory.available))
|
||||
}.font(.system(size: 9)).lineLimit(1)
|
||||
}
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel(Text("memory.distribution"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user