Files
Kymo/kymo/UI/Components/ResourceCard.swift
T

31 lines
1.3 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) {
Label { Text(title).foregroundStyle(.primary) } icon: {
Image(systemName: symbol).foregroundStyle(color)
}.font(.system(size: 13, weight: .semibold))
HStack(alignment: .firstTextBaseline) {
Text(verbatim: value).font(.system(size: 27, weight: .semibold, design: .rounded))
.foregroundStyle(color).monospacedDigit().lineLimit(1).minimumScaleFactor(0.8)
Spacer(minLength: 4)
if let secondaryValue { Text(verbatim: secondaryValue).font(.system(size: 15, weight: .semibold)).foregroundStyle(color).lineLimit(1) }
}
content()
}
.font(.system(size: 11))
.padding(10)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.background(Color("PanelCard"), in: .rect(cornerRadius: 10))
.overlay(RoundedRectangle(cornerRadius: 10).strokeBorder(.primary.opacity(0.14)))
}
}