Video player: Iterate on Play/Pause button
This commit is contained in:
parent
3175d9242a
commit
8db489f9d5
1 changed files with 19 additions and 3 deletions
|
|
@ -11,10 +11,13 @@ import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.widthIn
|
import androidx.compose.foundation.layout.widthIn
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableFloatStateOf
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
|
|
@ -63,8 +66,21 @@ fun MediaPlayerControllerView(
|
||||||
.widthIn(max = 480.dp),
|
.widthIn(max = 480.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
IconButton(
|
val bgColor = if (state.isPlaying) {
|
||||||
onClick = onTogglePlay,
|
ElementTheme.colors.bgCanvasDefault
|
||||||
|
} else {
|
||||||
|
ElementTheme.colors.textPrimary
|
||||||
|
}
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable { onTogglePlay() }
|
||||||
|
.size(36.dp)
|
||||||
|
.background(
|
||||||
|
color = bgColor,
|
||||||
|
shape = CircleShape,
|
||||||
|
)
|
||||||
|
.padding(8.dp),
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
) {
|
) {
|
||||||
if (state.isPlaying) {
|
if (state.isPlaying) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|
@ -75,7 +91,7 @@ fun MediaPlayerControllerView(
|
||||||
} else {
|
} else {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = CompoundIcons.PlaySolid(),
|
imageVector = CompoundIcons.PlaySolid(),
|
||||||
tint = ElementTheme.colors.iconPrimary,
|
tint = ElementTheme.colors.iconOnSolidPrimary,
|
||||||
contentDescription = stringResource(CommonStrings.a11y_play)
|
contentDescription = stringResource(CommonStrings.a11y_play)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue