Skip to content

Commit

Permalink
fix: openedx theme breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan-arshad-dev committed Apr 18, 2024
1 parent 7b32a1d commit e59f589
Show file tree
Hide file tree
Showing 23 changed files with 152 additions and 114 deletions.
8 changes: 4 additions & 4 deletions auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ fun InputRegistrationField(
}
val isSingleLine = registrationField.type != RegistrationFieldType.TEXTAREA
val helperTextColor = if (registrationField.errorInstructions.isEmpty()) {
MaterialTheme.appColors.primary
MaterialTheme.appColors.textSecondary
} else if (isErrorShown) {
MaterialTheme.appColors.error
} else {
MaterialTheme.appColors.textFieldHint
MaterialTheme.appColors.textSecondary
}
val helperText = if (registrationField.errorInstructions.isEmpty()) {
registrationField.instructions
Expand Down Expand Up @@ -381,11 +381,11 @@ fun SelectableRegisterField(
onClick: (String, List<RegistrationField.Option>) -> Unit
) {
val helperTextColor = if (registrationField.errorInstructions.isEmpty()) {
MaterialTheme.appColors.primary
MaterialTheme.appColors.textSecondary
} else if (isErrorShown) {
MaterialTheme.appColors.error
} else {
MaterialTheme.appColors.textFieldHint
MaterialTheme.appColors.textSecondary
}
val helperText = if (registrationField.errorInstructions.isEmpty()) {
registrationField.instructions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal fun CheckboxField(
checked = checkedState,
colors = CheckboxDefaults.colors(
checkedColor = MaterialTheme.appColors.primary,
uncheckedColor = MaterialTheme.appColors.primary
uncheckedColor = MaterialTheme.appColors.textFieldText
),
onCheckedChange = {
checkedState = it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ internal fun SocialAuthView(
.testTag("btn_google_auth")
.padding(top = 24.dp)
.fillMaxWidth(),
backgroundColor = MaterialTheme.appColors.buttonSecondaryBackground,
borderColor = MaterialTheme.appColors.textFieldBorder,
textColor = Color.Black,
backgroundColor = MaterialTheme.appColors.authGoogleButtonBackground,
borderColor = MaterialTheme.appColors.primary,
textColor = Color.Unspecified,
onClick = {
onEvent(AuthType.GOOGLE)
}
Expand All @@ -62,8 +62,8 @@ internal fun SocialAuthView(
modifier = Modifier
.testTag("txt_google_auth")
.padding(start = 10.dp),
color = Color.Black,
text = stringResource(id = stringRes)
text = stringResource(id = stringRes),
color = MaterialTheme.appColors.primaryButtonBorderedText,
)
}
}
Expand All @@ -88,13 +88,13 @@ internal fun SocialAuthView(
Icon(
painter = painterResource(id = R.drawable.ic_auth_facebook),
contentDescription = null,
tint = MaterialTheme.appColors.onSecondary,
tint = MaterialTheme.appColors.primaryButtonText,
)
Text(
modifier = Modifier
.testTag("txt_facebook_auth")
.padding(start = 10.dp),
color = MaterialTheme.appColors.onSecondary,
color = MaterialTheme.appColors.primaryButtonText,
text = stringResource(id = stringRes)
)
}
Expand Down Expand Up @@ -126,7 +126,7 @@ internal fun SocialAuthView(
modifier = Modifier
.testTag("txt_microsoft_auth")
.padding(start = 10.dp),
color = MaterialTheme.appColors.onSecondary,
color = MaterialTheme.appColors.primaryButtonText,
text = stringResource(id = stringRes)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fun FeedbackDialog(
colors = TextFieldDefaults.outlinedTextFieldColors(
backgroundColor = MaterialTheme.appColors.cardViewBackground,
unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder,
textColor = MaterialTheme.appColors.textFieldHint
textColor = MaterialTheme.appColors.textFieldText
),
)

Expand Down Expand Up @@ -320,8 +320,8 @@ fun DefaultTextButton(
val textColor: Color
val backgroundColor: Color
if (isEnabled) {
textColor = MaterialTheme.appColors.buttonText
backgroundColor = MaterialTheme.appColors.buttonBackground
textColor = MaterialTheme.appColors.primaryButtonText
backgroundColor = MaterialTheme.appColors.primaryButtonBackground
} else {
textColor = MaterialTheme.appColors.inactiveButtonText
backgroundColor = MaterialTheme.appColors.inactiveButtonBackground
Expand All @@ -345,7 +345,6 @@ fun DefaultTextButton(
) {
Text(
text = text,
color = MaterialTheme.appColors.onSecondary,
style = MaterialTheme.appTypography.labelLarge
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fun TransparentTextButton(
) {
Text(
modifier = Modifier.testTag("txt_secondary"),
color = MaterialTheme.appColors.textPrimary,
color = MaterialTheme.appColors.textAccent,
style = MaterialTheme.appTypography.labelLarge,
text = text
)
Expand All @@ -292,7 +292,7 @@ fun DefaultTextButton(
.testTag("btn_primary")
.height(42.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.appColors.textPrimary
backgroundColor = MaterialTheme.appColors.primaryButtonBackground
),
elevation = null,
shape = MaterialTheme.appShapes.navigationButtonShape,
Expand All @@ -305,7 +305,7 @@ fun DefaultTextButton(
Text(
modifier = Modifier.testTag("txt_primary"),
text = text,
color = MaterialTheme.appColors.buttonText,
color = MaterialTheme.appColors.primaryButtonText,
style = MaterialTheme.appTypography.labelLarge
)
}
Expand Down Expand Up @@ -401,4 +401,4 @@ private fun AppUpgradeRecommendDialogPreview() {
onUpdateClick = {}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private fun QualityOption(
Text(
modifier = Modifier.testTag("txt_video_quality_description_${title.tagId()}"),
text = description,
color = MaterialTheme.appColors.textPrimary,
color = MaterialTheme.appColors.textSecondary,
style = MaterialTheme.appTypography.labelMedium
)
}
Expand Down
43 changes: 22 additions & 21 deletions core/src/main/java/org/openedx/core/ui/ComposeCommon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,20 @@ fun SearchBar(
}
},
colors = TextFieldDefaults.outlinedTextFieldColors(
textColor = MaterialTheme.appColors.textFieldText,
backgroundColor = MaterialTheme.appColors.textFieldBackground,
focusedBorderColor = MaterialTheme.appColors.textFieldBorder,
cursorColor = MaterialTheme.appColors.textFieldText,
leadingIconColor = MaterialTheme.appColors.textFieldText
textColor = MaterialTheme.appColors.textPrimary,
backgroundColor = if (isFocused) MaterialTheme.appColors.background else MaterialTheme.appColors.textFieldBackground,
focusedBorderColor = MaterialTheme.appColors.primary,
unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder,
cursorColor = MaterialTheme.appColors.primary,
leadingIconColor = MaterialTheme.appColors.textPrimary
),
placeholder = {
Text(
modifier = Modifier
.testTag("txt_search_placeholder")
.fillMaxWidth(),
text = label,
color = MaterialTheme.appColors.textFieldHint,
color = MaterialTheme.appColors.textSecondary,
style = MaterialTheme.appTypography.bodyMedium
)
},
Expand All @@ -240,7 +241,7 @@ fun SearchBar(
modifier = Modifier.padding(start = 16.dp),
imageVector = Icons.Filled.Search,
contentDescription = null,
tint = if (isFocused) MaterialTheme.appColors.textFieldText else MaterialTheme.appColors.textFieldHint
tint = if (isFocused) MaterialTheme.appColors.primary else MaterialTheme.appColors.onSurface
)
},
trailingIcon = {
Expand Down Expand Up @@ -310,18 +311,18 @@ fun SearchBarStateless(
}
},
colors = TextFieldDefaults.outlinedTextFieldColors(
textColor = MaterialTheme.appColors.textFieldText,
backgroundColor = MaterialTheme.appColors.textFieldBackground,
focusedBorderColor = MaterialTheme.appColors.textFieldBorder,
textColor = MaterialTheme.appColors.textPrimary,
backgroundColor = if (isFocused) MaterialTheme.appColors.background else MaterialTheme.appColors.textFieldBackground,
focusedBorderColor = MaterialTheme.appColors.primary,
unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder,
cursorColor = MaterialTheme.appColors.textFieldText,
leadingIconColor = MaterialTheme.appColors.textFieldText
cursorColor = MaterialTheme.appColors.primary,
leadingIconColor = MaterialTheme.appColors.textPrimary
),
placeholder = {
Text(
modifier = Modifier.fillMaxWidth(),
text = label,
color = MaterialTheme.appColors.textFieldText,
color = MaterialTheme.appColors.textSecondary,
style = MaterialTheme.appTypography.bodyMedium
)
},
Expand All @@ -330,7 +331,7 @@ fun SearchBarStateless(
modifier = Modifier.padding(start = 16.dp),
imageVector = Icons.Filled.Search,
contentDescription = null,
tint = if (isFocused) MaterialTheme.appColors.textFieldText else MaterialTheme.appColors.textFieldHint
tint = if (isFocused) MaterialTheme.appColors.primary else MaterialTheme.appColors.onSurface
)
},
trailingIcon = {
Expand Down Expand Up @@ -1022,8 +1023,8 @@ fun OpenEdXSecondaryButton(
text = text,
onClick = onClick,
enabled = enabled,
textColor = MaterialTheme.appColors.onSecondary,
backgroundColor = MaterialTheme.appColors.secondary,
textColor = MaterialTheme.appColors.primaryButtonText,
backgroundColor = MaterialTheme.appColors.secondaryButtonBackground,
content = content
)
}
Expand All @@ -1034,8 +1035,8 @@ fun OpenEdXButton(
text: String = "",
onClick: () -> Unit,
enabled: Boolean = true,
textColor: Color = MaterialTheme.appColors.onSecondary,
backgroundColor: Color = MaterialTheme.appColors.secondary,
textColor: Color = MaterialTheme.appColors.primaryButtonText,
backgroundColor: Color = MaterialTheme.appColors.primaryButtonBackground,
content: (@Composable RowScope.() -> Unit)? = null
) {
Button(
Expand Down Expand Up @@ -1076,9 +1077,9 @@ fun OpenEdXSecondaryOutlinedButton(
text = text,
onClick = onClick,
enabled = enabled,
textColor = MaterialTheme.appColors.secondary,
backgroundColor = MaterialTheme.appColors.onSecondary,
borderColor = MaterialTheme.appColors.buttonBorder,
textColor = MaterialTheme.appColors.secondaryButtonBorderedText,
backgroundColor = MaterialTheme.appColors.secondaryButtonBorderedBackground,
borderColor = MaterialTheme.appColors.secondaryButtonBorder,
content = content
)
}
Expand Down
15 changes: 11 additions & 4 deletions core/src/main/java/org/openedx/core/ui/theme/AppColors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ data class AppColors(
val textFieldText: Color,
val textFieldHint: Color,

val buttonBackground: Color,
val buttonSecondaryBackground: Color,
val buttonText: Color,
val primaryButtonBackground: Color,
val primaryButtonText: Color,
val primaryButtonBorder: Color,
val primaryButtonBorderedText: Color,

val secondaryButtonBackground: Color,
val secondaryButtonText: Color,
val secondaryButtonBorder: Color,
val secondaryButtonBorderedBackground: Color,
val secondaryButtonBorderedText: Color,

val cardViewBackground: Color,
val cardViewBorder: Color,
Expand All @@ -36,7 +43,6 @@ data class AppColors(
val info_variant: Color,
val onWarning: Color,
val onInfo: Color,
val buttonBorder: Color,

val rateStars: Color,
val inactiveButtonBackground: Color,
Expand All @@ -50,6 +56,7 @@ data class AppColors(
val datesSectionBarNextWeek: Color,
val datesSectionBarUpcoming: Color,

val authGoogleButtonBackground: Color,
val authFacebookButtonBackground: Color,
val authMicrosoftButtonBackground: Color,

Expand Down
34 changes: 24 additions & 10 deletions core/src/main/java/org/openedx/core/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ private val DarkColorPalette = AppColors(
textFieldText = dark_text_field_text,
textFieldHint = dark_text_field_hint,

buttonBackground = dark_button_background,
buttonSecondaryBackground = dark_button_secondary_background,
buttonText = dark_button_text,
primaryButtonBackground = dark_primary_button_background,
primaryButtonText = dark_primary_button_text,
primaryButtonBorder = dark_primary_button_border,
primaryButtonBorderedText = dark_primary_button_bordered_text,

secondaryButtonBackground = dark_secondary_button_background,
secondaryButtonText = dark_secondary_button_text,
secondaryButtonBorder = dark_secondary_button_border,
secondaryButtonBorderedBackground = dark_secondary_button_bordered_background,
secondaryButtonBorderedText = dark_secondary_button_bordered_text,

cardViewBackground = dark_card_view_background,
cardViewBorder = dark_card_view_border,
Expand All @@ -56,11 +63,10 @@ private val DarkColorPalette = AppColors(
info_variant = dark_info_variant,
onWarning = dark_onWarning,
onInfo = dark_onInfo,
buttonBorder = dark_button_border,

rateStars = dark_rate_stars,
inactiveButtonBackground = dark_inactive_button_background,
inactiveButtonText = dark_button_text,
inactiveButtonText = dark_primary_button_text,

accessGreen = dark_access_green,

Expand All @@ -70,6 +76,7 @@ private val DarkColorPalette = AppColors(
datesSectionBarNextWeek = dark_dates_section_bar_next_week,
datesSectionBarUpcoming = dark_dates_section_bar_upcoming,

authGoogleButtonBackground = dark_auth_google_button_background,
authFacebookButtonBackground = dark_auth_facebook_button_background,
authMicrosoftButtonBackground = dark_auth_microsoft_button_background,

Expand Down Expand Up @@ -109,9 +116,16 @@ private val LightColorPalette = AppColors(
textFieldText = light_text_field_text,
textFieldHint = light_text_field_hint,

buttonBackground = light_button_background,
buttonSecondaryBackground = light_button_secondary_background,
buttonText = light_button_text,
primaryButtonBackground = light_primary_button_background,
primaryButtonText = light_primary_button_text,
primaryButtonBorder = light_primary_button_border,
primaryButtonBorderedText = light_primary_button_bordered_text,

secondaryButtonBackground = light_secondary_button_background,
secondaryButtonText = light_secondary_button_text,
secondaryButtonBorder = light_secondary_button_border,
secondaryButtonBorderedBackground = light_secondary_button_bordered_background,
secondaryButtonBorderedText = light_secondary_button_bordered_text,

cardViewBackground = light_card_view_background,
cardViewBorder = light_card_view_border,
Expand All @@ -125,11 +139,10 @@ private val LightColorPalette = AppColors(
info_variant = light_info_variant,
onWarning = light_onWarning,
onInfo = light_onInfo,
buttonBorder = light_button_border,

rateStars = light_rate_stars,
inactiveButtonBackground = light_inactive_button_background,
inactiveButtonText = light_button_text,
inactiveButtonText = light_primary_button_text,

accessGreen = light_access_green,

Expand All @@ -139,6 +152,7 @@ private val LightColorPalette = AppColors(
datesSectionBarNextWeek = light_dates_section_bar_next_week,
datesSectionBarUpcoming = light_dates_section_bar_upcoming,

authGoogleButtonBackground = light_auth_google_button_background,
authFacebookButtonBackground = light_auth_facebook_button_background,
authMicrosoftButtonBackground = light_auth_microsoft_button_background,

Expand Down
Loading

0 comments on commit e59f589

Please sign in to comment.