package me.khodak.claudeusage

import android.content.Context
import android.os.Build
import me.khodak.claudeusage.data.PreferencesManager

/**
 * Central source of the two accent colors used by the bars/rings (session + weekly).
 *
 * Default = the Claude brand palette. When the user enables Material You *and* the device is
 * Android 12+ (where the wallpaper-derived `system_accent*` palette exists), the fills switch to
 * the dynamic system accents so the widget matches the rest of the home screen. On older devices
 * the toggle is a no-op and the brand colors are always used.
 */
object ThemeColors {

    const val SESSION_DEFAULT = 0xFFCC785C.toInt()   // Claude orange
    const val WEEKLY_DEFAULT = 0xFF7B8FCC.toInt()    // Claude periwinkle

    private fun dynamicAvailable(prefs: PreferencesManager): Boolean =
        prefs.isMaterialYou() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S

    fun sessionFill(context: Context, prefs: PreferencesManager): Int =
        if (dynamicAvailable(prefs)) context.getColor(android.R.color.system_accent1_300)
        else SESSION_DEFAULT

    fun weeklyFill(context: Context, prefs: PreferencesManager): Int =
        if (dynamicAvailable(prefs)) context.getColor(android.R.color.system_accent2_300)
        else WEEKLY_DEFAULT
}
