I would like to implement a switch for dark/light ...
# compose
l
I would like to implement a switch for dark/light mode/theme. I know what I have to do to achieve this but my solution expects to bubble the event for mutating the state all the way up and I'm looking for alternative solutions. So my solution in a nutshell:
Copy code
setContent {
  var isDarkTheme by mutableStateOf(false)
  MyTheme(isDarkTheme = isDarkTheme) {
    EntryPoint(defaultRoute = Route.Test) { isDarkTheme = true }
  }
}

@Composable
fun EntryPoint(defaultRoute: Route, onChangeTheme: () -> Unit) {...}
CompositionLocalProvider is no option because it is read only, true? I could also define a public top-level state variable:
Copy code
e.g. in MainActivity.kt file:

var isDarkTheme by mutableStateOf(false)
which is accessible throughou the app module. Actually a no-brainer. Any other ideas, maybe more local?