-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Handle units with no descendants #29
Conversation
- Handle UI if an unit has zero descendant - show unit list if a subsection have more then 1 units.
@@ -852,7 +852,7 @@ fun SubSectionUnitsTitle( | |||
onUnitsClick: () -> Unit, | |||
) { | |||
val textStyle = MaterialTheme.appTypography.titleMedium | |||
val hasUnits = unitsCount > 0 | |||
val hasUnits = unitsCount > 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to rename this with hasMultipleUnits
.
if (unitBlocks.size > 1) { | ||
val selectedUnitIndex = unitBlocks.indexOfFirst { it.id == viewModel.unitId } | ||
OpenEdXTheme { | ||
SubSectionUnitsList( | ||
unitBlocks = unitBlocks, | ||
selectedUnitIndex = selectedUnitIndex | ||
) { index, unit -> | ||
if (index != selectedUnitIndex) { | ||
router.navigateToCourseContainer( | ||
fm = requireActivity().supportFragmentManager, | ||
courseId = viewModel.courseId, | ||
unitId = unit.id, | ||
mode = requireArguments().serializable(ARG_MODE)!! | ||
) | ||
|
||
} else { | ||
handleUnitsClick() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this code-change we can achieve the required error screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code change restricts this view to trigger only when it has multiple units.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition deserves some doc string.
Description: