package com.gh.gamecenter.setting.compose.ui.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color

data class HaloColor(
    val theme: Color,
    val themeFont: Color,
    val themeRed: Color,
    val textTitle: Color,
    val textSubtitle: Color,
    val textSubtitleDesc: Color,
    val textBody: Color,
    val textNeutral: Color,
    val background: Color,
    val backgroundWhite: Color,
    val backgroundSpace: Color,
    val divider: Color,
)

private val darkHaloColor = HaloColor(
    theme = themeDark,
    themeFont = themeFontDark,
    themeRed = themeRedDark,
    textTitle = textTitleDark,
    textSubtitle = textSubtitleDark,
    textSubtitleDesc = textSubtitleDescDark,
    textBody = textBodyDark,
    textNeutral = textNeutralDark,
    background = backgroundDark,
    backgroundWhite = backgroundWhiteDark,
    backgroundSpace = backgroundSpaceDark,
    divider = dividerDark,
)

private val lightHaloColor = HaloColor(
    theme = themeLight,
    themeFont = themeFontLight,
    themeRed = themeRedLight,
    textTitle = textTitleLight,
    textSubtitle = textSubtitleLight,
    textSubtitleDesc = textSubtitleDescLight,
    textBody = textBodyLight,
    textNeutral = textNeutralLight,
    background = backgroundLight,
    backgroundWhite = backgroundWhiteLight,
    backgroundSpace = backgroundSpaceLight,
    divider = dividerLight,
)

val LocalHaloColors = staticCompositionLocalOf {
    lightHaloColor
}

object HaloTheme {
    val colors: HaloColor
        @Composable
        get() = LocalHaloColors.current
}

@Composable
fun AssistantandroidTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable () -> Unit
) {

    val haloColors = if (darkTheme) {
        darkHaloColor
    } else {
        lightHaloColor
    }

    CompositionLocalProvider(
        LocalHaloColors provides haloColors
    ) {
        MaterialTheme(
            typography = Typography,
            shapes = Shapes,
            content = content
        )
    }
}