From 9a41d837e248790b39a0a734291dec36455e5e22 Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Tue, 21 Oct 2025 21:32:27 +0530 Subject: [PATCH] feat(ui): implement an about card --- .../pomodoro/ui/settingsScreen/AboutCard.kt | 147 ++++++++++++++++++ app/src/main/res/drawable/coffee.xml | 9 ++ app/src/main/res/drawable/discord.xml | 9 ++ app/src/main/res/drawable/github.xml | 9 ++ app/src/main/res/drawable/play_store.xml | 10 ++ 5 files changed, 184 insertions(+) create mode 100644 app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/AboutCard.kt create mode 100644 app/src/main/res/drawable/coffee.xml create mode 100644 app/src/main/res/drawable/discord.xml create mode 100644 app/src/main/res/drawable/github.xml create mode 100644 app/src/main/res/drawable/play_store.xml diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/AboutCard.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/AboutCard.kt new file mode 100644 index 0000000..96da61c --- /dev/null +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/AboutCard.kt @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2025 Nishant Mishra + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.nsh07.pomodoro.ui.settingsScreen + +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.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +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.robotoFlexHeadline +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 +@Composable +fun AboutCard(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 + ) { + val buttonColors = ButtonDefaults.buttonColors( + containerColor = colorScheme.onPrimaryContainer, + contentColor = colorScheme.primaryContainer + ) + + Row( + modifier = Modifier + .padding(16.dp) + .fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp) + ) { + Column { + Text( + text = stringResource(R.string.app_name), + style = MaterialTheme.typography.titleLarge, + fontFamily = robotoFlexTopBar + ) + Text( + text = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})", + fontFamily = robotoFlexHeadline + ) + } + + Spacer(modifier = Modifier.weight(1f)) + + Row { + IconButton( + onClick = { + Toast.makeText(context, "Coming soon...", Toast.LENGTH_SHORT).show() + } + ) { + Icon( + painterResource(R.drawable.discord), + contentDescription = "Discord", + modifier = Modifier.size(24.dp) + ) + } + + IconButton( + onClick = { uriHandler.openUri("https://github.com/nsh07/Tomato") } + ) { + 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) + ) { + Button( + colors = buttonColors, + onClick = { uriHandler.openUri("https://coff.ee/nsh07") } + ) { + Row( + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Icon( + painterResource(R.drawable.coffee), + contentDescription = "Buy me a coffee", + ) + + Text(text = "Buy me a coffee") + } + } + + Button( + colors = buttonColors, + onClick = { uriHandler.openUri("https://play.google.com/store/apps/details?id=org.nsh07.pomodoro") } + ) { + Row( + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Icon( + painterResource(R.drawable.play_store), + contentDescription = "Rate on Google Play", + modifier = Modifier.size(20.dp) + ) + + Text(text = "Rate on Google Play") + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/coffee.xml b/app/src/main/res/drawable/coffee.xml new file mode 100644 index 0000000..05b913c --- /dev/null +++ b/app/src/main/res/drawable/coffee.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/discord.xml b/app/src/main/res/drawable/discord.xml new file mode 100644 index 0000000..e0b6446 --- /dev/null +++ b/app/src/main/res/drawable/discord.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/github.xml b/app/src/main/res/drawable/github.xml new file mode 100644 index 0000000..c60cd31 --- /dev/null +++ b/app/src/main/res/drawable/github.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/play_store.xml b/app/src/main/res/drawable/play_store.xml new file mode 100644 index 0000000..fc7ef76 --- /dev/null +++ b/app/src/main/res/drawable/play_store.xml @@ -0,0 +1,10 @@ + + +