diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/ColorSchemePickerListItem.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/ColorSchemePickerListItem.kt index 03549b3..2587400 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/ColorSchemePickerListItem.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/ColorSchemePickerListItem.kt @@ -17,6 +17,7 @@ package org.nsh07.pomodoro.ui.settingsScreen.components +import android.os.Build import androidx.compose.animation.AnimatedContent import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement @@ -28,6 +29,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.CornerSize +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -38,6 +41,7 @@ import androidx.compose.material3.Switch import androidx.compose.material3.SwitchDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color @@ -65,6 +69,7 @@ fun ColorSchemePickerListItem( Color(0xff9fd75c), Color(0xffc1d02d), Color(0xfffabd00), Color(0xffffb86e), Color.White ) + val zeroCorner = remember { CornerSize(0) } Column( modifier @@ -76,45 +81,48 @@ fun ColorSchemePickerListItem( } ) ) { - ListItem( - leadingContent = { - Icon( - painterResource(R.drawable.colors), - null - ) - }, - headlineContent = { Text("Dynamic color") }, - supportingContent = { Text("Adapt theme colors from your wallpaper") }, - trailingContent = { - val checked = color == colorSchemes.last() - Switch( - checked = checked, - onCheckedChange = { - if (it) onColorChange(colorSchemes.last()) - else onColorChange(colorSchemes.first()) - }, - thumbContent = { - if (checked) { - Icon( - painter = painterResource(R.drawable.check), - contentDescription = null, - modifier = Modifier.size(SwitchDefaults.IconSize), - ) - } else { - Icon( - painter = painterResource(R.drawable.clear), - contentDescription = null, - modifier = Modifier.size(SwitchDefaults.IconSize), - ) - } - }, - colors = switchColors - ) - }, - colors = listItemColors, - modifier = Modifier.clip(middleListItemShape) - ) - Spacer(Modifier.height(2.dp)) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + ListItem( + leadingContent = { + Icon( + painterResource(R.drawable.colors), + null + ) + }, + headlineContent = { Text(stringResource(R.string.dynamic_color)) }, + supportingContent = { Text(stringResource(R.string.dynamic_color_desc)) }, + trailingContent = { + val checked = color == colorSchemes.last() + Switch( + checked = checked, + onCheckedChange = { + if (it) onColorChange(colorSchemes.last()) + else onColorChange(colorSchemes.first()) + }, + thumbContent = { + if (checked) { + Icon( + painter = painterResource(R.drawable.check), + contentDescription = null, + modifier = Modifier.size(SwitchDefaults.IconSize), + ) + } else { + Icon( + painter = painterResource(R.drawable.clear), + contentDescription = null, + modifier = Modifier.size(SwitchDefaults.IconSize), + ) + } + }, + colors = switchColors + ) + }, + colors = listItemColors, + modifier = Modifier.clip(middleListItemShape) + ) + Spacer(Modifier.height(2.dp)) + } + ListItem( leadingContent = { Icon( @@ -131,7 +139,14 @@ fun ColorSchemePickerListItem( ) }, colors = listItemColors, - modifier = Modifier.clip(middleListItemShape) + modifier = Modifier.clip( + RoundedCornerShape( + topStart = middleListItemShape.topStart, + topEnd = middleListItemShape.topEnd, + zeroCorner, + zeroCorner + ) + ) ) Column( diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AppearanceSettings.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AppearanceSettings.kt index eb55fb8..e4f44bf 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AppearanceSettings.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AppearanceSettings.kt @@ -56,6 +56,7 @@ import org.nsh07.pomodoro.ui.theme.CustomColors.switchColors import org.nsh07.pomodoro.ui.theme.CustomColors.topBarColors import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.bottomListItemShape import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.middleListItemShape +import org.nsh07.pomodoro.ui.theme.TomatoTheme import org.nsh07.pomodoro.utils.toColor @OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class) @@ -100,24 +101,24 @@ fun AppearanceSettings( item { Spacer(Modifier.height(14.dp)) } - item { - ColorSchemePickerListItem( - color = preferencesState.colorScheme.toColor(), - items = 3, - index = 0, - onColorChange = onColorSchemeChange - ) - } item { ThemePickerListItem( theme = preferencesState.theme, onThemeChange = onThemeChange, items = 3, - index = 1, + index = 0, modifier = Modifier .clip(middleListItemShape) ) } + item { + ColorSchemePickerListItem( + color = preferencesState.colorScheme.toColor(), + items = 3, + index = 1, + onColorChange = onColorSchemeChange + ) + } item { val item = SettingsSwitchItem( checked = preferencesState.blackTheme, @@ -168,11 +169,13 @@ fun AppearanceSettings( @Composable fun AppearanceSettingsPreview() { val preferencesState = PreferencesState() - AppearanceSettings( - preferencesState = preferencesState, - onBlackThemeChange = {}, - onThemeChange = {}, - onColorSchemeChange = {}, - onBack = {} - ) + TomatoTheme { + AppearanceSettings( + preferencesState = preferencesState, + onBlackThemeChange = {}, + onThemeChange = {}, + onColorSchemeChange = {}, + onBack = {} + ) + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a71a0b4..d03d14c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -83,4 +83,6 @@ Turn on DND when running a Focus timer Tomato+ Get Tomato+ + Dynamic color + Adapt theme colors from your wallpaper \ No newline at end of file