refactor: improve accessibility for previous/next buttons in player
This commit is contained in:
+14
-1
@@ -8,10 +8,13 @@ import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.onClick
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import bzh.ajaury.chombev.resources.generated.resources.Res
|
||||
import bzh.ajaury.chombev.resources.generated.resources.player_next_sentence
|
||||
import bzh.ajaury.chombev.resources.generated.resources.player_next_sentence_action_label
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
|
||||
@Composable
|
||||
@@ -20,8 +23,18 @@ fun NextButton(
|
||||
modifier: Modifier = Modifier,
|
||||
onNextSentenceClicked: () -> Unit = {},
|
||||
) {
|
||||
val actionLabel = stringResource(Res.string.player_next_sentence_action_label)
|
||||
IconButton(
|
||||
modifier = modifier.size(60.dp),
|
||||
modifier = modifier
|
||||
.size(60.dp)
|
||||
.semantics {
|
||||
if (canGoToNextSentence) {
|
||||
onClick(label = actionLabel) {
|
||||
onNextSentenceClicked()
|
||||
true
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled = canGoToNextSentence,
|
||||
onClick = onNextSentenceClicked,
|
||||
) {
|
||||
|
||||
+14
-1
@@ -8,10 +8,13 @@ import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.onClick
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import bzh.ajaury.chombev.resources.generated.resources.Res
|
||||
import bzh.ajaury.chombev.resources.generated.resources.player_previous_sentence
|
||||
import bzh.ajaury.chombev.resources.generated.resources.player_previous_sentence_action_label
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
|
||||
@Composable
|
||||
@@ -20,8 +23,18 @@ fun PreviousButton(
|
||||
modifier: Modifier = Modifier,
|
||||
onPreviousSentenceClicked: () -> Unit = {},
|
||||
) {
|
||||
val actionLabel = stringResource(Res.string.player_previous_sentence_action_label)
|
||||
IconButton(
|
||||
modifier = modifier.size(60.dp),
|
||||
modifier = modifier
|
||||
.size(60.dp)
|
||||
.semantics {
|
||||
if (canGoToPreviousSentence) {
|
||||
onClick(label = actionLabel) {
|
||||
onPreviousSentenceClicked()
|
||||
true
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled = canGoToPreviousSentence,
|
||||
onClick = onPreviousSentenceClicked,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user