package com.optix.android.ui.theme

import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider

@Composable
fun NeonTheme(
    appTheme: AppTheme = Themes.generate("red", true),
    content: @Composable () -> Unit,
) {
    val colorScheme = if (appTheme.isDark) {
        darkColorScheme(
            primary            = appTheme.accent,
            onPrimary          = appTheme.onSurface,
            primaryContainer   = appTheme.accentDim,
            secondary          = appTheme.accentGlow,
            background         = appTheme.background,
            surface            = appTheme.surface,
            surfaceVariant     = appTheme.surfaceVar,
            onBackground       = appTheme.onSurface,
            onSurface          = appTheme.onSurface,
            onSurfaceVariant   = appTheme.onSurfaceMid,
            error              = appTheme.warning,
            outline            = appTheme.border,
            tertiary           = appTheme.utility,
        )
    } else {
        lightColorScheme(
            primary            = appTheme.accent,
            onPrimary          = appTheme.onSurface,
            primaryContainer   = appTheme.accentDim,
            secondary          = appTheme.accentGlow,
            background         = appTheme.background,
            surface            = appTheme.surface,
            surfaceVariant     = appTheme.surfaceVar,
            onBackground       = appTheme.onSurface,
            onSurface          = appTheme.onSurface,
            onSurfaceVariant   = appTheme.onSurfaceMid,
            error              = appTheme.warning,
            outline            = appTheme.border,
            tertiary           = appTheme.utility,
        )
    }

    CompositionLocalProvider(LocalAppTheme provides appTheme) {
        MaterialTheme(
            colorScheme = colorScheme,
            typography  = NeonTypography,
            content     = content,
        )
    }
}
