feat(settings): add paywall restriction in Appearance settings
This commit is contained in:
@@ -35,6 +35,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.nsh07.pomodoro.R
|
||||
@@ -63,14 +64,14 @@ fun TomatoPlusPaywallDialog(
|
||||
)
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Text(
|
||||
"Tomato FOSS",
|
||||
stringResource(R.string.tomato_foss),
|
||||
style = typography.headlineSmall,
|
||||
fontFamily = robotoFlexTopBar,
|
||||
color = colorScheme.onSurface
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
"All features are unlocked in this version. If my app made a difference in your life, please consider supporting me by donating on ${"BuyMeACoffee"}.",
|
||||
stringResource(R.string.tomato_foss_desc, "BuyMeACoffee"),
|
||||
textAlign = TextAlign.Center,
|
||||
color = colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(horizontal = 24.dp)
|
||||
|
||||
@@ -285,9 +285,11 @@ private fun SettingsScreen(
|
||||
entry<Screen.Settings.Appearance> {
|
||||
AppearanceSettings(
|
||||
preferencesState = preferencesState,
|
||||
isPlus = isPlus,
|
||||
onBlackThemeChange = onBlackThemeChange,
|
||||
onThemeChange = onThemeChange,
|
||||
onColorSchemeChange = onColorSchemeChange,
|
||||
setShowPaywall = setShowPaywall,
|
||||
onBack = backStack::removeLastOrNull
|
||||
)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ 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
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
@@ -60,6 +59,7 @@ fun ColorSchemePickerListItem(
|
||||
color: Color,
|
||||
items: Int,
|
||||
index: Int,
|
||||
isPlus: Boolean,
|
||||
onColorChange: (Color) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -99,6 +99,7 @@ fun ColorSchemePickerListItem(
|
||||
if (it) onColorChange(colorSchemes.last())
|
||||
else onColorChange(colorSchemes.first())
|
||||
},
|
||||
enabled = isPlus,
|
||||
thumbContent = {
|
||||
if (checked) {
|
||||
Icon(
|
||||
@@ -149,21 +150,21 @@ fun ColorSchemePickerListItem(
|
||||
)
|
||||
)
|
||||
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
LazyRow(
|
||||
contentPadding = PaddingValues(horizontal = 48.dp),
|
||||
userScrollEnabled = isPlus,
|
||||
modifier = Modifier
|
||||
.background(listItemColors.containerColor)
|
||||
.padding(bottom = 8.dp)
|
||||
) {
|
||||
LazyRow(contentPadding = PaddingValues(horizontal = 48.dp)) {
|
||||
items(colorSchemes.dropLast(1)) {
|
||||
ColorPickerButton(
|
||||
it,
|
||||
it == color,
|
||||
modifier = Modifier.padding(4.dp)
|
||||
) {
|
||||
onColorChange(it)
|
||||
}
|
||||
items(colorSchemes.dropLast(1)) {
|
||||
ColorPickerButton(
|
||||
color = it,
|
||||
isSelected = it == color,
|
||||
enabled = isPlus,
|
||||
modifier = Modifier.padding(4.dp)
|
||||
) {
|
||||
onColorChange(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,12 +176,17 @@ fun ColorSchemePickerListItem(
|
||||
fun ColorPickerButton(
|
||||
color: Color,
|
||||
isSelected: Boolean,
|
||||
enabled: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
IconButton(
|
||||
shapes = IconButtonDefaults.shapes(),
|
||||
colors = IconButtonDefaults.iconButtonColors(containerColor = color),
|
||||
colors = IconButtonDefaults.iconButtonColors(
|
||||
containerColor = color,
|
||||
disabledContainerColor = color.copy(0.3f)
|
||||
),
|
||||
enabled = enabled,
|
||||
modifier = modifier.size(48.dp),
|
||||
onClick = onClick
|
||||
) {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.nsh07.pomodoro.ui.settingsScreen.components
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
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.unit.dp
|
||||
|
||||
@Composable
|
||||
fun PlusDivider(
|
||||
setShowPaywall: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = modifier.padding(vertical = 14.dp)) {
|
||||
HorizontalDivider(modifier = Modifier.clip(CircleShape), thickness = 4.dp)
|
||||
Button(
|
||||
onClick = { setShowPaywall(true) },
|
||||
modifier = Modifier
|
||||
.background(colorScheme.surfaceContainer)
|
||||
.padding(horizontal = 8.dp)
|
||||
) {
|
||||
Text("Customize further with Tomato+", style = typography.titleSmall)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import androidx.compose.ui.unit.dp
|
||||
import org.nsh07.pomodoro.R
|
||||
import org.nsh07.pomodoro.ui.theme.CustomColors.listItemColors
|
||||
import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.bottomListItemShape
|
||||
import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.cardShape
|
||||
import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.middleListItemShape
|
||||
import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.topListItemShape
|
||||
|
||||
@@ -69,11 +70,13 @@ fun ThemePickerListItem(
|
||||
Column(
|
||||
modifier
|
||||
.clip(
|
||||
when (index) {
|
||||
0 -> topListItemShape
|
||||
items - 1 -> bottomListItemShape
|
||||
else -> middleListItemShape
|
||||
},
|
||||
if (items > 1)
|
||||
when (index) {
|
||||
0 -> topListItemShape
|
||||
items - 1 -> bottomListItemShape
|
||||
else -> middleListItemShape
|
||||
}
|
||||
else cardShape,
|
||||
),
|
||||
) {
|
||||
ListItem(
|
||||
|
||||
@@ -48,6 +48,7 @@ import androidx.compose.ui.unit.dp
|
||||
import org.nsh07.pomodoro.R
|
||||
import org.nsh07.pomodoro.ui.settingsScreen.SettingsSwitchItem
|
||||
import org.nsh07.pomodoro.ui.settingsScreen.components.ColorSchemePickerListItem
|
||||
import org.nsh07.pomodoro.ui.settingsScreen.components.PlusDivider
|
||||
import org.nsh07.pomodoro.ui.settingsScreen.components.ThemePickerListItem
|
||||
import org.nsh07.pomodoro.ui.settingsScreen.viewModel.PreferencesState
|
||||
import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTopBar
|
||||
@@ -55,7 +56,6 @@ import org.nsh07.pomodoro.ui.theme.CustomColors.listItemColors
|
||||
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
|
||||
|
||||
@@ -63,9 +63,11 @@ import org.nsh07.pomodoro.utils.toColor
|
||||
@Composable
|
||||
fun AppearanceSettings(
|
||||
preferencesState: PreferencesState,
|
||||
isPlus: Boolean,
|
||||
onBlackThemeChange: (Boolean) -> Unit,
|
||||
onThemeChange: (String) -> Unit,
|
||||
onColorSchemeChange: (Color) -> Unit,
|
||||
setShowPaywall: (Boolean) -> Unit,
|
||||
onBack: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -105,18 +107,22 @@ fun AppearanceSettings(
|
||||
ThemePickerListItem(
|
||||
theme = preferencesState.theme,
|
||||
onThemeChange = onThemeChange,
|
||||
items = 3,
|
||||
index = 0,
|
||||
modifier = Modifier
|
||||
.clip(middleListItemShape)
|
||||
items = if (isPlus) 3 else 1,
|
||||
index = 0
|
||||
)
|
||||
}
|
||||
|
||||
if (!isPlus) {
|
||||
item { PlusDivider(setShowPaywall) }
|
||||
}
|
||||
|
||||
item {
|
||||
ColorSchemePickerListItem(
|
||||
color = preferencesState.colorScheme.toColor(),
|
||||
items = 3,
|
||||
index = 1,
|
||||
onColorChange = onColorSchemeChange
|
||||
index = if (isPlus) 1 else 0,
|
||||
isPlus = isPlus,
|
||||
onColorChange = onColorSchemeChange,
|
||||
)
|
||||
}
|
||||
item {
|
||||
@@ -137,6 +143,7 @@ fun AppearanceSettings(
|
||||
Switch(
|
||||
checked = item.checked,
|
||||
onCheckedChange = { item.onClick(it) },
|
||||
enabled = isPlus,
|
||||
thumbContent = {
|
||||
if (item.checked) {
|
||||
Icon(
|
||||
@@ -172,9 +179,11 @@ fun AppearanceSettingsPreview() {
|
||||
TomatoTheme {
|
||||
AppearanceSettings(
|
||||
preferencesState = preferencesState,
|
||||
isPlus = false,
|
||||
onBlackThemeChange = {},
|
||||
onThemeChange = {},
|
||||
onColorSchemeChange = {},
|
||||
setShowPaywall = {},
|
||||
onBack = {}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -85,4 +85,6 @@
|
||||
<string name="get_plus">Get Tomato+</string>
|
||||
<string name="dynamic_color">Dynamic color</string>
|
||||
<string name="dynamic_color_desc">Adapt theme colors from your wallpaper</string>
|
||||
<string name="tomato_foss">Tomato FOSS</string>
|
||||
<string name="tomato_foss_desc">All features are unlocked in this version. If my app made a difference in your life, please consider supporting me by donating on %1$s.</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user