35 lines
1.4 KiB
Swift
35 lines
1.4 KiB
Swift
import SwiftUI
|
|
|
|
struct ResourceCard<Content: View>: View {
|
|
let title: LocalizedStringKey
|
|
let symbol: String
|
|
let color: Color
|
|
let value: String
|
|
var secondaryValue: String? = nil
|
|
@ViewBuilder var content: () -> Content
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
|
Label { Text(title).foregroundStyle(.primary) } icon: {
|
|
Image(systemName: symbol).foregroundStyle(color)
|
|
}.font(.system(size: 13, weight: .semibold)).fixedSize()
|
|
Spacer(minLength: 0)
|
|
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
|
AnimatedMetricText(value: value)
|
|
.font(.system(size: 13, weight: .semibold))
|
|
if let secondaryValue {
|
|
AnimatedMetricText(value: secondaryValue).font(.system(size: 13, weight: .semibold))
|
|
}
|
|
}.foregroundStyle(color).lineLimit(1).minimumScaleFactor(0.65)
|
|
}
|
|
content()
|
|
}
|
|
.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)))
|
|
}
|
|
}
|