-
-
Save damianpetla/12a576cf714b05b91018ac4bdf4c6a7f 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
// somewhere in the theming code | |
data class Dimensions( | |
val tiny: Dp = 4.dp, | |
val mediocre: Dp = 16.dp, | |
val craaaazy: Dp = 100.dp | |
) | |
val LocalDimensions = staticCompositionLocalOf { Dimensions() } | |
val MaterialTheme.dimensions | |
@Composable | |
@ReadOnlyComposable | |
get() = LocalDimensions.current | |
// somewhere at top level of your UI hierarchy | |
CompositionLocalProvider(LocalDimensions provides Dimensions()) { | |
MaterialTheme( | |
colors = colors, | |
typography = Typography, | |
shapes = Shapes, | |
content = content | |
) | |
} | |
// somewhere in the layouts | |
Surface(modifier = Modifier.padding(MaterialTheme.dimensions.craaaazy)) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment