feat(menubar): 实现紧凑独立双列与按内容定高
This commit is contained in:
@@ -8,29 +8,35 @@ struct StorageDetailsView: View {
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
CardSeparator()
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
CardField(title: "memory.available") {
|
||||
MetricText(value: MetricFormat.bytes(disk?.available))
|
||||
HStack(spacing: 8) {
|
||||
VStack(spacing: 4) {
|
||||
field("memory.available", value: MetricFormat.bytes(disk?.available))
|
||||
field("disk.powerOnHours", value: health?.powerOnHours.map { "\($0) h" } ?? "--")
|
||||
}
|
||||
Divider().frame(height: 32)
|
||||
CardField(title: "disk.remainingLife") {
|
||||
MetricText(value: MetricFormat.percent(health?.remainingLife))
|
||||
}
|
||||
Divider().frame(height: 32)
|
||||
CardField(title: "disk.powerOnHours") {
|
||||
MetricText(value: health?.powerOnHours.map { "\($0) h" } ?? "--")
|
||||
}
|
||||
Divider().frame(height: 32)
|
||||
CardField(title: "disk.localVolumes") {
|
||||
VStack(spacing: 4) {
|
||||
field("disk.remainingLife", value: MetricFormat.percent(health?.remainingLife))
|
||||
Button(action: showVolumes) {
|
||||
HStack(spacing: 2) {
|
||||
Text("disk.viewDetails")
|
||||
HStack(spacing: 3) {
|
||||
Text("disk.localVolumes")
|
||||
Spacer(minLength: 3)
|
||||
Image(systemName: "chevron.right").font(.system(size: 8))
|
||||
}
|
||||
}.buttonStyle(.plain)
|
||||
}.contentShape(.rect)
|
||||
}
|
||||
.buttonStyle(.plain).help(Text("disk.viewDetails"))
|
||||
.frame(height: 14)
|
||||
}
|
||||
}.font(PanelStyle.label).lineLimit(1)
|
||||
}
|
||||
}
|
||||
|
||||
private func field(_ title: LocalizedStringKey, value: String) -> some View {
|
||||
HStack(spacing: 3) {
|
||||
Text(title).foregroundStyle(.secondary).help(Text(title))
|
||||
Spacer(minLength: 3)
|
||||
MetricText(value: value).font(PanelStyle.value)
|
||||
}
|
||||
.frame(height: 14)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user