From bbc981d5d2da94843c3a95a7795151265f728457 Mon Sep 17 00:00:00 2001 From: "omer.habib" Date: Mon, 3 Jun 2024 19:52:07 +0500 Subject: [PATCH] fix: Accessibility issue on courseDashboard - added content description for views fix: LEARNER-10021 --- .../container/CollapsingLayout.kt | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/course/src/main/java/org/openedx/course/presentation/container/CollapsingLayout.kt b/course/src/main/java/org/openedx/course/presentation/container/CollapsingLayout.kt index 64ba858d8..08f6cf96a 100644 --- a/course/src/main/java/org/openedx/course/presentation/container/CollapsingLayout.kt +++ b/course/src/main/java/org/openedx/course/presentation/container/CollapsingLayout.kt @@ -53,6 +53,7 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Devices import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Density @@ -64,6 +65,7 @@ import androidx.compose.ui.unit.dp import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import org.openedx.core.R import org.openedx.core.ui.RoundTabsBar import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.rememberWindowSize @@ -104,7 +106,8 @@ internal fun CollapsingLayout( val factor = if (rawFactor.isNaN() || rawFactor < 0) 0f else rawFactor val blurImagePadding = 40.dp val blurImagePaddingPx = with(localDensity) { blurImagePadding.toPx() } - val toolbarOffset = (offset.value + backgroundImageHeight.floatValue - blurImagePaddingPx).roundToInt() + val toolbarOffset = + (offset.value + backgroundImageHeight.floatValue - blurImagePaddingPx).roundToInt() val imageStartY = (backgroundImageHeight.floatValue - blurImagePaddingPx) * 0.5f val imageOffsetY = -(offset.value + imageStartY) val toolbarBackgroundOffset = if (toolbarOffset >= 0) { @@ -393,7 +396,12 @@ private fun CollapsingLayoutTablet( Box( modifier = Modifier - .offset { IntOffset(x = 0, y = (backgroundImageHeight.value + expandedTopHeight.value).roundToInt()) } + .offset { + IntOffset( + x = 0, + y = (backgroundImageHeight.value + expandedTopHeight.value).roundToInt() + ) + } .onSizeChanged { size -> navigationHeight.value = size.height.toFloat() }, @@ -516,7 +524,7 @@ private fun CollapsingLayoutMobile( }, imageVector = Icons.AutoMirrored.Filled.ArrowBack, tint = MaterialTheme.appColors.textPrimary, - contentDescription = null + contentDescription = stringResource(id = R.string.core_accessibility_btn_back) ) Spacer(modifier = Modifier.width(8.dp)) Box( @@ -679,7 +687,7 @@ private fun CollapsingLayoutMobile( }, imageVector = Icons.AutoMirrored.Filled.ArrowBack, tint = MaterialTheme.appColors.textPrimary, - contentDescription = null + contentDescription = stringResource(id = R.string.core_accessibility_btn_back) ) Spacer(modifier = Modifier.width(8.dp)) Box( @@ -721,8 +729,14 @@ private fun CollapsingLayoutMobile( @OptIn(ExperimentalFoundationApi::class) @Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) -@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO, device = "spec:parent=pixel_5,orientation=landscape") -@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES, device = "spec:parent=pixel_5,orientation=landscape") +@Preview( + uiMode = Configuration.UI_MODE_NIGHT_NO, + device = "spec:parent=pixel_5,orientation=landscape" +) +@Preview( + uiMode = Configuration.UI_MODE_NIGHT_YES, + device = "spec:parent=pixel_5,orientation=landscape" +) @Preview(device = Devices.NEXUS_9, uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(device = Devices.NEXUS_9, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable @@ -758,7 +772,7 @@ private fun CollapsingLayoutPreview() { suspend fun PointerInputScope.routePointerChangesTo( onDown: (PointerInputChange) -> Unit = {}, - onUp: (PointerInputChange) -> Unit = {} + onUp: (PointerInputChange) -> Unit = {}, ) { awaitEachGesture { do { @@ -776,7 +790,7 @@ suspend fun PointerInputScope.routePointerChangesTo( @Immutable data class PixelAlignment( val offsetX: Float, - val offsetY: Float + val offsetY: Float, ) : Alignment { override fun align(size: IntSize, space: IntSize, layoutDirection: LayoutDirection): IntOffset {