1717package com.google.samples.apps.nowinandroid.feature.settings
1818
1919import android.content.Intent
20+ import androidx.compose.animation.AnimatedVisibility
2021import androidx.compose.foundation.clickable
2122import androidx.compose.foundation.layout.Arrangement
2223import androidx.compose.foundation.layout.Column
24+ import androidx.compose.foundation.layout.ColumnScope
2325import androidx.compose.foundation.layout.ExperimentalLayoutApi
2426import androidx.compose.foundation.layout.FlowRow
2527import androidx.compose.foundation.layout.Row
@@ -149,8 +151,9 @@ fun SettingsDialog(
149151 )
150152}
151153
154+ // [ColumnScope] is used for using the [ColumnScope.AnimatedVisibility] extension overload composable.
152155@Composable
153- private fun SettingsPanel (
156+ private fun ColumnScope. SettingsPanel (
154157 settings : UserEditableSettings ,
155158 supportDynamicColor : Boolean ,
156159 onChangeThemeBrand : (themeBrand: ThemeBrand ) -> Unit ,
@@ -170,19 +173,21 @@ private fun SettingsPanel(
170173 onClick = { onChangeThemeBrand(ANDROID ) },
171174 )
172175 }
173- if (settings.brand == DEFAULT && supportDynamicColor) {
174- SettingsDialogSectionTitle (text = stringResource(R .string.dynamic_color_preference))
175- Column (Modifier .selectableGroup()) {
176- SettingsDialogThemeChooserRow (
177- text = stringResource(string.dynamic_color_yes),
178- selected = settings.useDynamicColor,
179- onClick = { onChangeDynamicColorPreference(true ) },
180- )
181- SettingsDialogThemeChooserRow (
182- text = stringResource(string.dynamic_color_no),
183- selected = ! settings.useDynamicColor,
184- onClick = { onChangeDynamicColorPreference(false ) },
185- )
176+ AnimatedVisibility (visible = settings.brand == DEFAULT && supportDynamicColor) {
177+ Column {
178+ SettingsDialogSectionTitle (text = stringResource(R .string.dynamic_color_preference))
179+ Column (Modifier .selectableGroup()) {
180+ SettingsDialogThemeChooserRow (
181+ text = stringResource(string.dynamic_color_yes),
182+ selected = settings.useDynamicColor,
183+ onClick = { onChangeDynamicColorPreference(true ) },
184+ )
185+ SettingsDialogThemeChooserRow (
186+ text = stringResource(string.dynamic_color_no),
187+ selected = ! settings.useDynamicColor,
188+ onClick = { onChangeDynamicColorPreference(false ) },
189+ )
190+ }
186191 }
187192 }
188193 SettingsDialogSectionTitle (text = stringResource(R .string.dark_mode_preference))
0 commit comments