fix(ui): 缩小卡片并还原设计稿紧凑排布
This commit is contained in:
@@ -29,7 +29,7 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
||||
.frame(width: bounds.size.width, height: ResourceCardMetrics.plotHeight)
|
||||
VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) {
|
||||
header
|
||||
HStack(alignment: .firstTextBaseline, spacing: 12) {
|
||||
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)
|
||||
@@ -40,18 +40,18 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
||||
content()
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.font(PanelStyle.label)
|
||||
.font(.system(size: 9))
|
||||
.padding(ResourceCardMetrics.padding)
|
||||
.padding(.bottom, ResourceCardMetrics.plotHeight - ResourceCardMetrics.padding)
|
||||
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
|
||||
}
|
||||
.background(Color("PanelCard"))
|
||||
.clipShape(.rect(cornerRadius: ResourceCardMetrics.radius))
|
||||
.overlay(RoundedRectangle(cornerRadius: ResourceCardMetrics.radius).strokeBorder(.primary.opacity(0.07)))
|
||||
.overlay(RoundedRectangle(cornerRadius: ResourceCardMetrics.radius).strokeBorder(.primary.opacity(colorScheme == .dark ? 0.06 : 0.025)))
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: ResourceCardMetrics.radius)
|
||||
.fill(Color("PanelCard"))
|
||||
.shadow(color: .black.opacity(colorScheme == .dark ? 0.16 : 0.06), radius: 6, x: 0, y: 2)
|
||||
.shadow(color: .black.opacity(colorScheme == .dark ? 0.12 : 0.05), radius: 4, x: 0, y: 1)
|
||||
}
|
||||
}
|
||||
.overlayPreferenceValue(ChartTooltipPreference.self) { tooltip in
|
||||
@@ -77,19 +77,19 @@ struct ResourceCard<Chart: View, Content: View>: View {
|
||||
} icon: {
|
||||
Image(systemName: symbol).foregroundStyle(statusWarning ? .red : color)
|
||||
}
|
||||
.font(.system(size: 14, weight: .semibold)).fixedSize()
|
||||
.font(.system(size: 11, weight: .semibold)).fixedSize()
|
||||
Spacer(minLength: 4)
|
||||
if let status {
|
||||
Text(verbatim: status)
|
||||
.font(.system(size: 11, weight: .medium))
|
||||
.font(.system(size: 9, 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: 10, weight: .medium)).foregroundStyle(detailColor ?? .secondary)
|
||||
.padding(.horizontal, 6).frame(height: 18)
|
||||
.font(.system(size: 8, weight: .medium)).foregroundStyle(detailColor ?? .secondary)
|
||||
.padding(.horizontal, 5).frame(height: 14)
|
||||
.background((detailColor ?? .primary).opacity(0.10), in: Capsule())
|
||||
.lineLimit(1)
|
||||
.help(Text(verbatim: detailHelp ?? detail))
|
||||
@@ -115,20 +115,20 @@ private struct MetricHeadline: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 3) {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 2) {
|
||||
if let direction {
|
||||
Image(systemName: direction == "↓" ? "arrow.down" : "arrow.up")
|
||||
.font(.system(size: 16, weight: .medium))
|
||||
.font(.system(size: 12, weight: .medium)).foregroundStyle(color)
|
||||
}
|
||||
Text(verbatim: parts.first.map(String.init) ?? value)
|
||||
.font(.system(size: compact ? 23 : 36, weight: .semibold))
|
||||
.font(.system(size: compact ? 16 : 28, weight: .semibold))
|
||||
if parts.count > 1 {
|
||||
Text(verbatim: String(parts[1]))
|
||||
.font(.system(size: compact ? 11 : 14, weight: .medium))
|
||||
.foregroundStyle(Color.secondary)
|
||||
.font(.system(size: compact ? 9 : 12, weight: .medium))
|
||||
.foregroundStyle(Color.primary.opacity(0.8))
|
||||
}
|
||||
}
|
||||
.monospacedDigit().foregroundStyle(color)
|
||||
.monospacedDigit().foregroundStyle(.primary)
|
||||
.lineLimit(1).minimumScaleFactor(0.75)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.help(Text(verbatim: value))
|
||||
|
||||
Reference in New Issue
Block a user