mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-11 03:13:12 +00:00
Add a theme token system (CCSBarCore/BarTheme.swift): a BarAppearance enum (system/light/dark, default dark to preserve the current look), light+dark token palettes, a colorScheme-driven resolver, and a SwiftUI EnvironmentKey. The root forces .preferredColorScheme so Light renders light even under a dark macOS, and paints an explicit light window surface. Thread the tokens (accent, headroom bands, subscription, card surface, track) through every view so the whole dropdown themes consistently, with chip text blending toward black on light. Add an appearance picker in Preferences, persisted in UserDefaults. Dark accent/subscription values are locked byte-identical and harness-guarded; pool-account rows now share the muted band palette for cross-section consistency.
28 lines
1.0 KiB
Swift
28 lines
1.0 KiB
Swift
import SwiftUI
|
|
import CCSBarCore
|
|
|
|
/// A compact bar sparkline for daily values (e.g. cost per day over 7 days).
|
|
/// Zero-value days render as faint placeholders so the cadence stays readable.
|
|
struct Sparkline: View {
|
|
let values: [Double]
|
|
// Default is the dark preset's accent: a default argument can't read the
|
|
// environment, so this is the static fallback. Live callers pass the themed
|
|
// `theme.accent` from the parent so the rendered bar follows the chosen theme.
|
|
var accent: Color = BarTheme.dark.accent
|
|
|
|
var body: some View {
|
|
GeometryReader { geo in
|
|
let peak = max(values.max() ?? 0, 0.0001)
|
|
HStack(alignment: .bottom, spacing: 3) {
|
|
ForEach(Array(values.enumerated()), id: \.offset) { _, value in
|
|
let height = CGFloat(value / peak) * geo.size.height
|
|
RoundedRectangle(cornerRadius: 2)
|
|
.fill(value > 0 ? accent : Color.secondary.opacity(0.2))
|
|
.frame(height: max(2, height))
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
|
|
}
|
|
}
|
|
}
|