[a11y] Group device information and spell out the deviceId
This commit is contained in:
parent
773797fff8
commit
9f5acd24fa
2 changed files with 21 additions and 1 deletions
|
|
@ -18,6 +18,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.features.verifysession.impl.R
|
import io.element.android.features.verifysession.impl.R
|
||||||
|
|
@ -46,7 +47,8 @@ fun SessionDetailsView(
|
||||||
color = ElementTheme.colors.borderDisabled,
|
color = ElementTheme.colors.borderDisabled,
|
||||||
shape = RoundedCornerShape(8.dp)
|
shape = RoundedCornerShape(8.dp)
|
||||||
)
|
)
|
||||||
.padding(24.dp),
|
.padding(24.dp)
|
||||||
|
.semantics(mergeDescendants = true) {},
|
||||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
|
|
@ -76,6 +78,7 @@ fun SessionDetailsView(
|
||||||
label = stringResource(CommonStrings.common_device_id),
|
label = stringResource(CommonStrings.common_device_id),
|
||||||
text = deviceId.value,
|
text = deviceId.value,
|
||||||
modifier = Modifier.weight(5f),
|
modifier = Modifier.weight(5f),
|
||||||
|
spellText = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,26 @@ package io.element.android.libraries.designsystem.atomic.molecules
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
import androidx.compose.ui.semantics.semantics
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a label and a text in a column.
|
||||||
|
* @param label the label to display
|
||||||
|
* @param text the text to display
|
||||||
|
* @param modifier the modifier to apply to this layout
|
||||||
|
* @param spellText if true, the text will be spelled out in the content description for accessibility.
|
||||||
|
* Useful for deviceId for instance, that the screen reader will read as a list of letters instead of trying to read a
|
||||||
|
* word of random characters.
|
||||||
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun TextWithLabelMolecule(
|
fun TextWithLabelMolecule(
|
||||||
label: String,
|
label: String,
|
||||||
text: String,
|
text: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
spellText: Boolean = false,
|
||||||
) {
|
) {
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
Text(
|
Text(
|
||||||
|
|
@ -26,6 +38,11 @@ fun TextWithLabelMolecule(
|
||||||
color = ElementTheme.colors.textSecondary,
|
color = ElementTheme.colors.textSecondary,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.semantics {
|
||||||
|
if (spellText) {
|
||||||
|
contentDescription = text.toList().joinToString()
|
||||||
|
}
|
||||||
|
},
|
||||||
text = text,
|
text = text,
|
||||||
style = ElementTheme.typography.fontBodyMdRegular,
|
style = ElementTheme.typography.fontBodyMdRegular,
|
||||||
color = ElementTheme.colors.textPrimary,
|
color = ElementTheme.colors.textPrimary,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue