From 9efc4f646730cf33b40b0a9a8d52c2a6c8f1e657 Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Mon, 1 Dec 2025 10:51:07 +0530 Subject: [PATCH] feat(ui): add about screen list item in settings, remove card Closes: #160 --- .../java/org/nsh07/pomodoro/ui/Navigation.kt | 6 +- .../main/java/org/nsh07/pomodoro/ui/Screen.kt | 3 + .../ui/settingsScreen/SettingsScreen.kt | 40 ++++-- .../ui/settingsScreen/components/AboutCard.kt | 123 ------------------ .../settingsScreen/components/PlusDivider.kt | 4 +- .../ui/settingsScreen/components/PlusPromo.kt | 79 +++++------ .../ui/settingsScreen/screens/AboutScreen.kt | 2 +- app/src/main/res/drawable/info.xml | 20 ++- app/src/main/res/values/strings.xml | 1 + 9 files changed, 94 insertions(+), 184 deletions(-) delete mode 100644 app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutCard.kt diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/Navigation.kt b/app/src/main/java/org/nsh07/pomodoro/ui/Navigation.kt index 2641e7a..f7d7ad0 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/Navigation.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/Navigation.kt @@ -45,18 +45,18 @@ val settingsScreens = listOf( Screen.Settings.Timer, R.drawable.timer_filled, R.string.timer, - listOf(R.string.durations, R.string.session_length, R.string.always_on_display) + listOf(R.string.durations, R.string.dnd, R.string.always_on_display) ), SettingsNavItem( Screen.Settings.Alarm, R.drawable.alarm, R.string.alarm, - listOf(R.string.alarm_sound, R.string.alarm, R.string.vibrate) + listOf(R.string.alarm_sound, R.string.sound, R.string.vibrate) ), SettingsNavItem( Screen.Settings.Appearance, R.drawable.palette, R.string.appearance, - listOf(R.string.color_scheme, R.string.theme, R.string.black_theme) + listOf(R.string.theme, R.string.color_scheme, R.string.black_theme) ) ) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt index a37fe21..b7ef562 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt @@ -34,6 +34,9 @@ sealed class Screen : NavKey { @Serializable object Main : Settings() + @Serializable + object About : Settings() + @Serializable object Alarm : Settings() 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 e32b1c3..79dbda2 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 @@ -65,13 +65,14 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation3.runtime.entryProvider import androidx.navigation3.ui.NavDisplay +import org.nsh07.pomodoro.BuildConfig import org.nsh07.pomodoro.R import org.nsh07.pomodoro.ui.Screen import org.nsh07.pomodoro.ui.mergePaddingValues -import org.nsh07.pomodoro.ui.settingsScreen.components.AboutCard import org.nsh07.pomodoro.ui.settingsScreen.components.ClickableListItem import org.nsh07.pomodoro.ui.settingsScreen.components.LocaleBottomSheet import org.nsh07.pomodoro.ui.settingsScreen.components.PlusPromo +import org.nsh07.pomodoro.ui.settingsScreen.screens.AboutScreen import org.nsh07.pomodoro.ui.settingsScreen.screens.AlarmSettings import org.nsh07.pomodoro.ui.settingsScreen.screens.AppearanceSettings import org.nsh07.pomodoro.ui.settingsScreen.screens.TimerSettings @@ -216,22 +217,33 @@ private fun SettingsScreen( .fillMaxSize() .padding(horizontal = 16.dp) ) { - item { Spacer(Modifier.height(12.dp)) } + item { Spacer(Modifier.height(14.dp)) } - if (!isPlus) item { + item { PlusPromo(isPlus, setShowPaywall) - Spacer(Modifier.height(14.dp)) } - item { AboutCard(isPlus) } + item { + ClickableListItem( + leadingContent = { + Icon(painterResource(R.drawable.info), null) + }, + headlineContent = { + Text(stringResource(R.string.about)) + }, + supportingContent = { + Text(stringResource(R.string.app_name) + " ${BuildConfig.VERSION_NAME}") + }, + trailingContent = { + Icon(painterResource(R.drawable.arrow_forward_big), null) + }, + items = 2, + index = 1 + ) { backStack.add(Screen.Settings.About) } + } item { Spacer(Modifier.height(12.dp)) } - if (isPlus) item { - PlusPromo(isPlus, setShowPaywall) - Spacer(Modifier.height(14.dp)) - } - itemsIndexed(settingsScreens) { index, item -> ClickableListItem( leadingContent = { @@ -286,6 +298,14 @@ private fun SettingsScreen( } } + entry { + AboutScreen( + contentPadding = contentPadding, + isPlus = isPlus, + onBack = backStack::removeLastOrNull + ) + } + entry { AlarmSettings( settingsState = settingsState, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutCard.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutCard.kt deleted file mode 100644 index f734c67..0000000 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutCard.kt +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2025 Nishant Mishra - * - * This file is part of Tomato - a minimalist pomodoro timer for Android. - * - * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU - * General Public License as published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * You should have received a copy of the GNU General Public License along with Tomato. - * If not, see . - */ - -package org.nsh07.pomodoro.ui.settingsScreen.components - -import android.widget.Toast -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.FlowRow -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material3.Card -import androidx.compose.material3.CardDefaults -import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.IconButtonDefaults -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.MaterialTheme.colorScheme -import androidx.compose.material3.MaterialTheme.shapes -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalUriHandler -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp -import org.nsh07.pomodoro.BuildConfig -import org.nsh07.pomodoro.R -import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTopBar - -// Taken from https://github.com/shub39/Grit/blob/master/app/src/main/java/com/shub39/grit/core/presentation/settings/ui/component/AboutApp.kt -@OptIn(ExperimentalMaterial3ExpressiveApi::class) -@Composable -fun AboutCard( - isPlus: Boolean, - modifier: Modifier = Modifier -) { - val uriHandler = LocalUriHandler.current - val context = LocalContext.current - - Card( - modifier = modifier.fillMaxWidth(), - colors = CardDefaults.cardColors( - containerColor = colorScheme.primaryContainer, - contentColor = colorScheme.onPrimaryContainer - ), - shape = shapes.extraLarge - ) { - Row( - modifier = Modifier - .padding(16.dp) - .fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp) - ) { - Column { - Text( - if (!isPlus) stringResource(R.string.app_name) - else stringResource(R.string.app_name_plus), - style = MaterialTheme.typography.titleLarge, - fontFamily = robotoFlexTopBar - ) - Text(text = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})") - } - - Spacer(modifier = Modifier.weight(1f)) - - Row { - IconButton( - onClick = { - Toast.makeText(context, "Coming soon...", Toast.LENGTH_SHORT).show() - }, - shapes = IconButtonDefaults.shapes() - ) { - Icon( - painterResource(R.drawable.discord), - contentDescription = "Discord", - modifier = Modifier.size(24.dp) - ) - } - - IconButton( - onClick = { uriHandler.openUri("https://github.com/nsh07/Tomato") }, - shapes = IconButtonDefaults.shapes() - ) { - Icon( - painterResource(R.drawable.github), - contentDescription = "GitHub", - modifier = Modifier.size(24.dp) - ) - } - } - } - - FlowRow( - modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp), - horizontalArrangement = Arrangement.spacedBy(8.dp) - ) { -// TopButton(buttonColors) -// BottomButton(buttonColors) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusDivider.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusDivider.kt index 13cb270..6ba3c2c 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusDivider.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusDivider.kt @@ -32,7 +32,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import org.nsh07.pomodoro.R @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable @@ -49,7 +51,7 @@ fun PlusDivider( .background(colorScheme.surfaceContainer) .padding(horizontal = 8.dp) ) { - Text("Customize further with Tomato+", style = typography.titleSmall) + Text(stringResource(R.string.tomato_plus_desc), style = typography.titleSmall) } } } \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusPromo.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusPromo.kt index 6566e8b..f6e0b3f 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusPromo.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusPromo.kt @@ -17,27 +17,18 @@ package org.nsh07.pomodoro.ui.settingsScreen.components -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Icon +import androidx.compose.material3.ListItemDefaults import androidx.compose.material3.MaterialTheme.colorScheme -import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import org.nsh07.pomodoro.R -import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTopBar +import org.nsh07.pomodoro.ui.theme.CustomColors.listItemColors @Composable fun PlusPromo( @@ -45,38 +36,38 @@ fun PlusPromo( setShowPaywall: (Boolean) -> Unit, modifier: Modifier = Modifier ) { - val container = if (isPlus) colorScheme.surfaceBright else colorScheme.primary - val onContainer = if (isPlus) colorScheme.onSurface else colorScheme.onPrimary - val onContainerVariant = if (isPlus) colorScheme.onSurfaceVariant else colorScheme.onPrimary - - Row( - verticalAlignment = Alignment.CenterVertically, + ClickableListItem( + leadingContent = { + Icon( + painterResource(R.drawable.tomato_logo_notification), + null, + modifier = Modifier.size(24.dp) + ) + }, + headlineContent = { + Text( + if (!isPlus) stringResource(R.string.get_plus) + else stringResource(R.string.app_name_plus) + ) + }, + supportingContent = { + if (!isPlus) Text(stringResource(R.string.tomato_plus_desc)) + }, + trailingContent = { + Icon( + painterResource(R.drawable.arrow_forward_big), + null + ) + }, + colors = if (isPlus) listItemColors else ListItemDefaults.colors( + containerColor = colorScheme.primary, + leadingIconColor = colorScheme.onPrimary, + trailingIconColor = colorScheme.onPrimary, + supportingColor = colorScheme.onPrimary, + headlineColor = colorScheme.onPrimary + ), + items = 2, + index = 0, modifier = modifier - .clip(CircleShape) - .clickable { setShowPaywall(true) } - .background(container) - .padding(16.dp) - ) { - Icon( - painterResource(R.drawable.tomato_logo_notification), - null, - tint = onContainerVariant, - modifier = Modifier - .size(24.dp) - ) - Spacer(Modifier.width(8.dp)) - Text( - if (!isPlus) stringResource(R.string.get_plus) - else stringResource(R.string.app_name_plus), - style = typography.titleLarge, - fontFamily = robotoFlexTopBar, - color = onContainer - ) - Spacer(Modifier.weight(1f)) - Icon( - painterResource(R.drawable.arrow_forward_big), - null, - tint = onContainerVariant - ) - } + ) { setShowPaywall(true) } } \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AboutScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AboutScreen.kt index 1e8a347..992f82e 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AboutScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AboutScreen.kt @@ -80,7 +80,7 @@ fun AboutScreen( onBack: () -> Unit, modifier: Modifier = Modifier ) { - val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() + val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior() val context = LocalContext.current val uriHandler = LocalUriHandler.current diff --git a/app/src/main/res/drawable/info.xml b/app/src/main/res/drawable/info.xml index bd589bd..8a56e42 100644 --- a/app/src/main/res/drawable/info.xml +++ b/app/src/main/res/drawable/info.xml @@ -1,10 +1,26 @@ + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52ec1f8..5a86cde 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -101,4 +101,5 @@ Translate Tomato into your language Liked the app? Write a review! Support me with a small donation + Customize further with Tomato+ \ No newline at end of file