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