Hi, I’m new to JetPack compose and I’m a bit confu...
# compose
Hi, I’m new to JetPack compose and I’m a bit confused with colors and themes in JetPack Compose. When I do:
Copy code
        text = "Something",
        style = MaterialTheme.typography.body1
then color is wrong when Android is set to dark mode. It is somehow connected to `Surface`/`Scaffold`but it is still not working for me. Why it is designed in so counterintuitive way? It looks like I have to specify colors in
(which is solution I feel is wrong as colors should be in ColorScheme IMHO)
It's hard to tell what's wrong since you didn't show how you create your theme and from where you call your Text composable, but the minimum you need for colors based on system theme to work should look something like this:
Copy code
@Composable fun AppContent() {
  val isDarkTheme = isSystemInDarkTheme()
  val colors = if (isDarkTheme) darkColors() else lightColors()

  MaterialTheme(colors = colors) {
    // here, colors from MaterialTheme.colors will respect the system theme
    // you can either use them directly:
    Text(text = "Text", color = MaterialTheme.colors.onSurface)
    // or wrap your text in Surface, Scaffold or other Material widget
    // those widgets set LocalContentColor which is the default color for Text widget
    Surface { Text(text = "Text") }