Make PlayerBottomSheet stable

This commit is contained in:
vfsfitvnm 2022-06-25 18:39:43 +02:00
parent ac26e61856
commit 85c37ae842
3 changed files with 10 additions and 7 deletions

View file

@ -12,7 +12,10 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@ -24,10 +27,9 @@ import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.media3.common.Player
import com.valentinilk.shimmer.ShimmerBounds
import com.valentinilk.shimmer.rememberShimmer
import it.vfsfitvnm.reordering.rememberReorderingState
import it.vfsfitvnm.reordering.verticalDragAfterLongPressToReorder
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
import it.vfsfitvnm.vimusic.ui.components.BottomSheetState
@ -41,12 +43,12 @@ import it.vfsfitvnm.vimusic.utils.PlayerState
@ExperimentalAnimationApi
@Composable
fun CurrentPlaylistView(
player: Player?,
playerState: PlayerState?,
layoutState: BottomSheetState,
onGlobalRouteEmitted: () -> Unit,
modifier: Modifier = Modifier,
) {
val player = LocalPlayerServiceBinder.current?.player
val hapticFeedback = LocalHapticFeedback.current
val density = LocalDensity.current
val colorPalette = LocalColorPalette.current

View file

@ -26,6 +26,7 @@ import it.vfsfitvnm.route.RouteHandler
import it.vfsfitvnm.route.empty
import it.vfsfitvnm.route.rememberRoute
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.models.Song
import it.vfsfitvnm.vimusic.ui.components.BottomSheet
import it.vfsfitvnm.vimusic.ui.components.BottomSheetState
@ -45,7 +46,6 @@ import kotlinx.coroutines.withContext
@ExperimentalAnimationApi
@Composable
fun PlayerBottomSheet(
player: Player?,
playerState: PlayerState?,
layoutState: BottomSheetState,
song: Song?,
@ -55,6 +55,7 @@ fun PlayerBottomSheet(
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
val coroutineScope = rememberCoroutineScope()
val lyricsRoute = rememberLyricsRoute()
@ -175,6 +176,8 @@ fun PlayerBottomSheet(
.fillMaxSize()
) {
lyricsRoute {
val player = LocalPlayerServiceBinder.current?.player
val context = LocalContext.current
LyricsView(
@ -238,7 +241,6 @@ fun PlayerBottomSheet(
host {
CurrentPlaylistView(
player = player,
playerState = playerState,
layoutState = layoutState,
onGlobalRouteEmitted = onGlobalRouteEmitted,

View file

@ -624,7 +624,6 @@ fun PlayerView(
}
PlayerBottomSheet(
player = player,
playerState = playerState,
layoutState = rememberBottomSheetState(64.dp, layoutState.upperBound - 128.dp),
onGlobalRouteEmitted = layoutState.collapse,