package com.servicebook.ui.theme import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.TopAppBarColors import androidx.compose.material3.TopAppBarDefaults 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 LightColorScheme = lightColorScheme( primary = PrimaryLight, onPrimary = OnPrimaryLight, primaryContainer = PrimaryContainerLight, onPrimaryContainer = OnPrimaryContainerLight, secondary = SecondaryLight, onSecondary = OnSecondaryLight, secondaryContainer = SecondaryContainerLight, onSecondaryContainer = OnSecondaryContainerLight, tertiary = TertiaryLight, onTertiary = OnTertiaryLight, tertiaryContainer = TertiaryContainerLight, onTertiaryContainer = OnTertiaryContainerLight, error = ErrorLight, onError = OnErrorLight, errorContainer = ErrorContainerLight, onErrorContainer = OnErrorContainerLight, background = BackgroundLight, onBackground = OnBackgroundLight, surface = SurfaceLight, onSurface = OnSurfaceLight, surfaceVariant = SurfaceVariantLight, onSurfaceVariant = OnSurfaceVariantLight, outline = OutlineLight, surfaceContainerLowest = SurfaceContainerLowestLight, surfaceContainerLow = SurfaceContainerLowLight, surfaceContainer = SurfaceContainerLight, surfaceContainerHigh = SurfaceContainerHighLight, surfaceContainerHighest = SurfaceContainerHighestLight, ) private val DarkColorScheme = darkColorScheme( primary = PrimaryDark, onPrimary = OnPrimaryDark, primaryContainer = PrimaryContainerDark, onPrimaryContainer = OnPrimaryContainerDark, secondary = SecondaryDark, onSecondary = OnSecondaryDark, secondaryContainer = SecondaryContainerDark, onSecondaryContainer = OnSecondaryContainerDark, tertiary = TertiaryDark, onTertiary = OnTertiaryDark, tertiaryContainer = TertiaryContainerDark, onTertiaryContainer = OnTertiaryContainerDark, error = ErrorDark, onError = OnErrorDark, errorContainer = ErrorContainerDark, onErrorContainer = OnErrorContainerDark, background = BackgroundDark, onBackground = OnBackgroundDark, surface = SurfaceDark, onSurface = OnSurfaceDark, surfaceVariant = SurfaceVariantDark, onSurfaceVariant = OnSurfaceVariantDark, outline = OutlineDark, surfaceContainerLowest = SurfaceContainerLowestDark, surfaceContainerLow = SurfaceContainerLowDark, surfaceContainer = SurfaceContainerDark, surfaceContainerHigh = SurfaceContainerHighDark, surfaceContainerHighest = SurfaceContainerHighestDark, ) @Composable fun appTopAppBarColors(): TopAppBarColors = TopAppBarDefaults.topAppBarColors( containerColor = MaterialTheme.colorScheme.surfaceContainerHigh, scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainerHigh, ) @Composable fun ServiceBookTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Material You on Android 12+ dynamicColor: Boolean = true, content: @Composable () -> Unit, ) { val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } darkTheme -> DarkColorScheme else -> LightColorScheme } val themedColorScheme = colorScheme.copy(background = colorScheme.surfaceContainerHigh) MaterialTheme( colorScheme = themedColorScheme, typography = AppTypography, content = content, ) }