refactor(ui): 统一资源卡片规范并收敛面板布局与公共组件
This commit is contained in:
@@ -16,48 +16,55 @@ struct ResourceCard<Content: View>: View {
|
||||
@ViewBuilder var content: () -> Content
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack(alignment: .center, spacing: 6) {
|
||||
Label { Text(title).foregroundStyle(statusWarning ? .red : .primary) } icon: {
|
||||
Image(systemName: symbol).foregroundStyle(statusWarning ? .red : color)
|
||||
}.font(.system(size: 13, weight: .semibold)).fixedSize()
|
||||
if let status {
|
||||
Text(verbatim: status)
|
||||
.font(.system(size: 10, weight: .medium))
|
||||
.foregroundStyle(statusWarning ? .red : color)
|
||||
.padding(.horizontal, 6).padding(.vertical, 2)
|
||||
.background((statusWarning ? Color.red : color).opacity(0.14), in: Capsule())
|
||||
.help(statusHelp ?? Text(verbatim: status))
|
||||
if let warningText {
|
||||
warningText
|
||||
.font(.system(size: 10)).foregroundStyle(.red).lineLimit(1).minimumScaleFactor(0.7)
|
||||
}
|
||||
}
|
||||
if let detail {
|
||||
Text(verbatim: detail)
|
||||
.font(.system(size: 9, weight: .medium)).foregroundStyle(.secondary)
|
||||
.padding(.horizontal, 5).padding(.vertical, 2)
|
||||
.background(.primary.opacity(0.06), in: Capsule())
|
||||
.lineLimit(1).minimumScaleFactor(0.7)
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
GeometryReader { bounds in
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(alignment: .center, spacing: 6) {
|
||||
AnimatedMetricText(value: value)
|
||||
.font(.system(size: 13, weight: .semibold))
|
||||
.foregroundStyle(valueColor ?? color)
|
||||
if let secondaryValue {
|
||||
AnimatedMetricText(value: secondaryValue).font(.system(size: 13, weight: .semibold))
|
||||
.foregroundStyle(secondaryValueColor ?? color)
|
||||
Label {
|
||||
Text(title).foregroundStyle(statusWarning ? .red : .primary)
|
||||
} icon: {
|
||||
Image(systemName: symbol).frame(width: 16, height: 16).foregroundStyle(statusWarning ? .red : color)
|
||||
}.font(PanelStyle.title).fixedSize()
|
||||
if let status {
|
||||
Text(verbatim: status)
|
||||
.font(.system(size: 10, weight: .medium))
|
||||
.foregroundStyle(statusWarning ? .red : color)
|
||||
.padding(.horizontal, 6).frame(height: 16)
|
||||
.background((statusWarning ? Color.red : color).opacity(0.14), in: Capsule())
|
||||
.help(statusHelp ?? Text(verbatim: status))
|
||||
if let warningText {
|
||||
warningText
|
||||
.font(.system(size: 10)).foregroundStyle(.red).lineLimit(1)
|
||||
}
|
||||
}
|
||||
}.foregroundStyle(color).lineLimit(1).minimumScaleFactor(0.65)
|
||||
if let detail {
|
||||
Text(verbatim: detail)
|
||||
.font(.system(size: 10, weight: .medium)).foregroundStyle(.secondary)
|
||||
.padding(.horizontal, 6).frame(height: 16)
|
||||
.background(.primary.opacity(0.06), in: Capsule())
|
||||
.lineLimit(1)
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
HStack(alignment: .center, spacing: 6) {
|
||||
AnimatedMetricText(value: value)
|
||||
.font(PanelStyle.title)
|
||||
.foregroundStyle(valueColor ?? color)
|
||||
if let secondaryValue {
|
||||
AnimatedMetricText(value: secondaryValue).font(PanelStyle.title)
|
||||
.foregroundStyle(secondaryValueColor ?? color)
|
||||
}
|
||||
}.foregroundStyle(color).lineLimit(1)
|
||||
}
|
||||
.frame(height: PanelStyle.titleHeight)
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
content()
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
content()
|
||||
.font(PanelStyle.label)
|
||||
.padding(PanelStyle.padding)
|
||||
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
|
||||
}
|
||||
.font(.system(size: 11))
|
||||
.padding(10)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
.modifier(PanelCardBackground(radius: 10))
|
||||
.overlay(RoundedRectangle(cornerRadius: 10).strokeBorder(.primary.opacity(0.14)))
|
||||
.modifier(CardSurface())
|
||||
.overlayPreferenceValue(ChartTooltipPreference.self) { tooltip in
|
||||
GeometryReader { proxy in
|
||||
if let tooltip {
|
||||
|
||||
Reference in New Issue
Block a user