From dc68f7ae9b4d0c46214422fb85b9d05e2fa1d8fc Mon Sep 17 00:00:00 2001
From: Charlie Rostant YOSSA <122052081+Shermine237@users.noreply.github.com>
Date: Mon, 1 Jul 2024 18:09:37 +0100
Subject: [PATCH] refactor: #2636 Use MaterialTheme colors for a uniform theme
(#2637)
---
.../mifos/mobile/ui/about/AboutUsHeader.kt | 4 ++--
.../mifos/mobile/ui/about/AboutUsScreen.kt | 7 +++++--
.../client_accounts/ClientAccountsScreen.kt | 5 ++---
.../org/mifos/mobile/ui/help/HelpScreen.kt | 2 +-
.../org/mifos/mobile/ui/login/LoginScreen.kt | 20 +++++++++----------
.../ui/user_profile/UserProfileDetails.kt | 15 +++++++-------
app/src/main/res/values/colors.xml | 2 +-
app/src/main/res/values/styles.xml | 4 +++-
.../screens/RegistrationScreen.kt | 7 +++++--
.../screens/RegistrationVerificationScreen.kt | 4 ++--
.../ui/component/MifosOutlinedTextField.kt | 2 +-
.../MifosTextButtonWithTopDrawable.kt | 5 ++---
12 files changed, 42 insertions(+), 35 deletions(-)
diff --git a/app/src/main/java/org/mifos/mobile/ui/about/AboutUsHeader.kt b/app/src/main/java/org/mifos/mobile/ui/about/AboutUsHeader.kt
index 944e6121e..ded1e8a65 100644
--- a/app/src/main/java/org/mifos/mobile/ui/about/AboutUsHeader.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/about/AboutUsHeader.kt
@@ -33,7 +33,7 @@ fun AboutUsHeader() {
Text(
text = stringResource(id = R.string.app_name),
style = MaterialTheme.typography.headlineMedium,
- color = if (isSystemInDarkTheme()) Color.White else Color.Black,
+ color = MaterialTheme.colorScheme.onSurface,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
@@ -43,7 +43,7 @@ fun AboutUsHeader() {
Text(
text = stringResource(id = R.string.about_app_description),
style = MaterialTheme.typography.titleSmall.copy(),
- color = if (isSystemInDarkTheme()) Color.White else Color.Black,
+ color = MaterialTheme.colorScheme.onSurface,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
diff --git a/app/src/main/java/org/mifos/mobile/ui/about/AboutUsScreen.kt b/app/src/main/java/org/mifos/mobile/ui/about/AboutUsScreen.kt
index 62691551c..3bad22efc 100644
--- a/app/src/main/java/org/mifos/mobile/ui/about/AboutUsScreen.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/about/AboutUsScreen.kt
@@ -10,6 +10,7 @@ import androidx.compose.ui.unit.dp
import org.mifos.mobile.core.model.enums.AboutUsListItemId
import org.mifos.mobile.core.ui.component.AboutUsItemCard
import org.mifos.mobile.core.ui.component.MifosItemCard
+import org.mifos.mobile.core.ui.theme.MifosMobileTheme
@Composable
fun AboutUsScreen(viewModel: AboutUsViewModel) {
@@ -64,8 +65,10 @@ fun AboutUsScreen(viewModel: AboutUsViewModel) {
}
+@Preview(showSystemUi = true, device = "id:pixel_5")
@Composable
-@Preview
fun AboutScreenPreview() {
- AboutUsScreen(AboutUsViewModel())
+ MifosMobileTheme {
+ AboutUsScreen(AboutUsViewModel())
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/org/mifos/mobile/ui/client_accounts/ClientAccountsScreen.kt b/app/src/main/java/org/mifos/mobile/ui/client_accounts/ClientAccountsScreen.kt
index b59fa3d77..5bf3494f1 100644
--- a/app/src/main/java/org/mifos/mobile/ui/client_accounts/ClientAccountsScreen.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/client_accounts/ClientAccountsScreen.kt
@@ -128,13 +128,12 @@ fun ClientAccountsScreen(
1 -> openNextActivity(currentPage)
}
},
- contentColor = if (isSystemInDarkTheme()) MaterialTheme.colorScheme.secondary
- else MaterialTheme.colorScheme.primary,
+ contentColor = MaterialTheme.colorScheme.primary,
content = {
Icon(
imageVector = MifosIcons.Add,
contentDescription = "Create Account",
- tint = if (isSystemInDarkTheme()) Color.Black else Color.White
+ tint = MaterialTheme.colorScheme.onSurface
)
}
),
diff --git a/app/src/main/java/org/mifos/mobile/ui/help/HelpScreen.kt b/app/src/main/java/org/mifos/mobile/ui/help/HelpScreen.kt
index 4e47bb7e0..e53245303 100644
--- a/app/src/main/java/org/mifos/mobile/ui/help/HelpScreen.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/help/HelpScreen.kt
@@ -61,7 +61,7 @@ fun HelpScreen(
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 8.dp),
style = MaterialTheme.typography.titleMedium,
- color = if (isSystemInDarkTheme()) Color.White else Color.Black
+ color = MaterialTheme.colorScheme.onSurface
)
if (!faqArrayList.isNullOrEmpty()) {
diff --git a/app/src/main/java/org/mifos/mobile/ui/login/LoginScreen.kt b/app/src/main/java/org/mifos/mobile/ui/login/LoginScreen.kt
index 84c7831b0..b6cfcdbf5 100644
--- a/app/src/main/java/org/mifos/mobile/ui/login/LoginScreen.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/login/LoginScreen.kt
@@ -23,6 +23,7 @@ import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
+import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@@ -47,6 +48,7 @@ import androidx.compose.ui.unit.sp
import org.mifos.mobile.R
import org.mifos.mobile.core.ui.component.MifosMobileIcon
import org.mifos.mobile.core.ui.component.MifosOutlinedTextField
+import org.mifos.mobile.core.ui.theme.MifosMobileTheme
@OptIn(ExperimentalComposeUiApi::class)
@Composable
@@ -164,9 +166,7 @@ fun LoginScreen(
.padding(start = 16.dp, end = 16.dp, top = 4.dp),
contentPadding = PaddingValues(12.dp),
colors = ButtonDefaults.buttonColors(
- containerColor = if (isSystemInDarkTheme()) Color(
- 0xFF9bb1e3
- ) else Color(0xFF325ca8)
+ containerColor = MaterialTheme.colorScheme.primary
)
) {
Text(text = stringResource(id = R.string.login))
@@ -189,7 +189,7 @@ fun LoginScreen(
modifier = Modifier.padding(8.dp),
text = "or",
fontSize = 18.sp,
- color = if (isSystemInDarkTheme()) Color.White else Color.Black
+ color = MaterialTheme.colorScheme.onSurface
)
Divider(
modifier = Modifier
@@ -207,9 +207,7 @@ fun LoginScreen(
.fillMaxWidth()
.align(Alignment.CenterHorizontally),
colors = ButtonDefaults.textButtonColors(
- contentColor = if (isSystemInDarkTheme()) Color(
- 0xFF9bb1e3
- ) else Color(0xFF325ca8)
+ contentColor = MaterialTheme.colorScheme.primary
)
) {
Text(text = stringResource(id = R.string.create_an_account))
@@ -217,8 +215,10 @@ fun LoginScreen(
}
}
-@Preview(showSystemUi = true, uiMode = UI_MODE_NIGHT_NO)
+@Preview(showSystemUi = true, device = "id:pixel_5")
@Composable
-fun LoginScreenPreview() {
- LoginScreen({ _, _ -> }, {}, { "" }, { "" })
+fun LoanScreenPreview() {
+ MifosMobileTheme {
+ LoginScreen({ _, _ -> }, {}, { "" }, { "" })
+ }
}
diff --git a/app/src/main/java/org/mifos/mobile/ui/user_profile/UserProfileDetails.kt b/app/src/main/java/org/mifos/mobile/ui/user_profile/UserProfileDetails.kt
index b092fc099..3e495cc19 100644
--- a/app/src/main/java/org/mifos/mobile/ui/user_profile/UserProfileDetails.kt
+++ b/app/src/main/java/org/mifos/mobile/ui/user_profile/UserProfileDetails.kt
@@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -31,7 +32,7 @@ fun UserProfileDetails(
Text(
modifier = Modifier.padding(top = 16.dp, start = 8.dp),
text = stringResource(id = R.string.user_details),
- color = Color(0xFF8E9099),
+ color = MaterialTheme.colorScheme.onSecondary,
style = TextStyle(fontSize = 12.sp, fontWeight = FontWeight.SemiBold),
)
Row(
@@ -41,13 +42,13 @@ fun UserProfileDetails(
Icon(
modifier = Modifier.padding(top = 8.dp, end = 8.dp),
painter = painterResource(id = R.drawable.ic_phone_24dp),
- tint = if (isSystemInDarkTheme()) Color(0xFF9bb1e3) else Color(0xFF325ca8),
+ tint = MaterialTheme.colorScheme.surfaceTint,
contentDescription = null
)
userDetails.phoneNumber?.let {
Text(
text = it,
- color = if (isSystemInDarkTheme()) Color.White else Color.Black,
+ color = MaterialTheme.colorScheme.onSurface,
style = TextStyle(fontSize = 14.sp)
)
}
@@ -59,13 +60,13 @@ fun UserProfileDetails(
Icon(
modifier = Modifier.padding(top = 8.dp, end = 8.dp),
painter = painterResource(id = R.drawable.ic_cake_24dp),
- tint = if (isSystemInDarkTheme()) Color(0xFF9bb1e3) else Color(0xFF325ca8),
+ tint = MaterialTheme.colorScheme.surfaceTint,
contentDescription = null
)
userDetails.dob?.let {
Text(
text = it,
- color = if (isSystemInDarkTheme()) Color.White else Color.Black,
+ color = MaterialTheme.colorScheme.onSurface,
style = TextStyle(fontSize = 14.sp)
)
}
@@ -77,13 +78,13 @@ fun UserProfileDetails(
Icon(
modifier = Modifier.padding(top = 8.dp, end = 8.dp),
painter = painterResource(id = R.drawable.ic_gender_24dp),
- tint = if (isSystemInDarkTheme()) Color(0xFF9bb1e3) else Color(0xFF325ca8),
+ tint = MaterialTheme.colorScheme.surfaceTint,
contentDescription = null
)
userDetails.gender?.let {
Text(
text = it,
- color = if (isSystemInDarkTheme()) Color.White else Color.Black,
+ color = MaterialTheme.colorScheme.onSurface,
style = TextStyle(fontSize = 14.sp)
)
}
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 324b9cd91..9648f048d 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -50,7 +50,7 @@
- #03A9F4
+ #FF325ca8
#0288D1
#B3E5FC
#FF4081
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index d62f7768a..cd1726160 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,6 +1,8 @@
-
+