From 0b5066fa1883c68a92db9b95a9b5be6366b6bdc8 Mon Sep 17 00:00:00 2001 From: Sad Ellie Date: Tue, 23 May 2023 23:49:54 +0300 Subject: [PATCH] Inline theming modes --- .../feature/settings/themes/ThemesScreen.kt | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/themes/ThemesScreen.kt b/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/themes/ThemesScreen.kt index 6bf6a234..22cb2c82 100644 --- a/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/themes/ThemesScreen.kt +++ b/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/themes/ThemesScreen.kt @@ -41,8 +41,6 @@ import androidx.compose.material3.Icon import androidx.compose.material3.ListItem import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -134,16 +132,6 @@ private fun ThemesScreen( monetMode: MonetMode, onMonetModeChange: (MonetMode) -> Unit ) { - val themingModes by remember { - mutableStateOf( - mapOf( - ThemingMode.AUTO to (R.string.auto_label to Icons.Outlined.HdrAuto), - ThemingMode.FORCE_LIGHT to (R.string.force_light_mode to Icons.Outlined.LightMode), - ThemingMode.FORCE_DARK to (R.string.force_dark_mode to Icons.Outlined.DarkMode) - ) - ) - } - UnittoScreenWithLargeTopBar( title = stringResource(R.string.theme_setting), navigationIcon = { NavigateUpButton(navigateUpAction) } @@ -170,15 +158,24 @@ private fun ThemesScreen( .wrapContentWidth() ) { SegmentedButtonsRow(modifier = Modifier.padding(56.dp, 8.dp, 24.dp, 2.dp)) { - themingModes.forEach { (mode, visuals) -> - val (label, icon) = visuals - SegmentedButton( - label = stringResource(label), - onClick = { onThemeChange(mode) }, - selected = mode == currentThemingMode, - icon = icon - ) - } + SegmentedButton( + label = stringResource(R.string.auto_label), + onClick = { onThemeChange(ThemingMode.AUTO) }, + selected = ThemingMode.AUTO == currentThemingMode, + icon = Icons.Outlined.HdrAuto + ) + SegmentedButton( + label = stringResource(R.string.force_light_mode), + onClick = { onThemeChange(ThemingMode.FORCE_LIGHT) }, + selected = ThemingMode.FORCE_LIGHT == currentThemingMode, + icon = Icons.Outlined.LightMode + ) + SegmentedButton( + label = stringResource(R.string.force_dark_mode), + onClick = { onThemeChange(ThemingMode.FORCE_DARK) }, + selected = ThemingMode.FORCE_DARK == currentThemingMode, + icon = Icons.Outlined.DarkMode + ) } } }