Skip to content

Commit d051b60

Browse files
authored
Merge pull request #87 from nsh07/settings-redesign
Settings redesign
2 parents d646615 + 2644974 commit d051b60

22 files changed

+1297
-507
lines changed

app/src/main/java/org/nsh07/pomodoro/MainActivity.kt

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright (c) 2025 Nishant Mishra
3+
*
4+
* This file is part of Tomato - a minimalist pomodoro timer for Android.
5+
*
6+
* Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU
7+
* General Public License as published by the Free Software Foundation, either version 3 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11+
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12+
* Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with Tomato.
15+
* If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
118
package org.nsh07.pomodoro
219

320
import android.os.Bundle
@@ -11,8 +28,6 @@ import androidx.compose.runtime.LaunchedEffect
1128
import androidx.compose.runtime.getValue
1229
import androidx.lifecycle.compose.collectAsStateWithLifecycle
1330
import org.nsh07.pomodoro.ui.AppScreen
14-
import org.nsh07.pomodoro.ui.NavItem
15-
import org.nsh07.pomodoro.ui.Screen
1631
import org.nsh07.pomodoro.ui.settingsScreen.viewModel.SettingsViewModel
1732
import org.nsh07.pomodoro.ui.theme.TomatoTheme
1833
import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerViewModel
@@ -71,27 +86,4 @@ class MainActivity : ComponentActivity() {
7186
// Increase the timer loop frequency again when visible to make the progress smoother
7287
appContainer.appTimerRepository.timerFrequency = 10f
7388
}
74-
75-
companion object {
76-
val screens = listOf(
77-
NavItem(
78-
Screen.Timer,
79-
R.drawable.timer_outlined,
80-
R.drawable.timer_filled,
81-
R.string.timer
82-
),
83-
NavItem(
84-
Screen.Stats,
85-
R.drawable.monitoring,
86-
R.drawable.monitoring_filled,
87-
R.string.stats
88-
),
89-
NavItem(
90-
Screen.Settings,
91-
R.drawable.settings,
92-
R.drawable.settings_filled,
93-
R.string.settings
94-
)
95-
)
96-
}
9789
}

app/src/main/java/org/nsh07/pomodoro/ui/AppScreen.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
/*
22
* Copyright (c) 2025 Nishant Mishra
33
*
4-
* You should have received a copy of the GNU General Public License
5-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
4+
* This file is part of Tomato - a minimalist pomodoro timer for Android.
5+
*
6+
* Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU
7+
* General Public License as published by the Free Software Foundation, either version 3 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11+
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12+
* Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with Tomato.
15+
* If not, see <https://www.gnu.org/licenses/>.
616
*/
717

818
package org.nsh07.pomodoro.ui
@@ -45,7 +55,6 @@ import androidx.navigation3.runtime.entryProvider
4555
import androidx.navigation3.runtime.rememberNavBackStack
4656
import androidx.navigation3.ui.NavDisplay
4757
import androidx.window.core.layout.WindowSizeClass
48-
import org.nsh07.pomodoro.MainActivity.Companion.screens
4958
import org.nsh07.pomodoro.service.TimerService
5059
import org.nsh07.pomodoro.ui.settingsScreen.SettingsScreenRoot
5160
import org.nsh07.pomodoro.ui.statsScreen.StatsScreenRoot
@@ -100,7 +109,7 @@ fun AppScreen(
100109
if (wide) ShortNavigationBarArrangement.Centered
101110
else ShortNavigationBarArrangement.EqualWeight
102111
) {
103-
screens.forEach {
112+
mainScreens.forEach {
104113
val selected = backStack.last() == it.route
105114
ShortNavigationBarItem(
106115
selected = selected,
@@ -131,7 +140,7 @@ fun AppScreen(
131140
SharedTransitionLayout {
132141
NavDisplay(
133142
backStack = backStack,
134-
onBack = { backStack.removeLastOrNull() },
143+
onBack = backStack::removeLastOrNull,
135144
transitionSpec = {
136145
ContentTransform(
137146
fadeIn(motionScheme.defaultEffectsSpec()),
@@ -213,7 +222,7 @@ fun AppScreen(
213222
)
214223
}
215224

216-
entry<Screen.Settings> {
225+
entry<Screen.Settings.Main> {
217226
SettingsScreenRoot(
218227
modifier = modifier.padding(
219228
start = contentPadding.calculateStartPadding(layoutDirection),
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2025 Nishant Mishra
3+
*
4+
* This file is part of Tomato - a minimalist pomodoro timer for Android.
5+
*
6+
* Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU
7+
* General Public License as published by the Free Software Foundation, either version 3 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11+
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12+
* Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with Tomato.
15+
* If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.nsh07.pomodoro.ui
19+
20+
import org.nsh07.pomodoro.R
21+
22+
val mainScreens = listOf(
23+
NavItem(
24+
Screen.Timer,
25+
R.drawable.timer_outlined,
26+
R.drawable.timer_filled,
27+
R.string.timer
28+
),
29+
NavItem(
30+
Screen.Stats,
31+
R.drawable.monitoring,
32+
R.drawable.monitoring_filled,
33+
R.string.stats
34+
),
35+
NavItem(
36+
Screen.Settings.Main,
37+
R.drawable.settings,
38+
R.drawable.settings_filled,
39+
R.string.settings
40+
)
41+
)
42+
43+
val settingsScreens = listOf(
44+
SettingsNavItem(
45+
Screen.Settings.Timer,
46+
R.drawable.timer_filled,
47+
R.string.timer,
48+
listOf(R.string.durations, R.string.session_length, R.string.always_on_display)
49+
),
50+
SettingsNavItem(
51+
Screen.Settings.Alarm,
52+
R.drawable.alarm,
53+
R.string.alarm,
54+
listOf(R.string.alarm_sound, R.string.alarm, R.string.vibrate)
55+
),
56+
SettingsNavItem(
57+
Screen.Settings.Appearance,
58+
R.drawable.palette,
59+
R.string.appearance,
60+
listOf(R.string.color_scheme, R.string.theme, R.string.black_theme)
61+
)
62+
)

app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright (c) 2025 Nishant Mishra
3+
*
4+
* This file is part of Tomato - a minimalist pomodoro timer for Android.
5+
*
6+
* Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU
7+
* General Public License as published by the Free Software Foundation, either version 3 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11+
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12+
* Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with Tomato.
15+
* If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
118
package org.nsh07.pomodoro.ui
219

320
import androidx.annotation.DrawableRes
@@ -13,7 +30,19 @@ sealed class Screen : NavKey {
1330
object AOD : Screen()
1431

1532
@Serializable
16-
object Settings : Screen()
33+
sealed class Settings : Screen() {
34+
@Serializable
35+
object Main : Settings()
36+
37+
@Serializable
38+
object Alarm : Settings()
39+
40+
@Serializable
41+
object Appearance : Settings()
42+
43+
@Serializable
44+
object Timer : Settings()
45+
}
1746

1847
@Serializable
1948
object Stats : Screen()
@@ -24,4 +53,11 @@ data class NavItem(
2453
@param:DrawableRes val unselectedIcon: Int,
2554
@param:DrawableRes val selectedIcon: Int,
2655
@param:StringRes val label: Int
27-
)
56+
)
57+
58+
data class SettingsNavItem(
59+
val route: Screen.Settings,
60+
@param:DrawableRes val icon: Int,
61+
@param:StringRes val label: Int,
62+
val innerSettings: List<Int>
63+
)

app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/MinutesTransformation.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)