Also, related to Glance, it seems that it doesn't ...
# glance
p
Also, related to Glance, it seems that it doesn't apply the colors of the theme, on their composables:
Copy code
provideContent {
    GlanceTheme(
        // Using colors from app theme
        colors = ColorProviders(light = lightScheme,dark = darkScheme)
    ) {
        MyContent()
    }
}
is ignoring primary and onPrimary, for example I need to do this to force white text in my texts:
Copy code
Text(style = TextStyle(color = GlanceTheme.colors.onPrimary))
is this normal? to be mandatory to set manually every color of the theme in every composable used in glance?
b
In Text.kt in glance, the default parameter of
style
for text will be
TextDefaults.defaultTextStyle
, which is black. There's a couple things you could do Create an
@Composable val myTextStyle get() = [...]
that resolves the desired text color at runtime. Create your own component that wraps
Text()
and initializes it the way you'd like. File a bug/feature request https://issuetracker.google.com/issues?q=status:open%20componentid:1097239
Copy code
@Composable
public fun Text(
    text: String,
    modifier: GlanceModifier = GlanceModifier,
    style: TextStyle = defaultTextStyle,
    maxLines: Int = Int.MAX_VALUE,
) {
    [...]
}

public object TextDefaults {
    public val defaultTextColor: ColorProvider = ColorProvider(Color.Black)
    public val defaultTextStyle: TextStyle = TextStyle(color = defaultTextColor)
}
The api goal was to be similar to normal compose, which defaults color to
Color.unspecified
. Normal compose however has a concept of
LocalContentColor
that takes over when the color is unspecified, which Glance currently does not have.