From e0305d30b552766b783db8b7191612ac2d18fe80 Mon Sep 17 00:00:00 2001 From: droid Date: Thu, 14 Dec 2023 14:19:49 +0100 Subject: [PATCH] refactor: moved static colors to the Theme --- .../org/openedx/core/ui/theme/AppColors.kt | 4 ++++ .../java/org/openedx/core/ui/theme/Colors.kt | 6 +++++ .../java/org/openedx/core/ui/theme/Theme.kt | 8 +++++++ .../outline/CourseOutlineViewModel.kt | 2 +- .../container/CourseUnitContainerFragment.kt | 24 +++++-------------- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/org/openedx/core/ui/theme/AppColors.kt b/core/src/main/java/org/openedx/core/ui/theme/AppColors.kt index 317f7ea72..91cac0a67 100644 --- a/core/src/main/java/org/openedx/core/ui/theme/AppColors.kt +++ b/core/src/main/java/org/openedx/core/ui/theme/AppColors.kt @@ -47,6 +47,10 @@ data class AppColors( val authFacebookButtonBackground: Color, val authMicrosoftButtonBackground: Color, + + val unitHorizontalProgressCompleted: Color, + val unitHorizontalProgressSelected: Color, + val unitHorizontalProgressDefault: Color, ) { val primary: Color get() = material.primary val primaryVariant: Color get() = material.primaryVariant diff --git a/core/src/main/java/org/openedx/core/ui/theme/Colors.kt b/core/src/main/java/org/openedx/core/ui/theme/Colors.kt index c85b83ae9..44a78bca5 100644 --- a/core/src/main/java/org/openedx/core/ui/theme/Colors.kt +++ b/core/src/main/java/org/openedx/core/ui/theme/Colors.kt @@ -47,6 +47,9 @@ val light_dates_badge_due = Color(0xFF707070) val light_dates_badge_text_due = Color(0xFFFFFFFF) val light_auth_facebook_button_background = Color(0xFF0866FF) val light_auth_microsoft_button_background = Color(0xFA000000) +val light_unit_horizontal_progress_completed = Color(0xFF2EA171) +val light_unit_horizontal_progress_selected = Color(0xFFF0CB00) +val light_unit_horizontal_progress_default = Color(0xFFD6D3D1) val dark_primary = Color(0xFF5478F9) @@ -94,3 +97,6 @@ val dark_dates_badge_due = Color(0xFF707070) val dark_dates_badge_text_due = Color(0xFFFFFFFF) val dark_auth_facebook_button_background = Color(0xFF0866FF) val dark_auth_microsoft_button_background = Color(0xFA000000) +val dark_unit_horizontal_progress_completed = Color(0xFF2EA171) +val dark_unit_horizontal_progress_selected = Color(0xFFF0CB00) +val dark_unit_horizontal_progress_default = Color(0xFFD6D3D1) diff --git a/core/src/main/java/org/openedx/core/ui/theme/Theme.kt b/core/src/main/java/org/openedx/core/ui/theme/Theme.kt index 725a4be3d..da52d8da2 100644 --- a/core/src/main/java/org/openedx/core/ui/theme/Theme.kt +++ b/core/src/main/java/org/openedx/core/ui/theme/Theme.kt @@ -67,6 +67,10 @@ private val DarkColorPalette = AppColors( authFacebookButtonBackground = dark_auth_facebook_button_background, authMicrosoftButtonBackground = dark_auth_microsoft_button_background, + + unitHorizontalProgressCompleted = dark_unit_horizontal_progress_completed, + unitHorizontalProgressSelected = dark_unit_horizontal_progress_selected, + unitHorizontalProgressDefault = dark_unit_horizontal_progress_default, ) private val LightColorPalette = AppColors( @@ -126,6 +130,10 @@ private val LightColorPalette = AppColors( authFacebookButtonBackground = light_auth_facebook_button_background, authMicrosoftButtonBackground = light_auth_microsoft_button_background, + + unitHorizontalProgressCompleted = light_unit_horizontal_progress_completed, + unitHorizontalProgressSelected = light_unit_horizontal_progress_selected, + unitHorizontalProgressDefault = light_unit_horizontal_progress_default, ) val MaterialTheme.appColors: AppColors diff --git a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt index f1b1d7448..543832540 100644 --- a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt @@ -141,7 +141,7 @@ class CourseOutlineViewModel( _uiState.value = CourseOutlineUIState.CourseData( courseStructure = state.courseStructure, downloadedState = state.downloadedState, - resumeBlock = state.resumeBlock, + resumeComponent = state.resumeComponent, courseSections = courseSections, courseSectionsState = courseSectionsState, downloadsCount = downloadsCount diff --git a/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerFragment.kt index 7ad5bfb8e..397fcdcb0 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerFragment.kt @@ -11,7 +11,6 @@ import androidx.compose.runtime.* import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.os.bundleOf @@ -133,9 +132,9 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta HorizontalPageIndicator( blocks = viewModel.descendantsBlocks, selectedPage = index, - completedColor = Color(0xFF2EA171), - selectedColor = Color(0xFFF0CB00), - defaultColor = Color(0xFFD6D3D1) + completedColor = MaterialTheme.appColors.unitHorizontalProgressCompleted, + selectedColor = MaterialTheme.appColors.unitHorizontalProgressSelected, + defaultColor = MaterialTheme.appColors.unitHorizontalProgressDefault ) } } @@ -164,7 +163,7 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta binding.btnBack.setContent { val sectionsBlocks by viewModel.subSectionsBlocks.collectAsState() - val currentSection = sectionsBlocks.firstOrNull { it.id == blockId } + val currentSection = sectionsBlocks.firstOrNull { it.id == unitId } val title = if (currentSection == null) "" else viewModel.getModuleBlock(currentSection.id).displayName @@ -179,7 +178,7 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta if (viewModel.isCourseExpandableSectionsEnabled) { binding.unitSubSectionsTitle.setContent { val subSectionsBlocks by viewModel.subSectionsBlocks.collectAsState() - val currentSubSection = subSectionsBlocks.firstOrNull { it.id == blockId } + val currentSubSection = subSectionsBlocks.firstOrNull { it.id == unitId } val subSectionName = currentSubSection?.displayName ?: "" val blockShowed by viewModel.selectBlockDialogShowed.observeAsState() @@ -197,7 +196,7 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta binding.subSectionsBlocksList.setContent { val sectionsBlocks by viewModel.subSectionsBlocks.collectAsState() - val selectedIndex = sectionsBlocks.indexOfFirst { it.id == blockId } + val selectedIndex = sectionsBlocks.indexOfFirst { it.id == unitId } OpenEdXTheme { UnitSubSectionsList( sectionsBlocks = sectionsBlocks, @@ -355,17 +354,6 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta } } - private fun proceedToNextSection(nextBlock: Block) { - if (nextBlock.type.isContainer()) { - router.replaceCourseContainer( - requireActivity().supportFragmentManager, - nextBlock.id, - viewModel.courseId, - requireArguments().serializable(ARG_MODE)!! - ) - } - } - @Composable private fun NavigationBar() { OpenEdXTheme {