Tweak code

This commit is contained in:
vfsfitvnm
2022-06-13 11:47:24 +02:00
parent 3a6af404ab
commit 243b2e0244

View File

@@ -12,6 +12,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.drawWithCache import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.ColorFilter
@@ -82,12 +83,10 @@ fun PlayerView(
.graphicsLayer { .graphicsLayer {
alpha = 1f - (layoutState.progress * 16).coerceAtMost(1f) alpha = 1f - (layoutState.progress * 16).coerceAtMost(1f)
} }
.drawWithCache { .background(colorPalette.elevatedBackground)
.drawBehind {
val offset = 64.dp.toPx() val offset = 64.dp.toPx()
val x = ((size.width - offset) * player.progress) + offset
onDrawWithContent {
drawContent()
drawLine( drawLine(
color = colorPalette.text, color = colorPalette.text,
start = Offset( start = Offset(
@@ -95,14 +94,12 @@ fun PlayerView(
y = 1.dp.toPx() y = 1.dp.toPx()
), ),
end = Offset( end = Offset(
x = x, x = ((size.width - offset) * player.progress) + offset,
y = 1.dp.toPx() y = 1.dp.toPx()
), ),
strokeWidth = 2.dp.toPx() strokeWidth = 2.dp.toPx()
) )
} }
}
.background(colorPalette.elevatedBackground)
) { ) {
AsyncImage( AsyncImage(
model = "${player.mediaMetadata.artworkUri}-w$smallThumbnailSize-h$smallThumbnailSize", model = "${player.mediaMetadata.artworkUri}-w$smallThumbnailSize-h$smallThumbnailSize",