Skip to content

Commit

Permalink
fix: Accessibility issue on courseDashboard
Browse files Browse the repository at this point in the history
- added content description for views
fix: LEARNER-10021
  • Loading branch information
omerhabib26 committed Jun 3, 2024
1 parent c2684f9 commit 12d5f4d
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
},
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -758,7 +772,7 @@ private fun CollapsingLayoutPreview() {

suspend fun PointerInputScope.routePointerChangesTo(
onDown: (PointerInputChange) -> Unit = {},
onUp: (PointerInputChange) -> Unit = {}
onUp: (PointerInputChange) -> Unit = {},
) {
awaitEachGesture {
do {
Expand All @@ -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 {
Expand Down

0 comments on commit 12d5f4d

Please sign in to comment.