Skip to content

Commit 6720bca

Browse files
sam-arth07niyajali
andauthored
refactor(core, feature): replaced hard-coded colors. (#1873)
Co-authored-by: Sk Niyaj Ali <niyaj639@gmail.com>
1 parent a64750b commit 6720bca

File tree

21 files changed

+151
-230
lines changed

21 files changed

+151
-230
lines changed

core/designsystem/src/commonMain/kotlin/org/mifospay/core/designsystem/component/BottomSheet.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.compose.animation.AnimatedVisibility
1313
import androidx.compose.foundation.layout.Box
1414
import androidx.compose.foundation.layout.height
1515
import androidx.compose.material3.ExperimentalMaterial3Api
16+
import androidx.compose.material3.MaterialTheme
1617
import androidx.compose.material3.ModalBottomSheet
1718
import androidx.compose.material3.rememberModalBottomSheetState
1819
import androidx.compose.runtime.Composable
@@ -22,7 +23,6 @@ import androidx.compose.runtime.remember
2223
import androidx.compose.runtime.rememberCoroutineScope
2324
import androidx.compose.runtime.setValue
2425
import androidx.compose.ui.Modifier
25-
import androidx.compose.ui.graphics.Color
2626
import androidx.compose.ui.unit.dp
2727
import com.arkivanov.essenty.backhandler.BackCallback
2828
import kotlinx.coroutines.launch
@@ -54,7 +54,7 @@ fun MifosBottomSheet(
5454

5555
AnimatedVisibility(visible = showBottomSheet) {
5656
ModalBottomSheet(
57-
containerColor = Color.White,
57+
containerColor = MaterialTheme.colorScheme.surfaceContainerLowest,
5858
onDismissRequest = {
5959
showBottomSheet = false
6060
dismissSheet()

core/designsystem/src/commonMain/kotlin/org/mifospay/core/designsystem/theme/Color.kt

Lines changed: 32 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -9,102 +9,22 @@
99
*/
1010
package org.mifospay.core.designsystem.theme
1111

12+
import androidx.compose.material3.MaterialTheme
13+
import androidx.compose.runtime.Composable
1214
import androidx.compose.ui.graphics.Color
1315

14-
// val md_theme_light_primary = Color(0xFF0673BA) // primary
15-
// val md_theme_light_onPrimary = Color(0xFFFFFFFF) // gradientOne
16-
// val md_theme_light_primaryContainer = Color(0xFFF5F5F5) // container color
17-
// val md_theme_light_onPrimaryContainer = Color(0xFF3E001D)
18-
//
19-
// val md_theme_light_secondary = Color(0xFF984061)
20-
// val md_theme_light_onSecondary = Color(0xFFFFFFFF)
21-
// val md_theme_light_secondaryContainer = Color(0xFFFFD9E2)
22-
// val md_theme_light_onSecondaryContainer = Color(0xFF3E001D)
23-
//
24-
// val md_theme_light_tertiary = Color(0xFF7D4996)
25-
// val md_theme_light_onTertiary = Color(0xFFFFFFFF)
26-
// val md_theme_light_tertiaryContainer = Color(0xFFF6D9FF)
27-
// val md_theme_light_onTertiaryContainer = Color(0xFF310049)
28-
//
29-
// val md_theme_light_error = Color(0xFFBA1A1A)
30-
// val md_theme_light_errorContainer = Color(0xFFFFDAD6)
31-
// val md_theme_light_onError = Color(0xFFFFFFFF)
32-
// val md_theme_light_onErrorContainer = Color(0xFF410002)
33-
//
34-
// val md_theme_light_background = Color(0xFFFFFBFF)
35-
// val md_theme_light_onBackground = Color(0xFF330045)
36-
//
37-
// val md_theme_light_surface = Color(0xFFFFFBFF)
38-
// val md_theme_light_onSurface = Color(0xFF333333) // onSurface
39-
// val md_theme_light_surfaceVariant = Color(0xFFF2DDE1)
40-
// val md_theme_light_onSurfaceVariant = Color(0xFF514347)
41-
// val md_theme_light_surfaceTint = Color(0xFF984061)
42-
//
43-
// val md_theme_light_outline = Color(0xFF837377)
44-
// val md_theme_light_outlineVariant = Color(0xFFD5C2C6)
45-
//
46-
// val md_theme_light_inverseOnSurface = Color(0xFFFFEBFF)
47-
// val md_theme_light_inverseSurface = Color(0xFF4D1661)
48-
// val md_theme_light_inversePrimary = Color(0xFFFFB1C8)
49-
//
50-
// val md_theme_light_shadow = Color(0xFF000000)
51-
// val md_theme_light_scrim = Color(0xFF000000)
52-
//
53-
//
54-
// // val md_theme_dark_primary = Color(0xFFFFFFFF)
55-
// val md_theme_dark_primary = Color(0xFF80CFFF)
56-
// val md_theme_dark_onPrimary = Color(0xFF000000)
57-
// val md_theme_dark_primaryContainer = Color(0xFF7B2949)
58-
// val md_theme_dark_onPrimaryContainer = Color(0xFFFFD9E2)
59-
//
60-
// val md_theme_dark_secondary = Color(0xFFFFB1C8)
61-
// val md_theme_dark_onSecondary = Color(0xFF5E1133)
62-
// val md_theme_dark_secondaryContainer = Color(0xFF7B2949)
63-
// val md_theme_dark_onSecondaryContainer = Color(0xFFFFD9E2)
64-
//
65-
// val md_theme_dark_tertiary = Color(0xFFE8B3FF)
66-
// val md_theme_dark_onTertiary = Color(0xFF4A1764)
67-
// val md_theme_dark_tertiaryContainer = Color(0xFF63307C)
68-
// val md_theme_dark_onTertiaryContainer = Color(0xFFF6D9FF)
69-
//
70-
// val md_theme_dark_error = Color(0xFFFFB4AB)
71-
// val md_theme_dark_errorContainer = Color(0xFF93000A)
72-
// val md_theme_dark_onError = Color(0xFF690005)
73-
// val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
74-
//
75-
// val md_theme_dark_background = Color(0xFF330045)
76-
// val md_theme_dark_onBackground = Color(0xFFFAD7FF)
77-
//
78-
// // val md_theme_dark_surface = Color(0xFF000000)
79-
// val md_theme_dark_surface = Color(0xFF1E1E1E)
80-
// val md_theme_dark_onSurface = Color(0xFFFFFFFF)
81-
// val md_theme_dark_surfaceVariant = Color(0xFF514347)
82-
// val md_theme_dark_onSurfaceVariant = Color(0xFFD5C2C6)
83-
// val md_theme_dark_surfaceTint = Color(0xFFFFB1C8)
84-
//
85-
// val md_theme_dark_outline = Color(0xFF9E8C90)
86-
// val md_theme_dark_outlineVariant = Color(0xFF514347)
87-
//
88-
// val md_theme_dark_inverseOnSurface = Color(0xFF330045)
89-
// val md_theme_dark_inverseSurface = Color(0xFFFAD7FF)
90-
// val md_theme_dark_inversePrimary = Color(0xFF984061)
91-
//
92-
// val md_theme_dark_shadow = Color(0xFF000000)
93-
// val md_theme_dark_scrim = Color(0xFF000000)
94-
95-
// Primary Light
96-
val primaryLight = Color(0xFF0673BA) // Main brand color
97-
val onPrimaryLight = Color(0xFFFFFFFF) // Contrast text/icon on primary
98-
val primaryContainerLight = Color(0xFFCEEAFD) // Lighter tone for background of components
99-
val onPrimaryContainerLight = Color(0XFF033D63) // Text/icon over container
100-
val secondaryLight = Color(0xFF984061) // Main secondary tone, rich and expressive
101-
val onSecondaryLight = Color(0xFFFFFFFF) // Best contrast for readable text/icons
102-
val secondaryContainerLight = Color(0xFFF0DBE3) // Soft container tone
103-
val onSecondaryContainerLight = Color(0xFF361722) // Dark text/icon for contrast on container
104-
val tertiaryLight = Color(0xFF7D4996) // Base tertiary
105-
val onTertiaryLight = Color(0xFFFFFFFF) // Light text/icons on tertiary
106-
val tertiaryContainerLight = Color(0XFFE9DDEE) // soft pastel background variant
107-
val onTertiaryContainerLight = Color(0xFF2B1934) // Deep tone for legibility over container
16+
val primaryLight = Color(0xFF0673BA)
17+
val onPrimaryLight = Color(0xFFFFFFFF)
18+
val primaryContainerLight = Color(0xFFCEEAFD)
19+
val onPrimaryContainerLight = Color(0xFF033D63)
20+
val secondaryLight = Color(0xFF984061)
21+
val onSecondaryLight = Color(0xFFFFFFFF)
22+
val secondaryContainerLight = Color(0xFFF0DBE3)
23+
val onSecondaryContainerLight = Color(0xFF361722)
24+
val tertiaryLight = Color(0xFF7D4996)
25+
val onTertiaryLight = Color(0xFFFFFFFF)
26+
val tertiaryContainerLight = Color(0XFFE9DDEE)
27+
val onTertiaryContainerLight = Color(0xFF2B1934)
10828
val errorLight = Color(0xFFBA1A1A)
10929
val onErrorLight = Color(0xFFFFFFFF)
11030
val errorContainerLight = Color(0xFFFFDAD6)
@@ -129,18 +49,18 @@ val surfaceContainerLight = Color(0xFFECEEF4)
12949
val surfaceContainerHighLight = Color(0xFFE6E8EE)
13050
val surfaceContainerHighestLight = Color(0xFFE0E2E9)
13151

132-
val primaryDark = Color(0xFF9CD6FC) // Slightly desaturated light tone
133-
val onPrimaryDark = Color(0xFF033D63) // Dark enough to maintain contrast
134-
val primaryContainerDark = Color(0xFF044C7C) // Deep tone for component background
135-
val onPrimaryContainerDark = Color(0XFFE6F5FE) // Light text/icon over container
136-
val secondaryDark = Color(0xFFD9A5B8) // Softer tone for dark surfaces
137-
val onSecondaryDark = Color(0xFF361722) // Still provides strong contrast
138-
val secondaryContainerDark = Color(0xFF5A2639) // Deep tone for container
139-
val onSecondaryContainerDark = Color(0xFFF0DBE3) // Light foreground over container
140-
val tertiaryDark = Color(0xFFC7A9D6) // bright pop for dark mode
141-
val onTertiaryDark = Color(0xFF3A2145) // Deep text/icon for contrast
142-
val tertiaryContainerDark = Color(0xFF653A78) // Solid background fill
143-
val onTertiaryContainerDark = Color(0xFFF4EEF7) // Light text/icons over container
52+
val primaryDark = Color(0xFF9CD6FC)
53+
val onPrimaryDark = Color(0xFF033D63)
54+
val primaryContainerDark = Color(0xFF044C7C)
55+
val onPrimaryContainerDark = Color(0xFFE6F5FE)
56+
val secondaryDark = Color(0xFFD9A5B8)
57+
val onSecondaryDark = Color(0xFF361722)
58+
val secondaryContainerDark = Color(0xFF5A2639)
59+
val onSecondaryContainerDark = Color(0xFFF0DBE3)
60+
val tertiaryDark = Color(0xFFC7A9D6)
61+
val onTertiaryDark = Color(0xFF3A2145)
62+
val tertiaryContainerDark = Color(0xFF653A78)
63+
val onTertiaryContainerDark = Color(0xFFF4EEF7)
14464
val errorDark = Color(0xFFFFB4AB)
14565
val onErrorDark = Color(0xFF690005)
14666
val errorContainerDark = Color(0xFF93000A)
@@ -165,8 +85,11 @@ val surfaceContainerDark = Color(0xFF1C2025)
16585
val surfaceContainerHighDark = Color(0xFF272A2F)
16686
val surfaceContainerHighestDark = Color(0xFF32353A)
16787

168-
// New UI Colors
16988
object NewUi {
170-
val walletColor1 = Color(0xFF1f7dd5)
171-
val walletColor2 = Color(0xFF1ec0a0)
89+
val walletColor1: Color
90+
@Composable
91+
get() = MaterialTheme.colorScheme.primary
92+
val walletColor2: Color
93+
@Composable
94+
get() = MaterialTheme.colorScheme.secondary
17295
}

core/designsystem/src/commonMain/kotlin/org/mifospay/core/designsystem/theme/MifosTextStyle.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ val styleMifosTopBar =
4444
fontSize = 20.sp,
4545
)
4646

47-
val styleSettingsButton = TextStyle(color = Color.White, textAlign = TextAlign.Center)
48-
val historyItemTextStyle = TextStyle(color = Color.Black, fontSize = 16.sp)
47+
val styleSettingsButton = TextStyle(textAlign = TextAlign.Center)
48+
val historyItemTextStyle = TextStyle(fontSize = 16.sp)

core/ui/src/commonMain/kotlin/org/mifospay/core/ui/ExpiryDateInput.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ import androidx.compose.ui.Alignment
2626
import androidx.compose.ui.ExperimentalComposeUiApi
2727
import androidx.compose.ui.Modifier
2828
import androidx.compose.ui.focus.FocusRequester
29+
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component1
30+
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component2
2931
import androidx.compose.ui.focus.focusProperties
3032
import androidx.compose.ui.focus.focusRequester
31-
import androidx.compose.ui.graphics.Color
3233
import androidx.compose.ui.text.TextRange
3334
import androidx.compose.ui.text.input.ImeAction
3435
import androidx.compose.ui.text.input.KeyboardType
@@ -119,9 +120,9 @@ fun FormattedDateView(
119120
text = char,
120121
style = MaterialTheme.typography.headlineSmall,
121122
color = if (isFocused) {
122-
Color.DarkGray
123+
MaterialTheme.colorScheme.outline
123124
} else {
124-
Color.LightGray
125+
MaterialTheme.colorScheme.outlineVariant
125126
},
126127
textAlign = TextAlign.Center,
127128
)

core/ui/src/commonMain/kotlin/org/mifospay/core/ui/HeadingTitile.kt renamed to core/ui/src/commonMain/kotlin/org/mifospay/core/ui/HeadingTitle.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import androidx.compose.material3.MaterialTheme
1919
import androidx.compose.material3.Text
2020
import androidx.compose.runtime.Composable
2121
import androidx.compose.ui.Modifier
22-
import androidx.compose.ui.graphics.Color
2322
import androidx.compose.ui.text.TextStyle
2423
import androidx.compose.ui.text.font.FontWeight
2524
import androidx.compose.ui.text.style.TextAlign
@@ -58,7 +57,7 @@ fun VerifyStepHeader(
5857
Icon(
5958
imageVector = MifosIcons.Check,
6059
contentDescription = null,
61-
tint = if (isVerified) MaterialTheme.colorScheme.onSurface else Color.Gray,
60+
tint = if (isVerified) MaterialTheme.colorScheme.onSurface else MaterialTheme.colorScheme.outline,
6261
modifier = Modifier.size(24.dp),
6362
)
6463
}
@@ -77,5 +76,7 @@ fun VerifyStepHeaderVerifiedPreview() {
7776
@Preview
7877
@Composable
7978
fun VerifyStepHeaderUnverifiedPreview() {
80-
VerifyStepHeader(text = "Enter OTP ", isVerified = false)
79+
MifosTheme {
80+
VerifyStepHeader(text = "Enter OTP ", isVerified = false)
81+
}
8182
}

core/ui/src/commonMain/kotlin/org/mifospay/core/ui/OtpTextField.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import androidx.compose.runtime.remember
2929
import androidx.compose.runtime.setValue
3030
import androidx.compose.ui.Alignment
3131
import androidx.compose.ui.Modifier
32-
import androidx.compose.ui.graphics.Color
3332
import androidx.compose.ui.text.TextRange
3433
import androidx.compose.ui.text.input.ImeAction
3534
import androidx.compose.ui.text.input.KeyboardType
@@ -94,11 +93,11 @@ fun OtpTextField(
9493
},
9594
)
9695
if (isError) {
97-
// display erro message in text
96+
// display error message in text
9897
Text(
9998
text = "Invalid OTP",
10099
style = MaterialTheme.typography.bodyMedium,
101-
color = Color.Red,
100+
color = MaterialTheme.colorScheme.error,
102101
textAlign = TextAlign.Center,
103102
modifier = Modifier.padding(top = 8.dp),
104103
)
@@ -125,9 +124,9 @@ fun CharView(
125124
text = char,
126125
style = MaterialTheme.typography.headlineSmall,
127126
color = if (isFocused) {
128-
Color.DarkGray
127+
MaterialTheme.colorScheme.outline
129128
} else {
130-
Color.LightGray
129+
MaterialTheme.colorScheme.outlineVariant
131130
},
132131
textAlign = TextAlign.Center,
133132
)

core/ui/src/commonMain/kotlin/org/mifospay/core/ui/PasswordStrengthIndicator.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import androidx.compose.ui.Alignment
4242
import androidx.compose.ui.Modifier
4343
import androidx.compose.ui.draw.clip
4444
import androidx.compose.ui.draw.drawBehind
45-
import androidx.compose.ui.graphics.Color
4645
import androidx.compose.ui.graphics.TransformOrigin
4746
import androidx.compose.ui.graphics.graphicsLayer
4847
import androidx.compose.ui.platform.testTag
@@ -89,10 +88,10 @@ fun CombinedPasswordErrorCard(
8988
PasswordStrengthState.NONE -> MaterialTheme.colorScheme.error
9089
PasswordStrengthState.WEAK_1 -> MaterialTheme.colorScheme.error
9190
PasswordStrengthState.WEAK_2 -> MaterialTheme.colorScheme.error
92-
PasswordStrengthState.WEAK_3 -> weakColor
91+
PasswordStrengthState.WEAK_3 -> MaterialTheme.colorScheme.error
9392
PasswordStrengthState.GOOD -> MaterialTheme.colorScheme.primary
94-
PasswordStrengthState.STRONG -> strongColor
95-
PasswordStrengthState.VERY_STRONG -> Color.Magenta
93+
PasswordStrengthState.STRONG -> MaterialTheme.colorScheme.primary
94+
PasswordStrengthState.VERY_STRONG -> MaterialTheme.colorScheme.tertiary
9695
}
9796

9897
val animatedIndicatorColor by animateColorAsState(
@@ -282,10 +281,10 @@ fun PasswordStrengthIndicator(
282281
PasswordStrengthState.NONE -> MaterialTheme.colorScheme.error
283282
PasswordStrengthState.WEAK_1 -> MaterialTheme.colorScheme.error
284283
PasswordStrengthState.WEAK_2 -> MaterialTheme.colorScheme.error
285-
PasswordStrengthState.WEAK_3 -> weakColor
284+
PasswordStrengthState.WEAK_3 -> MaterialTheme.colorScheme.error
286285
PasswordStrengthState.GOOD -> MaterialTheme.colorScheme.primary
287-
PasswordStrengthState.STRONG -> strongColor
288-
PasswordStrengthState.VERY_STRONG -> Color.Magenta
286+
PasswordStrengthState.STRONG -> MaterialTheme.colorScheme.primary
287+
PasswordStrengthState.VERY_STRONG -> MaterialTheme.colorScheme.tertiary
289288
}
290289
val animatedIndicatorColor by animateColorAsState(
291290
targetValue = indicatorColor,
@@ -346,7 +345,7 @@ private fun MinimumCharacterCount(
346345
) {
347346
val characterCountColor by animateColorAsState(
348347
targetValue = if (minimumRequirementMet) {
349-
strongColor
348+
MaterialTheme.colorScheme.primary
350349
} else {
351350
MaterialTheme.colorScheme.surfaceDim
352351
},
@@ -390,9 +389,6 @@ enum class PasswordStrengthState {
390389
VERY_STRONG,
391390
}
392391

393-
private val strongColor = Color(0xFF41B06D)
394-
private val weakColor = Color(0xFF8B6609)
395-
396392
@Preview
397393
@Composable
398394
private fun PasswordStrengthIndicatorPreview_minCharMet() {

core/ui/src/commonMain/kotlin/org/mifospay/core/ui/TransactionItemCard.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fun TransactionItemCard(
7373
style = TextStyle(
7474
fontSize = 10.sp,
7575
fontWeight = FontWeight(400),
76-
color = Color(0x66000000),
76+
color = MaterialTheme.colorScheme.onSurface,
7777
),
7878
)
7979
}
@@ -99,12 +99,14 @@ fun TransactionItemCard(
9999
green = 0f,
100100
blue = 0f,
101101
)
102+
102103
TransactionType.CREDIT -> MaterialTheme.colorScheme.onTertiaryContainer.copy(
103104
red = 0f,
104105
green = 0.51f,
105106
blue = 0.21f,
106107
)
107-
else -> Color.Black
108+
109+
else -> MaterialTheme.colorScheme.scrim
108110
},
109111
textAlign = TextAlign.End,
110112
),
@@ -195,12 +197,14 @@ fun TransactionItem(
195197
green = 0.51f,
196198
blue = 0.21f,
197199
)
200+
198201
TransactionType.DEBIT -> MaterialTheme.colorScheme.error.copy(
199202
red = 0.8f,
200203
green = 0f,
201204
blue = 0f,
202205
)
203-
else -> Color.Black
206+
207+
else -> MaterialTheme.colorScheme.scrim
204208
},
205209
textAlign = TextAlign.End,
206210
),

feature/accounts/src/commonMain/kotlin/org/mifospay/feature/accounts/AccountsScreen.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,9 @@ private fun StatusChip(label: String) {
652652
blue = 0.94f,
653653
)
654654
}
655-
656655
MifosSmallChip(
657656
label = label,
658657
containerColor = color,
659-
contentColor = Color.Black,
658+
contentColor = MaterialTheme.colorScheme.scrim,
660659
)
661660
}

0 commit comments

Comments
 (0)