Skip to content

Commit

Permalink
refactor: moved static colors to the Theme
Browse files Browse the repository at this point in the history
  • Loading branch information
dixidroid committed Dec 14, 2023
1 parent c9f6c41 commit e0305d3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/org/openedx/core/ui/theme/AppColors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/org/openedx/core/ui/theme/Colors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
8 changes: 8 additions & 0 deletions core/src/main/java/org/openedx/core/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
}
}
Expand Down Expand Up @@ -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

Expand All @@ -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()

Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e0305d3

Please sign in to comment.