From 477cb445e30a320fd123b7875f51f8389b5ed30e Mon Sep 17 00:00:00 2001 From: Antoine Jaury Date: Fri, 9 Oct 2026 15:19:05 +0200 Subject: [PATCH] refactor: improve record list accessibility --- .../composeResources/values/strings.xml | 3 ++ .../ajaury/chombev/records/ui/RecordView.kt | 43 ++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/data/resources/src/commonMain/composeResources/values/strings.xml b/data/resources/src/commonMain/composeResources/values/strings.xml index 310f12e..8f52320 100644 --- a/data/resources/src/commonMain/composeResources/values/strings.xml +++ b/data/resources/src/commonMain/composeResources/values/strings.xml @@ -44,6 +44,9 @@ Commencer Fermer + écouter + Chapitre %1$d + Retour Phrase précédente Phrase suivante diff --git a/feature/records/src/commonMain/kotlin/bzh/ajaury/chombev/records/ui/RecordView.kt b/feature/records/src/commonMain/kotlin/bzh/ajaury/chombev/records/ui/RecordView.kt index 35007b9..12b2fb2 100644 --- a/feature/records/src/commonMain/kotlin/bzh/ajaury/chombev/records/ui/RecordView.kt +++ b/feature/records/src/commonMain/kotlin/bzh/ajaury/chombev/records/ui/RecordView.kt @@ -11,23 +11,42 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.clearAndSetSemantics +import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import bzh.ajaury.chombev.core.model.Phrase import bzh.ajaury.chombev.core.model.Record +import bzh.ajaury.chombev.resources.generated.resources.Res +import bzh.ajaury.chombev.resources.generated.resources.records_chapter_action_description +import bzh.ajaury.chombev.resources.generated.resources.records_chapter_number +import org.jetbrains.compose.resources.stringResource @Composable fun RecordView( record: Record, onClick: () -> Unit = {}, ) { + val chapterNumber = stringResource(Res.string.records_chapter_number, record.index) + val rowDescription = + listOfNotNull(chapterNumber, record.title.transcription, record.title.translation) + .joinToString(separator = ", ") + Row( modifier = Modifier .fillMaxWidth() - .clickable { onClick() } - .padding(16.dp), + .clickable( + role = Role.Button, + onClickLabel = stringResource(Res.string.records_chapter_action_description), + ) { + onClick() + }.padding(16.dp) + .clearAndSetSemantics { + contentDescription = rowDescription + }, verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp), ) { @@ -70,3 +89,23 @@ private fun RecordViewPreview() { onClick = {}, ) } + +@Preview +@Composable +private fun RecordViewWithoutTranslationPreview() { + RecordView( + record = + Record( + id = 1, + index = 1, + emoji = "🙏", + title = Phrase( + transcription = "Sample Record", + translation = null, + ), + audioResourcePath = "files/Chom_bev_01.ogg", + subtitleResourcePath = "files/Chom_bev_01_st_bzh.lrc", + ), + onClick = {}, + ) +}