fix(ui): 提升卡片文字对比度与辅助信息可读性
This commit is contained in:
@@ -60,10 +60,10 @@ struct CPUCoreGrid: View {
|
||||
Circle().fill(color(kinds[groups[group][0]])).frame(width: 3, height: 3)
|
||||
if let kind = kinds[groups[group][0]] { label(kind, compact: true) }
|
||||
else { Text("cpu.core") }
|
||||
Text(verbatim: "\(groups[group].count)").foregroundStyle(.secondary)
|
||||
Text(verbatim: "\(groups[group].count)").foregroundStyle(.primary)
|
||||
}
|
||||
.font(.system(size: 8, weight: .medium)).lineLimit(1).minimumScaleFactor(0.65)
|
||||
.frame(height: 10)
|
||||
.font(.system(size: 9, weight: .medium)).lineLimit(1).minimumScaleFactor(0.65)
|
||||
.frame(height: 12)
|
||||
CPUCoreGridLayout {
|
||||
ForEach(groups[group], id: \.self) { index in core(index: index) }
|
||||
}
|
||||
@@ -79,7 +79,7 @@ struct CPUCoreGrid: View {
|
||||
private func gridHeight(groups: [[Int]]) -> CGFloat {
|
||||
let widths = Self.groupWidths(groups: groups, width: availableWidth)
|
||||
let rows = zip(groups, widths).map { CPUCoreGridLayout.rowCounts(count: $0.0.count, width: $0.1).count }.max() ?? 0
|
||||
return 14 + CGFloat(rows) * CPUCoreGridLayout.rowHeight + CGFloat(max(0, rows - 1)) * CPUCoreGridLayout.rowSpacing
|
||||
return 16 + CGFloat(rows) * CPUCoreGridLayout.rowHeight + CGFloat(max(0, rows - 1)) * CPUCoreGridLayout.rowSpacing
|
||||
}
|
||||
|
||||
private func core(index: Int) -> some View {
|
||||
|
||||
@@ -7,26 +7,36 @@ struct MemoryDetailsView: View {
|
||||
|
||||
var body: some View {
|
||||
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])))
|
||||
ViewThatFits(in: .horizontal) {
|
||||
classification(0..<3, unit: true).fixedSize(horizontal: true, vertical: true)
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
classification(0..<2, unit: false)
|
||||
classification(2..<3, unit: true)
|
||||
}
|
||||
Text(verbatim: "GiB")
|
||||
}
|
||||
.font(.system(size: 8)).foregroundStyle(.secondary)
|
||||
.lineLimit(1).minimumScaleFactor(0.75)
|
||||
HStack(spacing: 4) {
|
||||
Text("memory.available").foregroundStyle(.secondary)
|
||||
MetricText(value: MetricFormat.memory(memory.available))
|
||||
}.font(.system(size: 9)).lineLimit(1)
|
||||
MetricText(value: MetricFormat.memory(memory.available)).fontWeight(.medium)
|
||||
}.frame(height: 16)
|
||||
}
|
||||
.font(.system(size: 10)).lineLimit(1)
|
||||
.help(Text("memory.distributionHelp"))
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel(Text("memory.distribution"))
|
||||
}
|
||||
|
||||
private func classification(_ indices: Range<Int>, unit: Bool) -> some View {
|
||||
HStack(spacing: 4) {
|
||||
ForEach(Array(indices), id: \.self) { index in
|
||||
if index > indices.lowerBound { Text("·").foregroundStyle(.secondary) }
|
||||
HStack(spacing: 3) {
|
||||
Text(labels[index]).foregroundStyle(.secondary)
|
||||
MetricText(value: String(format: "%.1f", Double(values[index]) / 1_073_741_824))
|
||||
.fontWeight(.medium).foregroundStyle(.primary)
|
||||
}
|
||||
.help(Text(MetricFormat.memory(values[index])))
|
||||
}
|
||||
if unit { Text(verbatim: "GiB").foregroundStyle(.secondary) }
|
||||
}.frame(height: 16)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,18 @@ extension MenuPanelView {
|
||||
HStack(spacing: 3) {
|
||||
Text("network.totalShort").foregroundStyle(.secondary)
|
||||
Image(systemName: "arrow.down").foregroundStyle(Color("MetricMemory"))
|
||||
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received }))
|
||||
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received })).fontWeight(.medium)
|
||||
Text("·").foregroundStyle(.secondary)
|
||||
Image(systemName: "arrow.up").foregroundStyle(Color("SeriesUpload"))
|
||||
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent }))
|
||||
}.font(.system(size: 8)).lineLimit(1).minimumScaleFactor(0.75)
|
||||
VStack(spacing: 3) {
|
||||
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent })).fontWeight(.medium)
|
||||
}.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9).frame(height: 16)
|
||||
VStack(spacing: 4) {
|
||||
networkAddress("network.public", address: publicIPAddress)
|
||||
networkAddress(
|
||||
"network.local",
|
||||
address: addressInterface?.addresses.first(where: { !$0.contains(":") }) ?? addressInterface?.addresses.first)
|
||||
}
|
||||
.font(.system(size: 9))
|
||||
.font(.system(size: 10))
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel(Text("network.addresses"))
|
||||
}
|
||||
@@ -54,7 +54,7 @@ extension MenuPanelView {
|
||||
func networkAddress(_ title: LocalizedStringKey, address: String?) -> some View {
|
||||
HStack(spacing: 3) {
|
||||
Text(title).foregroundStyle(.secondary)
|
||||
Text(verbatim: address ?? "--").font(.system(size: 9, weight: .medium)).monospacedDigit().textSelection(.enabled)
|
||||
Text(verbatim: address ?? "--").font(.system(size: 10, weight: .medium)).monospacedDigit().textSelection(.enabled)
|
||||
.help(Text(verbatim: address ?? "--"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
if let address {
|
||||
@@ -66,7 +66,7 @@ extension MenuPanelView {
|
||||
}
|
||||
.buttonStyle(.plain).accessibilityLabel(Text("panel.copy"))
|
||||
}
|
||||
}.frame(maxWidth: .infinity, alignment: .leading).lineLimit(1)
|
||||
}.frame(maxWidth: .infinity, alignment: .leading).frame(height: 16).lineLimit(1)
|
||||
}
|
||||
var networkStatusLabel: LocalizedStringKey {
|
||||
switch snapshot.networkPath {
|
||||
|
||||
@@ -4,10 +4,10 @@ import SwiftUI
|
||||
extension MenuPanelView {
|
||||
func line(_ key: LocalizedStringKey, _ value: String) -> some View {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 4) {
|
||||
Text(key).font(.system(size: 9)).foregroundStyle(.secondary)
|
||||
Text(key).font(.system(size: 10)).foregroundStyle(.secondary)
|
||||
Spacer(minLength: 6)
|
||||
MetricText(value: value).font(.system(size: 9, weight: .medium))
|
||||
}.frame(height: 12)
|
||||
MetricText(value: value).font(.system(size: 10, weight: .medium))
|
||||
}.frame(height: 16)
|
||||
}
|
||||
|
||||
func inlineMetric(_ title: LocalizedStringKey, _ value: String) -> some View {
|
||||
@@ -15,7 +15,7 @@ extension MenuPanelView {
|
||||
Text(title).foregroundStyle(.secondary)
|
||||
MetricText(value: value).fontWeight(.medium)
|
||||
}
|
||||
.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.8)
|
||||
.font(.system(size: 10)).lineLimit(1)
|
||||
}
|
||||
|
||||
func batteryPowerLabel(_ battery: BatteryMetrics) -> LocalizedStringKey {
|
||||
@@ -45,7 +45,7 @@ extension MenuPanelView {
|
||||
HStack(spacing: 5) {
|
||||
inlineMetric("cpu.user", MetricFormat.percent(snapshot.cpu?.user))
|
||||
inlineMetric("cpu.system", MetricFormat.percent(snapshot.cpu?.system))
|
||||
}.frame(height: 12)
|
||||
}.frame(height: 16)
|
||||
if let cpu = snapshot.cpu {
|
||||
CPUCoreGrid(
|
||||
values: cpu.cores, kinds: CPUCoreTopology.cores,
|
||||
@@ -75,9 +75,9 @@ extension MenuPanelView {
|
||||
HStack(spacing: 5) {
|
||||
if let count = snapshot.gpu?.coreCount {
|
||||
Text(verbatim: String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), count))
|
||||
.foregroundStyle(.secondary)
|
||||
.foregroundStyle(.primary)
|
||||
}
|
||||
}.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.75).frame(height: 12)
|
||||
}.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9).frame(height: 16)
|
||||
let fans = displayedFans
|
||||
if !fans.isEmpty {
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 5, alignment: .leading), count: min(2, fans.count)), spacing: 2) {
|
||||
@@ -87,12 +87,12 @@ extension MenuPanelView {
|
||||
? (fan.id == 0 ? Text("gpu.fanLeft") : Text("gpu.fanRight"))
|
||||
: Text("gpu.fanNumber \(fan.id + 1)"), rpm: fan.rpm,
|
||||
isActive: metrics.isPanelVisible && !metrics.isPaused && !metrics.isSystemSleeping && !metrics.isDisplaySleeping)
|
||||
.frame(height: 12)
|
||||
.frame(height: 16)
|
||||
}
|
||||
}
|
||||
} else if snapshot.fans == nil {
|
||||
Text("metric.waiting").font(.system(size: 9))
|
||||
.frame(maxWidth: .infinity, alignment: .leading).frame(height: 12)
|
||||
Text("metric.waiting").font(.system(size: 10))
|
||||
.frame(maxWidth: .infinity, alignment: .leading).frame(height: 16)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ extension MenuPanelView {
|
||||
MemoryDetailsView(memory: memory)
|
||||
} else {
|
||||
Text("metric.waiting").foregroundStyle(.secondary)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ extension MenuPanelView {
|
||||
} ?? "--",
|
||||
headerAccessory: AnyView(Button { showVolumes.toggle() } label: {
|
||||
HStack(spacing: 2) { Text("disk.localVolumes"); Image(systemName: "chevron.right").font(.system(size: 7)) }
|
||||
}.font(.system(size: 9)).buttonStyle(.plain).help(Text("disk.viewDetails"))),
|
||||
}.font(.system(size: 10)).buttonStyle(.plain).help(Text("disk.viewDetails"))),
|
||||
chart: {
|
||||
PanelTrendChart(
|
||||
dates: samples.map(\.date), first: samples.map(\.read), second: samples.map(\.write), color: Color("MetricDisk"),
|
||||
@@ -159,7 +159,7 @@ extension MenuPanelView {
|
||||
"\(MetricFormat.bytes(volume.capacity.available)) / \(MetricFormat.bytes(volume.capacity.total))")
|
||||
}
|
||||
}
|
||||
Text("panel.apfsScope").font(.system(size: 9)).foregroundStyle(.secondary)
|
||||
Text("panel.apfsScope").font(.system(size: 10)).foregroundStyle(.secondary)
|
||||
}
|
||||
}.padding(12).frame(width: 330)
|
||||
.environment(\.locale, locale)
|
||||
@@ -191,17 +191,17 @@ extension MenuPanelView {
|
||||
}
|
||||
) {
|
||||
inlineMetric("battery.powerShort", MetricFormat.watts(snapshot.battery?.power))
|
||||
.frame(height: 12)
|
||||
.frame(height: 16)
|
||||
if let battery = snapshot.battery {
|
||||
batteryDetails(battery)
|
||||
} else {
|
||||
Text(snapshot.batteryState == .absent ? "panel.noBattery" : "panel.batteryFailed").foregroundStyle(.secondary)
|
||||
.font(.system(size: 9)).frame(maxWidth: .infinity).frame(height: 32)
|
||||
.font(.system(size: 10)).frame(maxWidth: .infinity).frame(height: 32)
|
||||
}
|
||||
}
|
||||
}
|
||||
private func batteryDetails(_ battery: BatteryMetrics) -> some View {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(spacing: 8) {
|
||||
inlineMetric("battery.healthShort", MetricFormat.percent(battery.health))
|
||||
inlineMetric("battery.cyclesShort", battery.cycles.map(String.init) ?? "--")
|
||||
@@ -217,6 +217,6 @@ extension MenuPanelView {
|
||||
}
|
||||
}
|
||||
}
|
||||
.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.75)
|
||||
.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.9)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,31 @@ struct StorageDetailsView: View {
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
field("memory.available", value: MetricFormat.bytes(disk?.available))
|
||||
HStack(spacing: 6) {
|
||||
field("disk.read", value: MetricFormat.rate(io?.read))
|
||||
field("disk.write", value: MetricFormat.rate(io?.written))
|
||||
ViewThatFits(in: .horizontal) {
|
||||
HStack(spacing: 6) { read; write }.fixedSize(horizontal: true, vertical: true)
|
||||
VStack(alignment: .leading, spacing: 4) { read; write }
|
||||
}
|
||||
ViewThatFits(in: .horizontal) {
|
||||
HStack(spacing: 4) {
|
||||
life
|
||||
Text("·").foregroundStyle(.secondary)
|
||||
powerOn
|
||||
}.fixedSize(horizontal: true, vertical: true)
|
||||
VStack(alignment: .leading, spacing: 4) { life; powerOn }
|
||||
}
|
||||
HStack(spacing: 4) {
|
||||
field("disk.lifeShort", value: MetricFormat.percent(health?.remainingLife))
|
||||
Text("·").foregroundStyle(.secondary)
|
||||
field("disk.powerOnShort", value: health?.powerOnHours.map { "\($0) h" } ?? "--")
|
||||
}.font(.system(size: 8))
|
||||
}
|
||||
.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.75)
|
||||
.font(.system(size: 10)).lineLimit(1)
|
||||
}
|
||||
|
||||
private var read: some View { field("disk.read", value: MetricFormat.rate(io?.read)) }
|
||||
private var write: some View { field("disk.write", value: MetricFormat.rate(io?.written)) }
|
||||
private var life: some View { field("disk.lifeShort", value: MetricFormat.percent(health?.remainingLife)) }
|
||||
private var powerOn: some View { field("disk.powerOnShort", value: health?.powerOnHours.map { "\($0) h" } ?? "--") }
|
||||
|
||||
private func field(_ title: LocalizedStringKey, value: String) -> some View {
|
||||
HStack(spacing: 3) {
|
||||
Text(title).foregroundStyle(.secondary).help(Text(title))
|
||||
MetricText(value: value)
|
||||
}
|
||||
MetricText(value: value).fontWeight(.medium).foregroundStyle(.primary)
|
||||
}.frame(height: 16)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user