From bb336ea973348315bb0a660f0a70b46c9bffdb49 Mon Sep 17 00:00:00 2001 From: Suphon Thanakornpakapong Date: Tue, 19 Oct 2021 20:49:01 +0700 Subject: [PATCH] Show color name as description --- .../ui/preferences/components/ColorPreference.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/ColorPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/ColorPreference.kt index f7aec14b6b..b03b36af51 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/ColorPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/ColorPreference.kt @@ -45,6 +45,13 @@ fun ColorPreference( PreferenceTemplate( title = { Text(text = label) }, + description = { + val selectedOption = (options + customOptions) + .firstOrNull { it.value == selectedColor } + if (selectedOption != null) { + Text(text = selectedOption.label()) + } + }, modifier = Modifier .clickable { coroutineScope.launch { bottomSheetState.show() } }, endWidget = { @@ -54,8 +61,7 @@ fun ColorPreference( .clip(CircleShape) .background(previewColor) ) - }, - verticalPadding = 12.dp + } ) BottomSheet(sheetState = bottomSheetState) { @@ -84,6 +90,7 @@ fun ColorPreference( options.mapIndexed { index, option -> key(option) { ModeRow( + title = option.label(), onClick = { selectedColor = option.value }, selected = selectedColor == option.value, option = option, @@ -94,6 +101,7 @@ fun ColorPreference( val customColorOption = customOptions.firstOrNull { it.value == selectedColor } val lastCustomColorOption = customOptions.first { it.value == lastCustomColor } ModeRow( + title = stringResource(id = R.string.custom), onClick = { selectedColor = lastCustomColor }, selected = customColorOption != null, option = lastCustomColorOption, @@ -198,6 +206,7 @@ fun TopBar( @Composable @ExperimentalAnimationApi fun ModeRow( + title: String, onClick: () -> Unit, onEditClick: (() -> Unit)? = null, option: ColorPreferenceOption, @@ -205,7 +214,7 @@ fun ModeRow( selected: Boolean ) { PreferenceTemplate( - title = { Text(text = option.label()) }, + title = { Text(text = title) }, modifier = Modifier .clickable(onClick = onClick), startWidget = {