fix(ui): 提升卡片文字对比度与辅助信息可读性
This commit is contained in:
@@ -27,20 +27,10 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
||||
ZStack(alignment: .bottomLeading) {
|
||||
chart()
|
||||
.frame(width: bounds.size.width, height: bounds.size.height)
|
||||
VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) {
|
||||
header
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
MetricHeadline(value: value, compact: secondaryValue != nil, color: valueColor ?? .primary)
|
||||
if let secondaryValue {
|
||||
MetricHeadline(value: secondaryValue, compact: true, color: secondaryValueColor ?? .primary)
|
||||
}
|
||||
}
|
||||
.frame(height: ResourceCardMetrics.headlineHeight, alignment: .leading)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
content()
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
foreground
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.font(.system(size: 9))
|
||||
.padding(ResourceCardMetrics.padding)
|
||||
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
|
||||
}
|
||||
@@ -69,6 +59,29 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var foreground: some View {
|
||||
VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) {
|
||||
header
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
MetricHeadline(value: value, compact: secondaryValue != nil, color: valueColor ?? .primary)
|
||||
if let secondaryValue {
|
||||
MetricHeadline(value: secondaryValue, compact: true, color: secondaryValueColor ?? .primary)
|
||||
}
|
||||
}
|
||||
.frame(height: ResourceCardMetrics.headlineHeight, alignment: .leading)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
content()
|
||||
}
|
||||
.font(.system(size: ResourceCardMetrics.auxiliarySize))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.fill(Color("PanelCard").opacity(ResourceCardMetrics.textBackgroundOpacity))
|
||||
.padding(-4)
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
HStack(spacing: 6) {
|
||||
Label {
|
||||
@@ -80,14 +93,14 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
||||
Spacer(minLength: 4)
|
||||
if let status {
|
||||
Text(verbatim: status)
|
||||
.font(.system(size: 9, weight: .medium))
|
||||
.font(.system(size: 10, weight: .medium))
|
||||
.foregroundStyle(statusWarning ? .red : .secondary)
|
||||
.help(warningText ?? Text(verbatim: status))
|
||||
.accessibilityLabel(warningText.map { Text("\(status) \($0)") } ?? Text(verbatim: status))
|
||||
}
|
||||
if let detail {
|
||||
Text(verbatim: detail)
|
||||
.font(.system(size: 8, weight: .medium)).foregroundStyle(detailColor ?? .secondary)
|
||||
.font(.system(size: 10, weight: .medium)).foregroundStyle(detailColor ?? .secondary)
|
||||
.padding(.horizontal, 5).frame(height: 14)
|
||||
.background((detailColor ?? .primary).opacity(0.10), in: Capsule())
|
||||
.lineLimit(1)
|
||||
@@ -123,7 +136,7 @@ private struct MetricHeadline: View {
|
||||
.font(.system(size: compact ? 16 : 28, weight: .semibold))
|
||||
if parts.count > 1 {
|
||||
Text(verbatim: String(parts[1]))
|
||||
.font(.system(size: compact ? 9 : 12, weight: .medium))
|
||||
.font(.system(size: compact ? 10 : 12, weight: .medium))
|
||||
.foregroundStyle(Color.primary.opacity(0.8))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user