Skip to content

Commit 6c18b25

Browse files
committed
Replace if condition with AnimatedVisibility component
1 parent 6d87dc6 commit 6c18b25

File tree

1 file changed

+18
-14
lines changed
  • feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings

1 file changed

+18
-14
lines changed

feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package com.google.samples.apps.nowinandroid.feature.settings
1818

1919
import android.content.Intent
2020
import android.net.Uri
21+
import androidx.compose.animation.AnimatedVisibility
2122
import androidx.compose.foundation.clickable
2223
import androidx.compose.foundation.layout.Column
24+
import androidx.compose.foundation.layout.ColumnScope
2325
import androidx.compose.foundation.layout.Row
2426
import androidx.compose.foundation.layout.Spacer
2527
import androidx.compose.foundation.layout.fillMaxWidth
@@ -149,7 +151,7 @@ fun SettingsDialog(
149151
}
150152

151153
@Composable
152-
private fun SettingsPanel(
154+
private fun ColumnScope.SettingsPanel(
153155
settings: UserEditableSettings,
154156
supportDynamicColor: Boolean,
155157
onChangeThemeBrand: (themeBrand: ThemeBrand) -> Unit,
@@ -169,19 +171,21 @@ private fun SettingsPanel(
169171
onClick = { onChangeThemeBrand(ANDROID) },
170172
)
171173
}
172-
if (settings.brand == DEFAULT && supportDynamicColor) {
173-
SettingsDialogSectionTitle(text = stringResource(R.string.dynamic_color_preference))
174-
Column(Modifier.selectableGroup()) {
175-
SettingsDialogThemeChooserRow(
176-
text = stringResource(string.dynamic_color_yes),
177-
selected = settings.useDynamicColor,
178-
onClick = { onChangeDynamicColorPreference(true) },
179-
)
180-
SettingsDialogThemeChooserRow(
181-
text = stringResource(string.dynamic_color_no),
182-
selected = !settings.useDynamicColor,
183-
onClick = { onChangeDynamicColorPreference(false) },
184-
)
174+
AnimatedVisibility(visible = settings.brand == DEFAULT && supportDynamicColor) {
175+
Column {
176+
SettingsDialogSectionTitle(text = stringResource(R.string.dynamic_color_preference))
177+
Column(Modifier.selectableGroup()) {
178+
SettingsDialogThemeChooserRow(
179+
text = stringResource(string.dynamic_color_yes),
180+
selected = settings.useDynamicColor,
181+
onClick = { onChangeDynamicColorPreference(true) },
182+
)
183+
SettingsDialogThemeChooserRow(
184+
text = stringResource(string.dynamic_color_no),
185+
selected = !settings.useDynamicColor,
186+
onClick = { onChangeDynamicColorPreference(false) },
187+
)
188+
}
185189
}
186190
}
187191
SettingsDialogSectionTitle(text = stringResource(R.string.dark_mode_preference))

0 commit comments

Comments
 (0)