From 6381fa3da5b75e396ca806014809721a729aa59b Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Mon, 7 Jul 2025 17:52:33 +0530 Subject: [PATCH] Refresh settings screen colors, add option to change number of sessions --- .../ui/settingsScreen/MinuteInputField.kt | 2 +- .../ui/settingsScreen/SettingsScreen.kt | 77 +++++++++++++------ .../pomodoro/ui/viewModel/UiViewModel.kt | 4 +- app/src/main/res/drawable/clocks.xml | 13 ++++ 4 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 app/src/main/res/drawable/clocks.xml diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/MinuteInputField.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/MinuteInputField.kt index a84ce48..81a8c21 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/MinuteInputField.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/MinuteInputField.kt @@ -59,7 +59,7 @@ fun MinuteInputField( .background( animateColorAsState( if (state.text.isNotEmpty()) - colorScheme.surfaceContainer + colorScheme.surface else colorScheme.errorContainer, motionScheme.defaultEffectsSpec() ).value, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsScreen.kt index 976e323..beea291 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsScreen.kt @@ -1,5 +1,6 @@ package org.nsh07.pomodoro.ui.settingsScreen +import androidx.compose.foundation.background import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -7,6 +8,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn @@ -16,22 +18,30 @@ import androidx.compose.foundation.text.input.TextFieldState import androidx.compose.foundation.text.input.rememberTextFieldState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi +import androidx.compose.material3.Icon +import androidx.compose.material3.ListItem import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme.colorScheme +import androidx.compose.material3.MaterialTheme.shapes import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.Slider import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.rememberSliderState import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.tooling.preview.Devices import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import org.nsh07.pomodoro.R import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTitle import org.nsh07.pomodoro.ui.theme.TomatoTheme @@ -53,6 +63,7 @@ fun SettingsScreen( } val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior() + val sessionsSliderState = rememberSliderState(value = 3f, steps = 3, valueRange = 1f..5f) Column(modifier.nestedScroll(scrollBehavior.nestedScrollConnection)) { TopAppBar( @@ -67,6 +78,7 @@ fun SettingsScreen( ) }, subtitle = {}, + colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceContainer), titleHorizontalAlignment = Alignment.CenterHorizontally, scrollBehavior = scrollBehavior ) @@ -74,17 +86,12 @@ fun SettingsScreen( LazyColumn( verticalArrangement = Arrangement.spacedBy(2.dp), modifier = Modifier + .background(colorScheme.surfaceContainer) .fillMaxSize() .padding(horizontal = 16.dp) ) { item { - Text( - "Timer", - style = typography.titleSmall, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 8.dp, vertical = 14.dp) - ) + Spacer(Modifier.height(12.dp)) } item { Row( @@ -97,6 +104,10 @@ fun SettingsScreen( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(2.dp) ) { + Text( + "Focus", + style = typography.titleSmallEmphasized + ) MinuteInputField( state = focusTimeInputFieldState, shape = RoundedCornerShape( @@ -107,35 +118,31 @@ fun SettingsScreen( ), imeAction = ImeAction.Next ) - Text( - "Focus", - style = typography.titleSmallEmphasized, - color = colorScheme.onPrimaryContainer, - modifier = Modifier.padding(horizontal = 8.dp) - ) } Spacer(Modifier.width(2.dp)) Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(2.dp) ) { + Text( + "Short break", + style = typography.titleSmallEmphasized + ) MinuteInputField( state = shortBreakTimeInputFieldState, shape = RoundedCornerShape(4.dp), imeAction = ImeAction.Next ) - Text( - "Short break", - style = typography.titleSmallEmphasized, - color = colorScheme.onTertiaryContainer, - modifier = Modifier.padding(horizontal = 8.dp) - ) } Spacer(Modifier.width(2.dp)) Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(2.dp) ) { + Text( + "Long break", + style = typography.titleSmallEmphasized + ) MinuteInputField( state = longBreakTimeInputFieldState, shape = RoundedCornerShape( @@ -146,15 +153,35 @@ fun SettingsScreen( ), imeAction = ImeAction.Done ) - Text( - "Long break", - style = typography.titleSmallEmphasized, - color = colorScheme.onTertiaryContainer, - modifier = Modifier.padding(horizontal = 8.dp) - ) } } } + item { + Spacer(Modifier.height(12.dp)) + } + item { + ListItem( + leadingContent = { + Icon( + painterResource(R.drawable.clocks), + null + ) + }, + headlineContent = { + Text("Sessions") + }, + supportingContent = { + Column { + Text("${sessionsSliderState.value.toInt()} sessions before a long break") + Slider( + state = sessionsSliderState, + modifier = Modifier.padding(vertical = 4.dp) + ) + } + }, + modifier = Modifier.clip(shapes.large) + ) + } } } } diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/viewModel/UiViewModel.kt b/app/src/main/java/org/nsh07/pomodoro/ui/viewModel/UiViewModel.kt index 7988c89..5574d86 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/viewModel/UiViewModel.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/viewModel/UiViewModel.kt @@ -213,7 +213,7 @@ class UiViewModel( .debounce(500) .collect { if (it.isNotEmpty()) { - focusTime = preferenceRepository.saveIntPreference( + shortBreakTime = preferenceRepository.saveIntPreference( "short_break_time", it.toString().toInt() * 60 * 1000 ) @@ -225,7 +225,7 @@ class UiViewModel( .debounce(500) .collect { if (it.isNotEmpty()) { - focusTime = preferenceRepository.saveIntPreference( + longBreakTime = preferenceRepository.saveIntPreference( "long_break_time", it.toString().toInt() * 60 * 1000 ) diff --git a/app/src/main/res/drawable/clocks.xml b/app/src/main/res/drawable/clocks.xml new file mode 100644 index 0000000..f5ddad5 --- /dev/null +++ b/app/src/main/res/drawable/clocks.xml @@ -0,0 +1,13 @@ + + + + +