Skip to content

Commit 9a41d83

Browse files
committed
feat(ui): implement an about card
1 parent d0ad8bc commit 9a41d83

File tree

5 files changed

+184
-0
lines changed

5 files changed

+184
-0
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* Copyright (c) 2025 Nishant Mishra
3+
*
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/>.
6+
*/
7+
8+
package org.nsh07.pomodoro.ui.settingsScreen
9+
10+
import android.widget.Toast
11+
import androidx.compose.foundation.layout.Arrangement
12+
import androidx.compose.foundation.layout.Column
13+
import androidx.compose.foundation.layout.FlowRow
14+
import androidx.compose.foundation.layout.Row
15+
import androidx.compose.foundation.layout.Spacer
16+
import androidx.compose.foundation.layout.fillMaxWidth
17+
import androidx.compose.foundation.layout.padding
18+
import androidx.compose.foundation.layout.size
19+
import androidx.compose.material3.Button
20+
import androidx.compose.material3.ButtonDefaults
21+
import androidx.compose.material3.Card
22+
import androidx.compose.material3.CardDefaults
23+
import androidx.compose.material3.Icon
24+
import androidx.compose.material3.IconButton
25+
import androidx.compose.material3.MaterialTheme
26+
import androidx.compose.material3.MaterialTheme.colorScheme
27+
import androidx.compose.material3.MaterialTheme.shapes
28+
import androidx.compose.material3.Text
29+
import androidx.compose.runtime.Composable
30+
import androidx.compose.ui.Alignment
31+
import androidx.compose.ui.Modifier
32+
import androidx.compose.ui.platform.LocalContext
33+
import androidx.compose.ui.platform.LocalUriHandler
34+
import androidx.compose.ui.res.painterResource
35+
import androidx.compose.ui.res.stringResource
36+
import androidx.compose.ui.unit.dp
37+
import org.nsh07.pomodoro.BuildConfig
38+
import org.nsh07.pomodoro.R
39+
import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexHeadline
40+
import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTopBar
41+
42+
// Taken from https://github.com/shub39/Grit/blob/master/app/src/main/java/com/shub39/grit/core/presentation/settings/ui/component/AboutApp.kt
43+
@Composable
44+
fun AboutCard(modifier: Modifier = Modifier) {
45+
val uriHandler = LocalUriHandler.current
46+
val context = LocalContext.current
47+
48+
Card(
49+
modifier = modifier.fillMaxWidth(),
50+
colors = CardDefaults.cardColors(
51+
containerColor = colorScheme.primaryContainer,
52+
contentColor = colorScheme.onPrimaryContainer
53+
),
54+
shape = shapes.extraLarge
55+
) {
56+
val buttonColors = ButtonDefaults.buttonColors(
57+
containerColor = colorScheme.onPrimaryContainer,
58+
contentColor = colorScheme.primaryContainer
59+
)
60+
61+
Row(
62+
modifier = Modifier
63+
.padding(16.dp)
64+
.fillMaxWidth(),
65+
verticalAlignment = Alignment.CenterVertically,
66+
horizontalArrangement = Arrangement.spacedBy(8.dp)
67+
) {
68+
Column {
69+
Text(
70+
text = stringResource(R.string.app_name),
71+
style = MaterialTheme.typography.titleLarge,
72+
fontFamily = robotoFlexTopBar
73+
)
74+
Text(
75+
text = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})",
76+
fontFamily = robotoFlexHeadline
77+
)
78+
}
79+
80+
Spacer(modifier = Modifier.weight(1f))
81+
82+
Row {
83+
IconButton(
84+
onClick = {
85+
Toast.makeText(context, "Coming soon...", Toast.LENGTH_SHORT).show()
86+
}
87+
) {
88+
Icon(
89+
painterResource(R.drawable.discord),
90+
contentDescription = "Discord",
91+
modifier = Modifier.size(24.dp)
92+
)
93+
}
94+
95+
IconButton(
96+
onClick = { uriHandler.openUri("https://github.com/nsh07/Tomato") }
97+
) {
98+
Icon(
99+
painterResource(R.drawable.github),
100+
contentDescription = "GitHub",
101+
modifier = Modifier.size(24.dp)
102+
)
103+
}
104+
}
105+
}
106+
107+
FlowRow(
108+
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
109+
horizontalArrangement = Arrangement.spacedBy(8.dp)
110+
) {
111+
Button(
112+
colors = buttonColors,
113+
onClick = { uriHandler.openUri("https://coff.ee/nsh07") }
114+
) {
115+
Row(
116+
horizontalArrangement = Arrangement.spacedBy(8.dp),
117+
verticalAlignment = Alignment.CenterVertically
118+
) {
119+
Icon(
120+
painterResource(R.drawable.coffee),
121+
contentDescription = "Buy me a coffee",
122+
)
123+
124+
Text(text = "Buy me a coffee")
125+
}
126+
}
127+
128+
Button(
129+
colors = buttonColors,
130+
onClick = { uriHandler.openUri("https://play.google.com/store/apps/details?id=org.nsh07.pomodoro") }
131+
) {
132+
Row(
133+
horizontalArrangement = Arrangement.spacedBy(8.dp),
134+
verticalAlignment = Alignment.CenterVertically
135+
) {
136+
Icon(
137+
painterResource(R.drawable.play_store),
138+
contentDescription = "Rate on Google Play",
139+
modifier = Modifier.size(20.dp)
140+
)
141+
142+
Text(text = "Rate on Google Play")
143+
}
144+
}
145+
}
146+
}
147+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960">
6+
<path
7+
android:fillColor="#e3e3e3"
8+
android:pathData="M440,720q-117,0 -198.5,-81.5T160,440v-240q0,-33 23.5,-56.5T240,120h500q58,0 99,41t41,99q0,58 -41,99t-99,41h-20v40q0,117 -81.5,198.5T440,720ZM240,320h400v-120L240,200v120ZM720,320h20q25,0 42.5,-17.5T800,260q0,-25 -17.5,-42.5T740,200h-20v120ZM200,840q-17,0 -28.5,-11.5T160,800q0,-17 11.5,-28.5T200,760h560q17,0 28.5,11.5T800,800q0,17 -11.5,28.5T760,840L200,840Z" />
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M20.317,4.37a19.791,19.791 0,0 0,-4.885 -1.515,0.074 0.074,0 0,0 -0.079,0.037c-0.211,0.375 -0.445,0.865 -0.608,1.25 -1.845,-0.276 -3.68,-0.276 -5.487,0 -0.164,-0.393 -0.406,-0.874 -0.618,-1.25a0.077,0.077 0,0 0,-0.079 -0.037,19.736 19.736,0 0,0 -4.885,1.515 0.07,0.07 0,0 0,-0.032 0.028C0.533,9.046 -0.319,13.58 0.099,18.058a0.082,0.082 0,0 0,0.031 0.056c2.053,1.508 4.041,2.423 5.993,3.029a0.078,0.078 0,0 0,0.084 -0.028c0.462,-0.63 0.873,-1.295 1.226,-1.994a0.076,0.076 0,0 0,-0.042 -0.106c-0.653,-0.248 -1.274,-0.549 -1.872,-0.892a0.077,0.077 0,0 1,-0.008 -0.128c0.126,-0.094 0.252,-0.192 0.372,-0.291a0.074,0.074 0,0 1,0.078 -0.01c3.928,1.793 8.18,1.793 12.061,0a0.074,0.074 0,0 1,0.079 0.009c0.12,0.099 0.246,0.198 0.373,0.292a0.077,0.077 0,0 1,-0.007 0.128,12.299 12.299,0 0,1 -1.873,0.891 0.077,0.077 0,0 0,-0.041 0.107c0.36,0.698 0.772,1.363 1.225,1.993a0.076,0.076 0,0 0,0.084 0.029c1.961,-0.607 3.95,-1.522 6.002,-3.029a0.077,0.077 0,0 0,0.031 -0.055c0.5,-5.177 -0.838,-9.674 -3.549,-13.66a0.061,0.061 0,0 0,-0.031 -0.029zM8.02,15.331c-1.183,0 -2.157,-1.086 -2.157,-2.419 0,-1.333 0.956,-2.419 2.157,-2.419 1.211,0 2.176,1.095 2.157,2.419 0,1.333 -0.956,2.419 -2.157,2.419zM15.995,15.331c-1.183,0 -2.157,-1.086 -2.157,-2.419 0,-1.333 0.955,-2.419 2.157,-2.419 1.211,0 2.176,1.095 2.157,2.419 0,1.333 -0.946,2.419 -2.157,2.419Z" />
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M12,0.297c-6.63,0 -12,5.373 -12,12 0,5.303 3.438,9.8 8.205,11.385 0.6,0.113 0.82,-0.258 0.82,-0.577 0,-0.285 -0.01,-1.04 -0.015,-2.04 -3.338,0.724 -4.042,-1.61 -4.042,-1.61C4.422,18.07 3.633,17.7 3.633,17.7c-1.087,-0.744 0.084,-0.729 0.084,-0.729 1.205,0.084 1.838,1.236 1.838,1.236 1.07,1.835 2.809,1.305 3.495,0.998 0.108,-0.776 0.417,-1.305 0.76,-1.605 -2.665,-0.3 -5.466,-1.332 -5.466,-5.93 0,-1.31 0.465,-2.38 1.235,-3.22 -0.135,-0.303 -0.54,-1.523 0.105,-3.176 0,0 1.005,-0.322 3.3,1.23 0.96,-0.267 1.98,-0.399 3,-0.405 1.02,0.006 2.04,0.138 3,0.405 2.28,-1.552 3.285,-1.23 3.285,-1.23 0.645,1.653 0.24,2.873 0.12,3.176 0.765,0.84 1.23,1.91 1.23,3.22 0,4.61 -2.805,5.625 -5.475,5.92 0.42,0.36 0.81,1.096 0.81,2.22 0,1.606 -0.015,2.896 -0.015,3.286 0,0.315 0.21,0.69 0.825,0.57C20.565,22.092 24,17.592 24,12.297c0,-6.627 -5.373,-12 -12,-12" />
9+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="6.35"
5+
android:viewportHeight="6.35">
6+
<path
7+
android:fillColor="#000000"
8+
android:pathData="M0.6744,6.3347C0.5991,6.3185 0.471,6.275 0.4362,6.2538 0.4204,6.2442 0.7343,5.9434 1.9712,4.7827L3.5262,3.3236 4.159,3.8713C4.5071,4.1725 4.7868,4.4231 4.7806,4.4283 4.767,4.4398 1.3189,6.2241 1.2202,6.2708 1.0678,6.3428 0.8376,6.3698 0.6744,6.3347ZM0.0712,5.8885C-0.0032,5.736 0,5.8606 0,3.1751c0,-2.6939 -0.0037,-2.5574 0.0735,-2.7187 0.0195,-0.0409 0.0396,-0.0743 0.0445,-0.0743 0.0049,0 0.7041,0.6015 1.5538,1.3366L3.2165,3.0555 1.6709,4.5056C0.8208,5.3031 0.1205,5.9557 0.1146,5.9557c-0.0059,0 -0.0254,-0.0302 -0.0435,-0.0672zM4.5028,3.6306 L3.826,3.0448 4.377,2.5266C4.6801,2.2415 4.9336,2.0083 4.9405,2.0083c0.0168,0 0.9615,0.4887 1.0486,0.5425C6.2037,2.6831 6.35,2.9363 6.35,3.1751 6.35,3.4137 6.2088,3.6595 5.9939,3.7948 5.9253,3.838 5.1959,4.2187 5.1846,4.2171 5.1818,4.2168 4.875,3.9528 4.5028,3.6306ZM3.241,2.5383C3.099,2.4141 2.409,1.8158 1.7076,1.2088 0.5332,0.1924 0.4344,0.1038 0.4572,0.0882 0.5059,0.0547 0.6943,0.008 0.8067,0.0015 0.9426,-0.0064 1.0774,0.0175 1.2002,0.0715 1.247,0.092 2.0206,0.4896 2.9193,0.955L4.5534,1.8012 4.0396,2.2834C3.757,2.5485 3.5198,2.7652 3.5125,2.7648 3.5052,2.7644 3.383,2.6625 3.241,2.5383Z"
9+
android:strokeWidth="0.0120146" />
10+
</vector>

0 commit comments

Comments
 (0)