Hieu Truong
07/03/2023, 6:12 AMval customTextSelectionColors = TextSelectionColors(
handleColor = Blue06,
backgroundColor = BlueAlpha04
)
CompositionLocalProvider(LocalTextSelectionColors provides customTextSelectionColors) {
BasicTextField(...)
How to let it work globally without creating wrapper like above?
I tried to put into App Theme, but it does not work.
@Composable
fun AppTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
val color = if (darkTheme) {
DarkColorPalette
} else {
LightColorPalette
}
val customColorsPalette = if (darkTheme) {
AppDarkColorsPalette
} else {
AppLightColorsPalette
}
val customTextSelectionColors = if (darkTheme) {
DarkTextSelectionColors
} else {
LightTextSelectionColors
}
CompositionLocalProvider(
AppLocalColorsPalette provides customColorsPalette,
LocalTextSelectionColors provides customTextSelectionColors,
) {
MaterialTheme(
colors = color,
typography = MaterialTheme.typography,
shapes = Shapes,
content = content
)
}
}
Hieu Truong
07/03/2023, 6:17 AMMaterialTheme(
colors = color,
typography = MaterialTheme.typography,
shapes = Shapes,
) {
CompositionLocalProvider(
AppLocalColorsPalette provides customColorsPalette,
LocalTextSelectionColors provides customTextSelectionColors,
content = content
)
}