Rework play icon UI

This commit is contained in:
vfsfitvnm 2022-07-01 22:53:21 +02:00
parent 15f99304bd
commit e34c575441
3 changed files with 21 additions and 34 deletions

View file

@ -9,6 +9,7 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.material.ripple.rememberRipple
@ -554,31 +555,35 @@ fun PlayerView(
modifier = Modifier
.clickable(onClick = player::seekToPrevious)
.padding(horizontal = 16.dp)
.size(32.dp)
.size(28.dp)
)
when {
playerState.playbackState == Player.STATE_ENDED || !playerState.playWhenReady -> Image(
painter = painterResource(R.drawable.play_circle),
contentDescription = null,
colorFilter = ColorFilter.tint(colorPalette.text),
modifier = Modifier
.clickable {
val isPaused = playerState.playbackState == Player.STATE_ENDED || !playerState.playWhenReady
Box(
modifier = Modifier
.padding(horizontal = 8.dp)
.clickable {
if (isPaused) {
if (player.playbackState == Player.STATE_IDLE) {
player.prepare()
}
player.play()
} else {
player.pause()
}
.size(64.dp)
)
else -> Image(
painter = painterResource(R.drawable.pause_circle),
}
.background(color = colorPalette.text, shape = CircleShape)
.size(64.dp)
) {
Image(
painter = painterResource(if (isPaused) R.drawable.play else R.drawable.pause),
contentDescription = null,
colorFilter = ColorFilter.tint(colorPalette.text),
colorFilter = ColorFilter.tint(colorPalette.background),
modifier = Modifier
.clickable(onClick = player::pause)
.size(64.dp)
.align(Alignment.Center)
.size(28.dp)
)
}
@ -589,7 +594,7 @@ fun PlayerView(
modifier = Modifier
.clickable(onClick = player::seekToNext)
.padding(horizontal = 16.dp)
.size(32.dp)
.size(28.dp)
)
Image(

View file

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:fillColor="#FF000000"
android:pathData="M256,48C141.31,48 48,141.31 48,256s93.31,208 208,208 208,-93.31 208,-208S370.69,48 256,48zM224,320a16,16 0,0 1,-32 0L192,192a16,16 0,0 1,32 0zM320,320a16,16 0,0 1,-32 0L288,192a16,16 0,0 1,32 0z"/>
</vector>

View file

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:fillColor="#FF000000"
android:pathData="M256,48C141.31,48 48,141.31 48,256s93.31,208 208,208 208,-93.31 208,-208S370.69,48 256,48zM330.77,265.3l-114.45,69.14a10.78,10.78 0,0 1,-16.32 -9.31L200,186.87a10.78,10.78 0,0 1,16.32 -9.31l114.45,69.14a10.89,10.89 0,0 1,0 18.6z"/>
</vector>