import SwiftUI /// Mirrors the Kotlin `WidgetPalette` in WidgetRenderer.kt so day/week widgets /// look identical across platforms. All values are hex tokens from the in-app /// LightAppTheme / DarkAppTheme — do not swap to system colors, the whole /// point is platform-independent branding. struct WidgetPalette { let background: Color let textPrimary: Color let textSecondary: Color let divider: Color let accent: Color let onAccent: Color let breakBlock: Color let todayTint: Color let holidayTint: Color let watermarkOpacity: Double // ColorScheme.fromSeed(#993333).primary of the app's light / dark theme. private static let lightAccent = Color(red: 0x90 / 255, green: 0x4A / 255, blue: 0x47 / 255) private static let darkAccent = Color(red: 0xFF / 255, green: 0xB3 / 255, blue: 0xAF / 255) static let light = WidgetPalette( background: Color(red: 0xFC / 255, green: 0xF7 / 255, blue: 0xF5 / 255), textPrimary: Color(red: 0x11 / 255, green: 0x11 / 255, blue: 0x11 / 255), textSecondary: Color(red: 0x55 / 255, green: 0x55 / 255, blue: 0x55 / 255), divider: Color.black.opacity(0x22 / 255.0), accent: lightAccent, onAccent: .white, breakBlock: lightAccent.opacity(0x32 / 255.0), todayTint: lightAccent.opacity(0x0E / 255.0), holidayTint: Color.black.opacity(0x32 / 255.0), watermarkOpacity: 0.014 ) static let dark = WidgetPalette( background: Color(red: 0x1F / 255, green: 0x17 / 255, blue: 0x16 / 255), textPrimary: Color(red: 0xF1 / 255, green: 0xF1 / 255, blue: 0xF1 / 255), textSecondary: Color(red: 0xB0 / 255, green: 0xB0 / 255, blue: 0xB0 / 255), divider: Color.white.opacity(0x33 / 255.0), accent: darkAccent, onAccent: Color(red: 0x57 / 255, green: 0x1D / 255, blue: 0x1D / 255), breakBlock: darkAccent.opacity(0x32 / 255.0), todayTint: darkAccent.opacity(0x0E / 255.0), holidayTint: Color.white.opacity(0x32 / 255.0), watermarkOpacity: 0.025 ) static func resolve(themeMode: String, colorScheme: ColorScheme) -> WidgetPalette { let isDark: Bool switch themeMode { case "light": isDark = false case "dark": isDark = true default: isDark = colorScheme == .dark } return isDark ? .dark : .light } } private struct WidgetPaletteKey: EnvironmentKey { static let defaultValue = WidgetPalette.light } extension EnvironmentValues { var widgetPalette: WidgetPalette { get { self[WidgetPaletteKey.self] } set { self[WidgetPaletteKey.self] = newValue } } }