Issue with Dynamic Theme Change Not Reflecting in Jetpack Compose Elements
I'm working on a personal project and I'm sure I'm missing something obvious here, but I'm working on a project and hit a roadblock..... I'm facing an issue where the dynamic theme change in my Jetpack Compose app doesn't reflect on certain UI elements... I have implemented a simple theme switcher that toggles between light and dark modes, but while the main background changes, some elements remain in their original state. Here's the relevant code snippet for the theme management: ```kotlin @Composable fun MyApp() { val isDarkTheme = remember { mutableStateOf(false) } MaterialTheme( colors = if (isDarkTheme.value) DarkColors else LightColors ) { Column(modifier = Modifier.fillMaxSize()) { Button(onClick = { isDarkTheme.value = !isDarkTheme.value }) { Text(text = "Switch Theme") } // Some other UI elements MyCustomComposable() } } } ``` The `MyCustomComposable` function is defined as follows: ```kotlin @Composable fun MyCustomComposable() { Text(text = "Hello, World!", color = MaterialTheme.colors.onSurface) } ``` Despite the theme toggling correctly, the text color seems to remain unchanged on some devices, while it reflects correctly on others. I verified that I am not hardcoding any colors in `MyCustomComposable`. I have also tried to wrap the `MyCustomComposable` within a `LaunchedEffect` to trigger a recomposition, but that didn't resolve the issue: ```kotlin LaunchedEffect(isDarkTheme.value) { // Attempt to force recomposition } ``` I am targeting Android 14 and using Compose version 1.4.0. I suspect it might have something to do with the recomposition of the `Text` element not picking up the new theme colors. Could there be an issue with state management or recomposition that I'm missing? Any insights would be appreciated! This is part of a larger API I'm building. Has anyone else encountered this? My development environment is macOS. Has anyone else encountered this? What's the best practice here? This issue appeared after updating to Kotlin LTS. Thanks for any help you can provide! This is for a web app running on Ubuntu 22.04. Any ideas how to fix this?