refactor: improve record list accessibility

This commit is contained in:
Antoine Jaury
2026-10-09 15:27:19 +02:00
parent da9619b8fe
commit 477cb445e3
2 changed files with 44 additions and 2 deletions
@@ -44,6 +44,9 @@
<string name="onboarding_start">Commencer</string> <string name="onboarding_start">Commencer</string>
<string name="onboarding_close">Fermer</string> <string name="onboarding_close">Fermer</string>
<string name="records_chapter_action_description">écouter</string>
<string name="records_chapter_number">Chapitre %1$d</string>
<string name="player_back">Retour</string> <string name="player_back">Retour</string>
<string name="player_previous_sentence">Phrase précédente</string> <string name="player_previous_sentence">Phrase précédente</string>
<string name="player_next_sentence">Phrase suivante</string> <string name="player_next_sentence">Phrase suivante</string>
@@ -11,23 +11,42 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable 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.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.text.font.FontFamily
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import bzh.ajaury.chombev.core.model.Phrase import bzh.ajaury.chombev.core.model.Phrase
import bzh.ajaury.chombev.core.model.Record 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 @Composable
fun RecordView( fun RecordView(
record: Record, record: Record,
onClick: () -> Unit = {}, 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( Row(
modifier = modifier =
Modifier Modifier
.fillMaxWidth() .fillMaxWidth()
.clickable { onClick() } .clickable(
.padding(16.dp), role = Role.Button,
onClickLabel = stringResource(Res.string.records_chapter_action_description),
) {
onClick()
}.padding(16.dp)
.clearAndSetSemantics {
contentDescription = rowDescription
},
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
) { ) {
@@ -70,3 +89,23 @@ private fun RecordViewPreview() {
onClick = {}, 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 = {},
)
}