package xyz.cottongin.radio247.ui.theme

import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext

private val DarkColorScheme = darkColorScheme(
    primary = Amber400,
    onPrimary = BlueGray950,
    primaryContainer = BlueGray700,
    onPrimaryContainer = BlueGray100,
    secondary = BlueGray400,
    onSecondary = BlueGray100,
    secondaryContainer = BlueGray800,
    onSecondaryContainer = BlueGray200,
    tertiary = Amber300,
    onTertiary = BlueGray950,
    background = BlueGray950,
    onBackground = BlueGray100,
    surface = BlueGray900,
    onSurface = BlueGray100,
    surfaceVariant = BlueGray800,
    onSurfaceVariant = BlueGray300,
    outline = BlueGray600,
    outlineVariant = BlueGray700
)

private val LightColorScheme = lightColorScheme(
    primary = Amber500,
    onPrimary = BlueGray900,
    primaryContainer = Amber300,
    onPrimaryContainer = BlueGray900,
    secondary = BlueGray600,
    onSecondary = BlueGray100,
    secondaryContainer = BlueGray200,
    onSecondaryContainer = BlueGray800,
    tertiary = Amber400,
    onTertiary = BlueGray900,
    background = BlueGray100,
    onBackground = BlueGray900,
    surface = BlueGray500,
    onSurface = BlueGray900,
    surfaceVariant = BlueGray200,
    onSurfaceVariant = BlueGray700,
    outline = BlueGray600,
    outlineVariant = BlueGray400
)

@Composable
fun Radio247Theme(content: @Composable () -> Unit) {
    val dynamicColor = Build.VERSION.SDK_INT >= 31
    val darkTheme = isSystemInDarkTheme()
    val colorScheme = when {
        dynamicColor && darkTheme -> dynamicDarkColorScheme(LocalContext.current)
        dynamicColor && !darkTheme -> dynamicLightColorScheme(LocalContext.current)
        darkTheme -> DarkColorScheme
        else -> LightColorScheme
    }
    MaterialTheme(
        colorScheme = colorScheme,
        typography = Typography,
        content = content
    )
}
