Jakub Ledwon
03/22/2021, 10:36 PMRadioButtons
(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 commentJakub Ledwon
03/22/2021, 10:38 PMval 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)
)
}
}
}
}
}
Jakub Ledwon
03/22/2021, 10:39 PMJakub Ledwon
03/22/2021, 10:39 PMLouis Pullen-Freilich [G]
03/22/2021, 10:40 PMJakub Ledwon
03/22/2021, 10:41 PMJakub Ledwon
03/22/2021, 10:41 PM