Skip to content

Commit

Permalink
chore: Theme Improvements for Primary Course Card
Browse files Browse the repository at this point in the history
Fixes: LEARNER-10078
  • Loading branch information
HamzaIsrar12 committed Aug 19, 2024
1 parent 648640f commit 46c572b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 22 deletions.
10 changes: 8 additions & 2 deletions core/src/edx/org/openedx/core/ui/theme/Colors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ val light_course_home_header_shade = Color(0xFFBABABA)
val light_course_home_back_btn_background = light_surface
val light_settings_title_content = light_surface
val light_progress_bar_color = light_primary_button_background
val light_progress_bar_background_color = Color(0xFFCCD4E0)
val light_progress_bar_background_color = Color(0xFFE7E4DB)

val light_primary_card_caution_background = Color(0xFFF3F1ED)
val light_primary_card_info_background = Color(0xFFE7E4DB)


// Dark theme colors scheme
Expand Down Expand Up @@ -166,4 +169,7 @@ val dark_course_home_header_shade = Color(0xFF999999)
val dark_course_home_back_btn_background = Color.Black
val dark_settings_title_content = Color.White
val dark_progress_bar_color = dark_primary_button_background
val dark_progress_bar_background_color = Color(0xFF8E9BAE)
val dark_progress_bar_background_color = Color(0xFFE7E4DB)

val dark_primary_card_caution_background = Color(0xFF2D494E)
val dark_primary_card_info_background = Color(0xFF0E3639)
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fun UpgradeToAccessView(
primaryIcon = Icons.Filled.EmojiEvents
textColor = MaterialTheme.appColors.textDark
shape = RectangleShape
backgroundColor = textColor.copy(0.05f)
backgroundColor = MaterialTheme.appColors.primaryCardInfoBackground
secondaryIcon = {
Icon(
modifier = Modifier
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/java/org/openedx/core/ui/theme/AppColors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ data class AppColors(
val settingsTitleContent: Color,

val progressBarColor: Color,
val progressBarBackgroundColor: Color
val progressBarBackgroundColor: Color,

val primaryCardCautionBackground: Color,
val primaryCardInfoBackground: Color,
) {
val primary: Color get() = material.primary
val primaryVariant: Color get() = material.primaryVariant
Expand Down
10 changes: 8 additions & 2 deletions core/src/main/java/org/openedx/core/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ private val DarkColorPalette = AppColors(
settingsTitleContent = dark_settings_title_content,

progressBarColor = dark_progress_bar_color,
progressBarBackgroundColor = dark_progress_bar_background_color
progressBarBackgroundColor = dark_progress_bar_background_color,

primaryCardCautionBackground = dark_primary_card_caution_background,
primaryCardInfoBackground = dark_primary_card_info_background,
)

private val LightColorPalette = AppColors(
Expand Down Expand Up @@ -185,7 +188,10 @@ private val LightColorPalette = AppColors(
settingsTitleContent = light_settings_title_content,

progressBarColor = light_progress_bar_color,
progressBarBackgroundColor = light_progress_bar_background_color
progressBarBackgroundColor = light_progress_bar_background_color,

primaryCardCautionBackground = light_primary_card_caution_background,
primaryCardInfoBackground = light_primary_card_info_background,
)

val MaterialTheme.appColors: AppColors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,21 @@ private fun PrimaryCourseButtons(
if (!pastAssignments.isNullOrEmpty()) {
viewsList.add {
val nearestAssignment = pastAssignments.maxBy { it.date }
val title = if (pastAssignments.size == 1) nearestAssignment.title else null
val title = if (pastAssignments.size == 1) {
nearestAssignment.title
} else {
stringResource(R.string.dashboard_assignment_due_default)
}
AssignmentItem(
modifier = Modifier.clickable {
if (pastAssignments.size == 1) {
resumeBlockId(primaryCourse, nearestAssignment.blockId)
} else {
navigateToDates(primaryCourse)
}
},
modifier = Modifier
.background(MaterialTheme.appColors.primaryCardCautionBackground)
.clickable {
if (pastAssignments.size == 1) {
resumeBlockId(primaryCourse, nearestAssignment.blockId)
} else {
navigateToDates(primaryCourse)
}
},
painter = rememberVectorPainter(Icons.Default.Warning),
title = title,
info = pluralStringResource(
Expand All @@ -697,13 +703,20 @@ private fun PrimaryCourseButtons(
val nearestAssignment = futureAssignments.minBy { it.date }
val title = if (futureAssignments.size == 1) nearestAssignment.title else null
AssignmentItem(
modifier = Modifier.clickable {
if (futureAssignments.size == 1) {
resumeBlockId(primaryCourse, nearestAssignment.blockId)
} else {
navigateToDates(primaryCourse)
}
},
modifier = Modifier
.background(
if (!pastAssignments.isNullOrEmpty())
MaterialTheme.appColors.primaryCardInfoBackground
else
MaterialTheme.appColors.primaryCardCautionBackground
)
.clickable {
if (futureAssignments.size == 1) {
resumeBlockId(primaryCourse, nearestAssignment.blockId)
} else {
navigateToDates(primaryCourse)
}
},
painter = painterResource(id = CoreR.drawable.ic_core_chapter_icon),
title = title,
info = stringResource(
Expand Down Expand Up @@ -988,7 +1001,7 @@ private val mockCourse = EnrolledCourse(
certificate = Certificate(""),
mode = "mode",
isActive = true,
progress = Progress.DEFAULT_PROGRESS,
progress = Progress(4, 10),
courseStatus = CourseStatus("", emptyList(), "", "Unit name"),
courseAssignments = mockCourseAssignments,
course = EnrolledCourseData(
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<string name="dashboard_view_all_with_count">View All My Courses (%1$d)</string>
<string name="dashboard_view_all">View All</string>
<string name="dashboard_assignment_due" translatable="false">%1$s %2$s</string>
<string name="dashboard_assignment_due_default">View Assignments</string>
<string name="dashboard_course_filter_all">All</string>
<string name="dashboard_course_filter_in_progress">In Progress</string>
<string name="dashboard_course_filter_completed">Completed</string>
Expand Down

0 comments on commit 46c572b

Please sign in to comment.