From 243b2e0244adc1268cf77c49d870891c727b0644 Mon Sep 17 00:00:00 2001 From: vfsfitvnm Date: Mon, 13 Jun 2022 11:47:24 +0200 Subject: [PATCH] Tweak code --- .../vfsfitvnm/vimusic/ui/views/PlayerView.kt | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/views/PlayerView.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/views/PlayerView.kt index aebc378..1c49894 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/views/PlayerView.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/views/PlayerView.kt @@ -12,6 +12,7 @@ import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.draw.drawWithCache import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.ColorFilter @@ -82,27 +83,23 @@ fun PlayerView( .graphicsLayer { alpha = 1f - (layoutState.progress * 16).coerceAtMost(1f) } - .drawWithCache { - val offset = 64.dp.toPx() - val x = ((size.width - offset) * player.progress) + offset - - onDrawWithContent { - drawContent() - drawLine( - color = colorPalette.text, - start = Offset( - x = offset, - y = 1.dp.toPx() - ), - end = Offset( - x = x, - y = 1.dp.toPx() - ), - strokeWidth = 2.dp.toPx() - ) - } - } .background(colorPalette.elevatedBackground) + .drawBehind { + val offset = 64.dp.toPx() + + drawLine( + color = colorPalette.text, + start = Offset( + x = offset, + y = 1.dp.toPx() + ), + end = Offset( + x = ((size.width - offset) * player.progress) + offset, + y = 1.dp.toPx() + ), + strokeWidth = 2.dp.toPx() + ) + } ) { AsyncImage( model = "${player.mediaMetadata.artworkUri}-w$smallThumbnailSize-h$smallThumbnailSize",