molikto
04/21/2020, 3:14 AMText
pick up a Emphasis.high, so the actual content color for Text is not pure black.Louis Pullen-Freilich [G]
04/21/2020, 1:41 PMEmphasis.high
is not a default, the default is no emphasis level, i.e 100% alpha.
Content color represents the raw / unmodified color to be used in a component / hierarchy. For example, if the background is black, then content color is probably white. Content color is not Material specific, and lives in ui-foundation
, which allows generic components like Text
and Icon
to consume this by default, so they will have the correct color for different backgrounds.
Emphasis is a Material specific transformation of content color, essentially applying alpha to the existing content color, and providing the newly modified content color to children. This allows components to apply different emphasis levels to their content, to emphasize / de-emphasize subcomponents as needed.
TextStyle
is just a collection of properties used to style a Text
, so it's not really that related to content color - you can explicitly set color
in TextStyle
to override the content color / emphasis, but most of the time you probably want to use / set content color.
The intended use of this is something like:
@Composable
fun IconListItem(icon, label...) {
// Provide red as the content color
Providers(ContentColorAmbient provides Color.Red) {
Row {
// Provide medium emphasis for the icon ProvideEmphasis(emphasisLevels.medium) {
icon()
}
// Provide high emphasis for the label
ProvideEmphasis(emphasisLevels.high) {
label()
}
}
}
}
Does this make sense? In general we need to write more tutorials / guidance / docs around this, as it's not very visible right now.molikto
04/21/2020, 1:57 PMLouis Pullen-Freilich [G]
04/21/2020, 2:04 PMmolikto
04/21/2020, 2:08 PM