Anthony
12/15/2021, 5:26 PMCompositionLocalProvider
to provide alpha and text values, should the approach be different when using an annotated string? When I use a simple Text composable, the alpha and color is applied, but a annotated string inside a clickable text does not reflect these changes.CompositionLocalProvider(
LocalContentAlpha provides ContentAlpha.medium,
LocalContentColor provides Color.White
) {
Text("Hello")
}
This works
CompositionLocalProvider(
LocalContentAlpha provides ContentAlpha.medium,
LocalContentColor provides Color.White
) {
ClickableText(
text = annotatedString,
onClick = { offset ->
annotatedString.getStringAnnotations(
tag = "terms",
start = offset,
end = offset
).firstOrNull()?.let {
Log.d("terms", it.item)
}
annotatedString.getStringAnnotations(
tag = "privacyPolicy",
start = offset,
end = offset
).firstOrNull()?.let {
Log.d("privacyPolicy", it.item)
}
},
// style = MaterialTheme.typography.subtitle2,
modifier = Modifier.padding(start = 32.dp, end = 32.dp)
)
}
This does notZach Klippenstein (he/him) [MOD]
12/15/2021, 7:13 PMText
is a material component, and LocalContent*
locals are part of the material theming implementation.ClickableText
isn’t material, and doesn’t know about those. We’re aware that ClickableText
has a lot of issues and are planning to come up with a more flexible solution eventually.Anthony
12/15/2021, 7:15 PM