Thread
#compose
    j

    Jakub Ledwon

    1 year ago
    I have an app which allows users to pick color them they want. In settings screen I have three rows of
    RadioButtons
    (to change between themese) with
    Boxes
    (to present the main color of theme). Everything is managed by a viewModel . In compose beta01 everythings works fine, but in beta02 after changing selected theme, other theme's color changes as well. Is there some sort of bug or am I doing somethings wrong? I prepared a simplified code snippet with screens in comment
    val appColorTheme = settingsViewModel.appColorTheme.collectAsState()
    
    LazyColumn() {
                val colorThemeRows = settingsViewModel.themes.chunked(3) //themes is just a list of themes
                items(colorThemeRows) { row ->
                    Row(
                        horizontalArrangement = Arrangement.SpaceEvenly,
                        modifier = Modifier.padding(vertical = 16.dp).fillMaxWidth()
                    ) {
                        row.forEach { theme ->
                            Row(verticalAlignment = Alignment.CenterVertically) {
                                RadioButton(
                                    selected = theme == appColorTheme.value,
                                    onClick = { settingsViewModel.updateAppColorTheme(theme) })
                                Box(
                                    modifier = Modifier
                                        .height(64.dp)
                                        .width(64.dp)
                                        .padding(start = 8.dp)
                                        .clickable { settingsViewModel.updateAppColorTheme(theme) }
                                        .background(if (isDarkMode) theme.value.colorTheme.darkColors.primary else theme.value.colorTheme.lightColors.primary)
                                )
                            }
                        }
    
                    }
                }
    }
    Initial state:
    After changing color in beta02:
    l

    Louis Pullen-Freilich [G]

    1 year ago
    Yep this is a known issue, should be fixed in beta03
    j

    Jakub Ledwon

    1 year ago
    After changing color in beta01:
    Thanks for info ^ ^