Fixed switch settings item. Now it gives you new value on change instead of current value.

This commit is contained in:
Sad Ellie 2022-07-20 22:28:28 +03:00
parent 183c5d47a6
commit 19378fc7fc
3 changed files with 9 additions and 8 deletions

View File

@ -122,7 +122,7 @@ fun SettingsScreen(
stringResource(R.string.send_usage_statistics), stringResource(R.string.send_usage_statistics),
stringResource(R.string.send_usage_statistics_support), stringResource(R.string.send_usage_statistics_support),
mainViewModel.enableAnalytics mainViewModel.enableAnalytics
) { mainViewModel.updateEnableAnalytics(!it) } ) { mainViewModel.updateEnableAnalytics(it) }
} }
// THIRD PARTY // THIRD PARTY

View File

@ -119,7 +119,8 @@ fun SettingsListItem(
* @param label Main text. * @param label Main text.
* @param supportText Text that is located below label. * @param supportText Text that is located below label.
* @param switchState Current switch state. * @param switchState Current switch state.
* @param onSwitchChange Action to perform when user clicks on this component or just switch. * @param onSwitchChange Action to perform when user clicks on this component or just switch. Gives
* you new value.
*/ */
@Composable @Composable
fun SettingsListItem( fun SettingsListItem(
@ -127,8 +128,8 @@ fun SettingsListItem(
supportText: String? = null, supportText: String? = null,
switchState: Boolean, switchState: Boolean,
onSwitchChange: (Boolean) -> Unit onSwitchChange: (Boolean) -> Unit
) = BasicSettingsListItem(label, supportText, { onSwitchChange(switchState) }) { ) = BasicSettingsListItem(label, supportText, { onSwitchChange(!switchState) }) {
Switch(checked = switchState, onCheckedChange = { onSwitchChange(!it) }) Switch(checked = switchState, onCheckedChange = { onSwitchChange(it) })
} }
/** /**

View File

@ -61,8 +61,8 @@ fun ThemesScreen(
supportText = stringResource(R.string.enable_dynamic_colors_support), supportText = stringResource(R.string.enable_dynamic_colors_support),
switchState = themmoController.isDynamicThemeEnabled, switchState = themmoController.isDynamicThemeEnabled,
onSwitchChange = { onSwitchChange = {
themmoController.enableDynamicTheme(!it) themmoController.enableDynamicTheme(it)
viewModel.updateDynamicTheme(!it) viewModel.updateDynamicTheme(it)
} }
) )
} }
@ -78,8 +78,8 @@ fun ThemesScreen(
supportText = stringResource(R.string.force_amoled_mode_support), supportText = stringResource(R.string.force_amoled_mode_support),
switchState = themmoController.isAmoledThemeEnabled, switchState = themmoController.isAmoledThemeEnabled,
onSwitchChange = { onSwitchChange = {
themmoController.enableAmoledTheme(!it) themmoController.enableAmoledTheme(it)
viewModel.updateAmoledTheme(!it) viewModel.updateAmoledTheme(it)
} }
) )
} }