Tolriq
01/13/2022, 6:03 PMChris Sinco [G]
01/13/2022, 8:13 PMTolriq
01/13/2022, 8:26 PMChris Sinco [G]
01/13/2022, 8:30 PMYes, providing the Contentalpha does not workIs this in a specific Material3 component or just
Text
?Tolriq
01/13/2022, 8:34 PMCompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium)
Chris Sinco [G]
01/13/2022, 8:35 PMTolriq
01/13/2022, 8:39 PMCompositionLocalProvider(LocalContentColor provides TextContentAlpha.medium) {
Text(subtitle)
}
But it's normal I guess.
Material Text have:
val textColor = color.takeOrElse {
style.color.takeOrElse {
LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
}
}
but Material 3 text have
val textColor = color.takeOrElse {
style.color.takeOrElse {
LocalContentColor.current
}
}
So I guess there's not LocalContentAlpha support at all in material 3. Just wondering if it will be added in the same way or in a new way. If same way I can provide a localcolor and apply the alpha easy to search and replace. If not maybe I need to directly work with typography and TextStyles to supply colors with alpha directly.CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(subtitle)
}
Is what was working in m2 and no more in m3Chris Sinco [G]
01/14/2022, 12:20 AMAlbert Chang
01/14/2022, 12:37 AMMatetialTheme.colorScheme.onSurfaceVariant
(which is actually opaque) for medium alpha text. But indeed there doesn't seem to be a good way to set disabled alpha.Tolriq
01/14/2022, 6:32 AMobject ContentColorAlpha {
val high: Color
@Composable
get() = LocalContentColor.current.copy(alpha = ContentAlpha.high)
val medium: Color
@Composable
get() = LocalContentColor.current.copy(alpha = ContentAlpha.medium)
val disabled: Color
@Composable
get() = LocalContentColor.current.copy(alpha = ContentAlpha.disabled)
}
With
CompositionLocalProvider(LocalContentColor provides ContentColorAlpha.medium) {
The advantage is that it works also on other components so I can apply that on a row and it applies to all inside it and it works whatever the current color is. The inconvenient is that it does not work for components with forced color and I must add it there too.
I hope you can have some feedback on this, maybe I need to open an issue?
@Albert Chang The problem of onSurfaceVariant is that it's only one color for one case, and some non dynamictonal theme may use something that does not work as this use case :(Chris Sinco [G]
01/19/2022, 2:09 AMTolriq
01/19/2022, 6:56 AMAlbert Chang
01/19/2022, 7:07 AMText
or by specifying the alpha
parameter of Image
) is more efficient than using an alpha modifier as it doesn’t require the content to be rendered into an offscreen buffer.Tolriq
01/19/2022, 7:36 AMAlbert Chang
01/19/2022, 7:44 AMTolriq
01/19/2022, 7:52 AMCompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium)
no ?Albert Chang
01/19/2022, 7:54 AMTolriq
01/19/2022, 7:54 AMAlbert Chang
01/19/2022, 8:01 AMTolriq
01/19/2022, 8:07 AMAlbert Chang
01/19/2022, 8:18 AMTolriq
01/19/2022, 8:28 AM