Skip to content

Commit bf77623

Browse files
committed
ui: remove hardcoded colors and font, configure light/dark theme #25
1 parent 681def5 commit bf77623

23 files changed

+1160
-765
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ dependencies {
8989
implementation(libs.koin.android)
9090
implementation(libs.koin.annotations)
9191
implementation(libs.koin.androidx.compose)
92+
implementation(libs.androidx.ui.text.google.fonts)
9293
ksp(libs.koin.ksp.compiler)
9394

9495
// ObjectBox: on-device NoSQL database

app/src/main/java/io/shubham0204/smollmandroid/ui/components/AppAlertDialog.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import androidx.compose.runtime.Composable
2323
import androidx.compose.runtime.getValue
2424
import androidx.compose.runtime.mutableStateOf
2525
import androidx.compose.runtime.remember
26-
import io.shubham0204.smollmandroid.ui.theme.AppFontFamily
2726

2827
private var title = ""
2928
private var text = ""
@@ -38,8 +37,8 @@ fun AppAlertDialog() {
3837
val visible by remember { alertDialogShowStatus }
3938
if (visible) {
4039
AlertDialog(
41-
title = { Text(text = title, fontFamily = AppFontFamily) },
42-
text = { Text(text = text, fontFamily = AppFontFamily) },
40+
title = { Text(text = title) },
41+
text = { Text(text = text) },
4342
onDismissRequest = { /* All alert dialogs are non-cancellable */ },
4443
confirmButton = {
4544
TextButton(

app/src/main/java/io/shubham0204/smollmandroid/ui/components/AppProgressDialog.kt

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,17 @@ import androidx.compose.foundation.layout.padding
2525
import androidx.compose.foundation.shape.RoundedCornerShape
2626
import androidx.compose.material3.LinearProgressIndicator
2727
import androidx.compose.material3.MaterialTheme
28+
import androidx.compose.material3.Surface
2829
import androidx.compose.material3.Text
2930
import androidx.compose.runtime.Composable
3031
import androidx.compose.runtime.getValue
3132
import androidx.compose.runtime.mutableStateOf
3233
import androidx.compose.runtime.remember
3334
import androidx.compose.ui.Alignment
3435
import androidx.compose.ui.Modifier
35-
import androidx.compose.ui.graphics.Color
3636
import androidx.compose.ui.text.style.TextAlign
3737
import androidx.compose.ui.unit.dp
3838
import androidx.compose.ui.window.Dialog
39-
import io.shubham0204.smollmandroid.ui.theme.AppAccentColor
40-
import io.shubham0204.smollmandroid.ui.theme.AppFontFamily
4139

4240
private val progressDialogVisibleState = mutableStateOf(false)
4341
private val progressDialogText = mutableStateOf("")
@@ -47,32 +45,35 @@ private val progressDialogTitle = mutableStateOf("")
4745
fun AppProgressDialog() {
4846
val isVisible by remember { progressDialogVisibleState }
4947
if (isVisible) {
50-
Dialog(onDismissRequest = { /* Progress dialogs are non-cancellable */ }) {
51-
Box(
52-
contentAlignment = Alignment.Center,
53-
modifier =
54-
Modifier
55-
.fillMaxWidth()
56-
.background(Color.White, shape = RoundedCornerShape(8.dp)),
57-
) {
58-
Column(
59-
horizontalAlignment = Alignment.CenterHorizontally,
60-
modifier = Modifier.padding(vertical = 24.dp),
48+
Surface {
49+
Dialog(onDismissRequest = { /* Progress dialogs are non-cancellable */ }) {
50+
Box(
51+
contentAlignment = Alignment.Center,
52+
modifier =
53+
Modifier
54+
.fillMaxWidth()
55+
.background(MaterialTheme.colorScheme.surfaceContainer, shape = RoundedCornerShape(8.dp)),
6156
) {
62-
Text(text = progressDialogTitle.value, fontFamily = AppFontFamily)
63-
Spacer(modifier = Modifier.padding(4.dp))
64-
LinearProgressIndicator(
65-
modifier = Modifier.fillMaxWidth(),
66-
color = AppAccentColor,
67-
)
68-
Spacer(modifier = Modifier.padding(4.dp))
69-
Text(
70-
text = progressDialogText.value,
71-
textAlign = TextAlign.Center,
72-
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp),
73-
fontFamily = AppFontFamily,
74-
style = MaterialTheme.typography.labelSmall,
75-
)
57+
Column(
58+
horizontalAlignment = Alignment.CenterHorizontally,
59+
modifier = Modifier.padding(vertical = 24.dp),
60+
) {
61+
Text(text = progressDialogTitle.value)
62+
Spacer(modifier = Modifier.padding(4.dp))
63+
LinearProgressIndicator(
64+
modifier = Modifier.fillMaxWidth(),
65+
)
66+
Spacer(modifier = Modifier.padding(4.dp))
67+
Text(
68+
text = progressDialogText.value,
69+
textAlign = TextAlign.Center,
70+
modifier =
71+
Modifier
72+
.fillMaxWidth()
73+
.padding(horizontal = 16.dp),
74+
style = MaterialTheme.typography.labelSmall,
75+
)
76+
}
7677
}
7778
}
7879
}

app/src/main/java/io/shubham0204/smollmandroid/ui/components/Text.kt

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,11 @@
1616

1717
package io.shubham0204.smollmandroid.ui.components
1818

19-
import androidx.compose.foundation.layout.fillMaxWidth
2019
import androidx.compose.material3.MaterialTheme
2120
import androidx.compose.material3.Text
2221
import androidx.compose.runtime.Composable
2322
import androidx.compose.ui.Modifier
24-
import androidx.compose.ui.graphics.Color
2523
import androidx.compose.ui.text.font.FontWeight
26-
import androidx.compose.ui.text.style.TextAlign
27-
import io.shubham0204.smollmandroid.ui.theme.AppFontFamily
28-
29-
@Composable
30-
fun SmallLabelText(
31-
text: String,
32-
modifier: Modifier = Modifier,
33-
textColor: Color = Color.Black,
34-
) {
35-
Text(
36-
text = text,
37-
style = MaterialTheme.typography.labelSmall,
38-
fontFamily = AppFontFamily,
39-
modifier = modifier,
40-
color = textColor,
41-
)
42-
}
4324

4425
@Composable
4526
fun MediumLabelText(
@@ -49,7 +30,6 @@ fun MediumLabelText(
4930
Text(
5031
text = text,
5132
style = MaterialTheme.typography.labelMedium,
52-
fontFamily = AppFontFamily,
5333
modifier = modifier,
5434
)
5535
}
@@ -62,25 +42,10 @@ fun LargeLabelText(
6242
Text(
6343
text = text,
6444
style = MaterialTheme.typography.labelLarge,
65-
fontFamily = AppFontFamily,
6645
modifier = modifier,
6746
)
6847
}
6948

70-
@Composable
71-
fun DialogTitleText(
72-
text: String,
73-
modifier: Modifier = Modifier,
74-
) {
75-
Text(
76-
text = text,
77-
style = MaterialTheme.typography.titleLarge,
78-
fontFamily = AppFontFamily,
79-
modifier = modifier.fillMaxWidth(),
80-
textAlign = TextAlign.Center,
81-
)
82-
}
83-
8449
@Composable
8550
fun AppBarTitleText(
8651
text: String,
@@ -89,7 +54,6 @@ fun AppBarTitleText(
8954
Text(
9055
text = text,
9156
style = MaterialTheme.typography.titleMedium,
92-
fontFamily = AppFontFamily,
9357
modifier = modifier,
9458
fontWeight = FontWeight.Bold,
9559
)

0 commit comments

Comments
 (0)