-
-
Save llama-0/4c65f4aa7fdccf8b35ca089f6b30fac1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.llama.core.presentation.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.ReadOnlyComposable | |
import androidx.compose.runtime.staticCompositionLocalOf | |
object AppTheme { | |
val colors: AppColors | |
@Composable | |
@ReadOnlyComposable | |
get() = LocalAppColors.current | |
val typography: AppTypography | |
@Composable | |
@ReadOnlyComposable | |
get() = LocalAppTypography.current | |
} | |
private val LocalAppColors = staticCompositionLocalOf { | |
defaultAppColors() | |
} | |
private val LocalAppTypography = staticCompositionLocalOf { | |
defaultAppTypography() | |
} | |
@Composable | |
fun AppTheme( | |
darkTheme: Boolean = isSystemInDarkTheme(), | |
colors: AppColors = appColors(darkTheme = darkTheme), | |
typography: AppTypography = appTypography(TextStyles(colors)), | |
content: @Composable () -> Unit, | |
) { | |
CompositionLocalProvider( | |
LocalAppColors provides colors, | |
LocalAppTypography provides typography, | |
) { | |
MaterialTheme( | |
colors = colors.materialColors, | |
typography = typography.materialTypography, | |
shapes = Shapes, | |
content = content, | |
) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment