feat(player): add content descriptions for play, pause, and add to queue actions

This commit is contained in:
Kingkor Roy Tirtho 2026-10-13 13:06:22 +06:00
parent 76518a01a1
commit 8efcbd4af4
2 changed files with 21 additions and 5 deletions

View File

@ -230,6 +230,9 @@
<string name="player_go_to_album">Go to album</string>
<string name="player_sleep_timer">Sleep timer</string>
<string name="player_track_details">Track details</string>
<string name="player_play_content_description">Play</string>
<string name="player_pause_content_description">Pause</string>
<string name="player_add_to_queue_content_description">Add to queue</string>
<string name="update_action_ignore">Ignore</string>
<string name="update_action_update">Update</string>

View File

@ -62,6 +62,11 @@ import dev.krtirtho.spotube.resources.iconsax.Iconsax
import dev.krtirtho.spotube.resources.iconsax.IconsaxAddSquare
import dev.krtirtho.spotube.resources.iconsax.IconsaxPause
import dev.krtirtho.spotube.resources.iconsax.IconsaxPlay
import org.jetbrains.compose.resources.stringResource
import spotube.composeapp.generated.resources.Res
import spotube.composeapp.generated.resources.player_add_to_queue_content_description
import spotube.composeapp.generated.resources.player_pause_content_description
import spotube.composeapp.generated.resources.player_play_content_description
@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
@ -107,14 +112,16 @@ fun PlayableCard(
) {
val isHovered by interactionSource.collectIsHoveredAsState()
this@Column.AnimatedVisibility(
visible = isHovered,
visible = isHovered || (isPlaying && onPlay != null),
enter = fadeIn(),
exit = fadeOut()) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(4.dp)
) {
onAddToQueue?.let {
// While this collection is playing the play/pause toggle stays
// visible and the add-to-queue action is hidden entirely.
onAddToQueue?.takeIf { !isPlaying }?.let {
MillenniumIconButton(
onClick = onAddToQueue,
modifier = Modifier.size(34.dp),
@ -122,10 +129,11 @@ fun PlayableCard(
) {
MillenniumIcon(
imageVector = Iconsax.IconsaxAddSquare,
contentDescription = "Add to queue")
contentDescription = stringResource(
Res.string.player_add_to_queue_content_description))
}
Spacer(modifier = Modifier.height(8.dp))
}
Spacer(modifier = Modifier.height(8.dp))
onPlay?.let {
MillenniumIconButton(
onClick = onPlay,
@ -137,7 +145,12 @@ fun PlayableCard(
imageVector = if (isPlaying) {
Iconsax.IconsaxPause
} else Iconsax.IconsaxPlay,
contentDescription = "Play")
contentDescription = stringResource(
if (isPlaying) {
Res.string.player_pause_content_description
} else {
Res.string.player_play_content_description
}))
}
}
}