mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-11-04 10:13:59 +00:00
feat(player): add content descriptions for play, pause, and add to queue actions
This commit is contained in:
parent
76518a01a1
commit
8efcbd4af4
@ -230,6 +230,9 @@
|
|||||||
<string name="player_go_to_album">Go to album</string>
|
<string name="player_go_to_album">Go to album</string>
|
||||||
<string name="player_sleep_timer">Sleep timer</string>
|
<string name="player_sleep_timer">Sleep timer</string>
|
||||||
<string name="player_track_details">Track details</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_ignore">Ignore</string>
|
||||||
<string name="update_action_update">Update</string>
|
<string name="update_action_update">Update</string>
|
||||||
|
|||||||
@ -62,6 +62,11 @@ import dev.krtirtho.spotube.resources.iconsax.Iconsax
|
|||||||
import dev.krtirtho.spotube.resources.iconsax.IconsaxAddSquare
|
import dev.krtirtho.spotube.resources.iconsax.IconsaxAddSquare
|
||||||
import dev.krtirtho.spotube.resources.iconsax.IconsaxPause
|
import dev.krtirtho.spotube.resources.iconsax.IconsaxPause
|
||||||
import dev.krtirtho.spotube.resources.iconsax.IconsaxPlay
|
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)
|
@OptIn(ExperimentalSharedTransitionApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
@ -107,14 +112,16 @@ fun PlayableCard(
|
|||||||
) {
|
) {
|
||||||
val isHovered by interactionSource.collectIsHoveredAsState()
|
val isHovered by interactionSource.collectIsHoveredAsState()
|
||||||
this@Column.AnimatedVisibility(
|
this@Column.AnimatedVisibility(
|
||||||
visible = isHovered,
|
visible = isHovered || (isPlaying && onPlay != null),
|
||||||
enter = fadeIn(),
|
enter = fadeIn(),
|
||||||
exit = fadeOut()) {
|
exit = fadeOut()) {
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
modifier = Modifier.padding(4.dp)
|
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(
|
MillenniumIconButton(
|
||||||
onClick = onAddToQueue,
|
onClick = onAddToQueue,
|
||||||
modifier = Modifier.size(34.dp),
|
modifier = Modifier.size(34.dp),
|
||||||
@ -122,10 +129,11 @@ fun PlayableCard(
|
|||||||
) {
|
) {
|
||||||
MillenniumIcon(
|
MillenniumIcon(
|
||||||
imageVector = Iconsax.IconsaxAddSquare,
|
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 {
|
onPlay?.let {
|
||||||
MillenniumIconButton(
|
MillenniumIconButton(
|
||||||
onClick = onPlay,
|
onClick = onPlay,
|
||||||
@ -137,7 +145,12 @@ fun PlayableCard(
|
|||||||
imageVector = if (isPlaying) {
|
imageVector = if (isPlaying) {
|
||||||
Iconsax.IconsaxPause
|
Iconsax.IconsaxPause
|
||||||
} else Iconsax.IconsaxPlay,
|
} else Iconsax.IconsaxPlay,
|
||||||
contentDescription = "Play")
|
contentDescription = stringResource(
|
||||||
|
if (isPlaying) {
|
||||||
|
Res.string.player_pause_content_description
|
||||||
|
} else {
|
||||||
|
Res.string.player_play_content_description
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user