Activity Chart Intensity Logic
Nucleic-Session: 76D64900-B16F-45BE-A6CB-E3D2EBC7C73A Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -128,18 +128,23 @@ private struct InProgressSessions: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private struct StatCard: View {
|
private struct StatCard: View {
|
||||||
let value: String
|
/// Candidate renderings of the value, widest first: the card shows the fullest one its width
|
||||||
|
/// allows (via `ViewThatFits`) and falls back to the narrowest. A single entry for the plain
|
||||||
|
/// integer cards; several for the token card, so a wide card shows more digits than "1.6B".
|
||||||
|
let values: [String]
|
||||||
let label: String
|
let label: String
|
||||||
let icon: String
|
let icon: String
|
||||||
|
|
||||||
init(value: Int, label: String, icon: String) {
|
init(value: Int, label: String, icon: String) {
|
||||||
self.value = "\(value)"
|
self.init(values: ["\(value)"], label: label, icon: icon)
|
||||||
self.label = label
|
|
||||||
self.icon = icon
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(value: String, label: String, icon: String) {
|
init(value: String, label: String, icon: String) {
|
||||||
self.value = value
|
self.init(values: [value], label: label, icon: icon)
|
||||||
|
}
|
||||||
|
|
||||||
|
init(values: [String], label: String, icon: String) {
|
||||||
|
self.values = values.isEmpty ? [""] : values
|
||||||
self.label = label
|
self.label = label
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
}
|
}
|
||||||
@@ -147,7 +152,14 @@ private struct StatCard: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
Image(systemName: icon).foregroundStyle(Palette.accent)
|
Image(systemName: icon).foregroundStyle(Palette.accent)
|
||||||
Text(value).font(.title2.weight(.semibold).monospacedDigit())
|
// Show the fullest value the card's width fits, shrinking toward the compact form when
|
||||||
|
// narrow; ViewThatFits renders the last candidate if none fit, so it never overflows.
|
||||||
|
ViewThatFits(in: .horizontal) {
|
||||||
|
ForEach(Array(values.enumerated()), id: \.offset) { _, value in
|
||||||
|
Text(value).font(.title2.weight(.semibold).monospacedDigit())
|
||||||
|
.lineLimit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
Text(label).font(.caption).foregroundStyle(.secondary)
|
Text(label).font(.caption).foregroundStyle(.secondary)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|||||||
Reference in New Issue
Block a user