diff --git a/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt b/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt index 4cffb3d22..94d3455d2 100644 --- a/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt +++ b/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt @@ -982,6 +982,7 @@ fun TextIcon( painter: Painter, color: Color, textStyle: TextStyle = MaterialTheme.appTypography.bodySmall, + iconModifier: Modifier = Modifier, onClick: (() -> Unit)? = null, ) { val modifier = if (onClick == null) { @@ -996,7 +997,8 @@ fun TextIcon( ) { Text(text = text, color = color, style = textStyle) Icon( - modifier = Modifier.size((textStyle.fontSize.value + 4).dp), + modifier = iconModifier + .size((textStyle.fontSize.value + 4).dp), painter = painter, contentDescription = null, tint = color diff --git a/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt b/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt index 3a0bfe50a..32c48b433 100644 --- a/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt +++ b/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt @@ -8,27 +8,15 @@ import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.view.LayoutInflater import android.view.ViewGroup -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.material.Card -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.foundation.layout.* +import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Close import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.rotate import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.ViewCompositionStrategy @@ -78,6 +66,9 @@ class ChapterEndFragmentDialog : DialogFragment() { ChapterEndDialogScreen( sectionName = requireArguments().getString(ARG_SECTION_NAME) ?: "", nextSectionName = requireArguments().getString(ARG_NEXT_SECTION_NAME) ?: "", + isVerticalNavigation = requireArguments().getBoolean( + ARG_IS_VERTICAL_NAVIGATION + ), onBackButtonClick = { dismiss() listener?.onDismiss() @@ -122,14 +113,17 @@ class ChapterEndFragmentDialog : DialogFragment() { companion object { private const val ARG_SECTION_NAME = "sectionName" private const val ARG_NEXT_SECTION_NAME = "nexSectionName" + private const val ARG_IS_VERTICAL_NAVIGATION = "isVerticalNavigation" fun newInstance( sectionName: String, - nextSectionName: String + nextSectionName: String, + isVerticalNavigation: Boolean ): ChapterEndFragmentDialog { val dialog = ChapterEndFragmentDialog() dialog.arguments = bundleOf( ARG_SECTION_NAME to sectionName, - ARG_NEXT_SECTION_NAME to nextSectionName + ARG_NEXT_SECTION_NAME to nextSectionName, + ARG_IS_VERTICAL_NAVIGATION to isVerticalNavigation ) return dialog } @@ -145,6 +139,7 @@ interface DialogListener { private fun ChapterEndDialogScreen( sectionName: String, nextSectionName: String, + isVerticalNavigation: Boolean, onBackButtonClick: () -> Unit, onProceedButtonClick: () -> Unit, onCancelButtonClick: () -> Unit @@ -206,7 +201,8 @@ private fun ChapterEndDialogScreen( text = stringResource(id = R.string.course_next_section), painter = painterResource(org.openedx.core.R.drawable.core_ic_forward), color = MaterialTheme.appColors.buttonText, - textStyle = MaterialTheme.appTypography.labelLarge + textStyle = MaterialTheme.appTypography.labelLarge, + iconModifier = Modifier.rotate(if (isVerticalNavigation) 90f else 0f) ) }, onClick = onProceedButtonClick @@ -366,6 +362,7 @@ fun ChapterEndDialogScreenPreview() { ChapterEndDialogScreen( sectionName = "Section", nextSectionName = "Section2", + isVerticalNavigation = true, onBackButtonClick = {}, onProceedButtonClick = {}, onCancelButtonClick = {} diff --git a/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt b/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt index 7b4e3275b..a791da2d7 100644 --- a/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt +++ b/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt @@ -310,6 +310,7 @@ fun NavigationUnitsButtons( nextButtonText: String, hasPrevBlock: Boolean, hasNextBlock: Boolean, + isVerticalNavigation: Boolean, onPrevClick: () -> Unit, onNextClick: () -> Unit ) { @@ -362,6 +363,7 @@ fun NavigationUnitsButtons( ) Spacer(Modifier.width(8.dp)) Icon( + modifier = Modifier.rotate(if (isVerticalNavigation) 0f else -90f), painter = painterResource(id = org.openedx.core.R.drawable.core_ic_up), contentDescription = null, tint = MaterialTheme.appColors.primary @@ -391,6 +393,7 @@ fun NavigationUnitsButtons( ) Spacer(Modifier.width(8.dp)) Icon( + modifier = Modifier.rotate(if (isVerticalNavigation || !hasNextBlock) 0f else -90f), painter = nextButtonIcon, contentDescription = null, tint = MaterialTheme.appColors.buttonText @@ -921,6 +924,7 @@ private fun NavigationUnitsButtonsOnlyNextButtonPreview() { windowSize = WindowSize(WindowType.Compact, WindowType.Compact), hasPrevBlock = true, hasNextBlock = true, + isVerticalNavigation = true, nextButtonText = "Next", onPrevClick = {}) {} } @@ -935,6 +939,7 @@ private fun NavigationUnitsButtonsOnlyFinishButtonPreview() { windowSize = WindowSize(WindowType.Compact, WindowType.Compact), hasPrevBlock = true, hasNextBlock = false, + isVerticalNavigation = true, nextButtonText = "Finish", onPrevClick = {}) {} } @@ -949,6 +954,7 @@ private fun NavigationUnitsButtonsWithFinishPreview() { windowSize = WindowSize(WindowType.Compact, WindowType.Compact), hasPrevBlock = true, hasNextBlock = false, + isVerticalNavigation = true, nextButtonText = "Finish", onPrevClick = {}) {} } @@ -963,6 +969,7 @@ private fun NavigationUnitsButtonsWithNextPreview() { windowSize = WindowSize(WindowType.Compact, WindowType.Compact), hasPrevBlock = true, hasNextBlock = true, + isVerticalNavigation = true, nextButtonText = "Next", onPrevClick = {}) {} } 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 91339a81f..9bee43fe6 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 @@ -260,7 +260,9 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta } private fun initViewPager() { - binding.viewPager.orientation = ViewPager2.ORIENTATION_VERTICAL + if (!viewModel.isCourseUnitProgressEnabled) { + binding.viewPager.orientation = ViewPager2.ORIENTATION_VERTICAL + } binding.viewPager.offscreenPageLimit = 1 adapter = CourseUnitContainerAdapter(this, viewModel.getUnitBlocks(), viewModel) binding.viewPager.adapter = adapter @@ -301,7 +303,8 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta val nextVerticalBlock = viewModel.getNextVerticalBlock() val dialog = ChapterEndFragmentDialog.newInstance( currentVerticalBlock?.displayName ?: "", - nextVerticalBlock?.displayName ?: "" + nextVerticalBlock?.displayName ?: "", + !viewModel.isCourseUnitProgressEnabled ) currentVerticalBlock?.let { viewModel.finishVerticalClickedEvent( @@ -379,6 +382,7 @@ class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_conta hasPrevBlock = hasPrevBlock, nextButtonText = nextButtonText, hasNextBlock = hasNextBlock, + isVerticalNavigation = !viewModel.isCourseUnitProgressEnabled, onPrevClick = { handlePrevClick { next, hasPrev, hasNext -> nextButtonText = next