File tree Expand file tree Collapse file tree 3 files changed +25
-18
lines changed
course/src/main/java/org/openedx/course/presentation Expand file tree Collapse file tree 3 files changed +25
-18
lines changed Original file line number Diff line number Diff line change @@ -884,15 +884,15 @@ fun SubSectionUnitsTitle(
884884 onUnitsClick : () -> Unit ,
885885) {
886886 val textStyle = MaterialTheme .appTypography.titleMedium
887- val hasUnits = unitsCount > 0
887+ val hasMultipleUnits = unitsCount > 1
888888 var rowModifier = Modifier
889889 .fillMaxWidth()
890890 .padding(
891891 horizontal = 16 .dp,
892892 vertical = 8 .dp
893893 )
894894 .displayCutoutForLandscape()
895- if (hasUnits ) {
895+ if (hasMultipleUnits ) {
896896 rowModifier = rowModifier.noRippleClickable { onUnitsClick() }
897897 }
898898
@@ -912,7 +912,7 @@ fun SubSectionUnitsTitle(
912912 textAlign = TextAlign .Start
913913 )
914914
915- if (hasUnits ) {
915+ if (hasMultipleUnits ) {
916916 Icon (
917917 modifier = Modifier .rotate(if (unitsListShowed) 180f else 0f ),
918918 painter = painterResource(id = R .drawable.ic_course_arrow_down),
Original file line number Diff line number Diff line change @@ -281,21 +281,24 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta
281281
282282 binding.subSectionUnitsList.setContent {
283283 val unitBlocks by viewModel.subSectionUnitBlocks.collectAsState()
284- val selectedUnitIndex = unitBlocks.indexOfFirst { it.id == viewModel.unitId }
285- OpenEdXTheme {
286- SubSectionUnitsList (
287- unitBlocks = unitBlocks,
288- selectedUnitIndex = selectedUnitIndex
289- ) { index, unit ->
290- if (index != selectedUnitIndex) {
291- router.navigateToCourseContainer(
292- fm = requireActivity().supportFragmentManager,
293- courseId = viewModel.courseId,
294- unitId = unit.id,
295- mode = requireArguments().serializable(ARG_MODE )!!
296- )
297- } else {
298- handleUnitsClick()
284+ // If there is more than one unit in the section, show the list
285+ if (unitBlocks.size > 1 ) {
286+ val selectedUnitIndex = unitBlocks.indexOfFirst { it.id == viewModel.unitId }
287+ OpenEdXTheme {
288+ SubSectionUnitsList (
289+ unitBlocks = unitBlocks,
290+ selectedUnitIndex = selectedUnitIndex
291+ ) { index, unit ->
292+ if (index != selectedUnitIndex) {
293+ router.navigateToCourseContainer(
294+ fm = requireActivity().supportFragmentManager,
295+ courseId = viewModel.courseId,
296+ unitId = unit.id,
297+ mode = requireArguments().serializable(ARG_MODE )!!
298+ )
299+ } else {
300+ handleUnitsClick()
301+ }
299302 }
300303 }
301304 }
Original file line number Diff line number Diff line change @@ -138,6 +138,10 @@ class CourseUnitContainerViewModel(
138138 }
139139 _subSectionUnitBlocks .value =
140140 getSubSectionUnitBlocks(blocks, getSubSectionId(unitId))
141+
142+ if (_descendantsBlocks .value.isEmpty()) {
143+ _descendantsBlocks .value = listOf (block)
144+ }
141145 } else {
142146 setNextVerticalIndex()
143147 }
You can’t perform that action at this time.
0 commit comments