package com.peachpasswords.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 import androidx.compose.runtime.compositionLocalOf import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp /** Current accent color, available to any composable under [PeachTheme]. */ val LocalPeachAccent = compositionLocalOf { DEFAULT_ACCENT } /** When true, decorative/long-running animations should be skipped or shortened. */ val LocalReduceMotion = staticCompositionLocalOf { false } /** True when the active scheme is dark — some surfaces tune themselves off this. */ val LocalPeachDark = staticCompositionLocalOf { true } @Composable fun PeachTheme( darkTheme: Boolean = true, accent: Color = DEFAULT_ACCENT, reduceMotion: Boolean = false, content: @Composable () -> Unit, ) { val colors = if (darkTheme) { darkColorScheme( primary = accent, onPrimary = PeachColors.Bg, secondary = PeachColors.SyncBusy, onSecondary = PeachColors.Bg, background = PeachColors.Bg, onBackground = PeachColors.T0, surface = PeachColors.S1, onSurface = PeachColors.T0, surfaceVariant = PeachColors.S2, onSurfaceVariant = PeachColors.T1, outline = PeachColors.T3, error = PeachColors.Breach, onError = PeachColors.Bg, ) } else { lightColorScheme( primary = accent, onPrimary = PeachColorsLight.Bg, secondary = PeachColorsLight.TextLink, onSecondary = PeachColorsLight.Bg, background = PeachColorsLight.Bg, onBackground = PeachColorsLight.T0, surface = PeachColorsLight.S1, onSurface = PeachColorsLight.T0, surfaceVariant = PeachColorsLight.S2, onSurfaceVariant = PeachColorsLight.T1, outline = PeachColorsLight.BorderSubtle, error = PeachColorsLight.BreachText, onError = PeachColorsLight.Bg, ) } val typography = androidx.compose.material3.Typography( bodyLarge = TextStyle( fontFamily = PeachType.Body, fontSize = 16.sp, fontWeight = FontWeight.Normal, ), titleLarge = TextStyle( fontFamily = PeachType.Display, fontSize = 24.sp, fontStyle = FontStyle.Italic, fontWeight = FontWeight.Light, ), labelLarge = TextStyle( fontFamily = PeachType.Body, fontSize = 12.sp, fontWeight = FontWeight.Medium, ), ) val palette = if (darkTheme) peachDark(accent) else peachLight(accent) CompositionLocalProvider( LocalPeachAccent provides accent, LocalReduceMotion provides reduceMotion, LocalPeachDark provides darkTheme, LocalPeachColors provides palette, ) { MaterialTheme(colorScheme = colors, typography = typography, content = content) } }