Make PlayerBottomSheet stable
This commit is contained in:
@@ -12,7 +12,10 @@ import androidx.compose.foundation.layout.size
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
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.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
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.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.media3.common.Player
|
import androidx.media3.common.Player
|
||||||
import com.valentinilk.shimmer.ShimmerBounds
|
|
||||||
import com.valentinilk.shimmer.rememberShimmer
|
|
||||||
import it.vfsfitvnm.reordering.rememberReorderingState
|
import it.vfsfitvnm.reordering.rememberReorderingState
|
||||||
import it.vfsfitvnm.reordering.verticalDragAfterLongPressToReorder
|
import it.vfsfitvnm.reordering.verticalDragAfterLongPressToReorder
|
||||||
|
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||||
import it.vfsfitvnm.vimusic.R
|
import it.vfsfitvnm.vimusic.R
|
||||||
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
|
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
|
||||||
import it.vfsfitvnm.vimusic.ui.components.BottomSheetState
|
import it.vfsfitvnm.vimusic.ui.components.BottomSheetState
|
||||||
@@ -41,12 +43,12 @@ import it.vfsfitvnm.vimusic.utils.PlayerState
|
|||||||
@ExperimentalAnimationApi
|
@ExperimentalAnimationApi
|
||||||
@Composable
|
@Composable
|
||||||
fun CurrentPlaylistView(
|
fun CurrentPlaylistView(
|
||||||
player: Player?,
|
|
||||||
playerState: PlayerState?,
|
playerState: PlayerState?,
|
||||||
layoutState: BottomSheetState,
|
layoutState: BottomSheetState,
|
||||||
onGlobalRouteEmitted: () -> Unit,
|
onGlobalRouteEmitted: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
|
val player = LocalPlayerServiceBinder.current?.player
|
||||||
val hapticFeedback = LocalHapticFeedback.current
|
val hapticFeedback = LocalHapticFeedback.current
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
val colorPalette = LocalColorPalette.current
|
val colorPalette = LocalColorPalette.current
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import it.vfsfitvnm.route.RouteHandler
|
|||||||
import it.vfsfitvnm.route.empty
|
import it.vfsfitvnm.route.empty
|
||||||
import it.vfsfitvnm.route.rememberRoute
|
import it.vfsfitvnm.route.rememberRoute
|
||||||
import it.vfsfitvnm.vimusic.Database
|
import it.vfsfitvnm.vimusic.Database
|
||||||
|
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||||
import it.vfsfitvnm.vimusic.models.Song
|
import it.vfsfitvnm.vimusic.models.Song
|
||||||
import it.vfsfitvnm.vimusic.ui.components.BottomSheet
|
import it.vfsfitvnm.vimusic.ui.components.BottomSheet
|
||||||
import it.vfsfitvnm.vimusic.ui.components.BottomSheetState
|
import it.vfsfitvnm.vimusic.ui.components.BottomSheetState
|
||||||
@@ -45,7 +46,6 @@ import kotlinx.coroutines.withContext
|
|||||||
@ExperimentalAnimationApi
|
@ExperimentalAnimationApi
|
||||||
@Composable
|
@Composable
|
||||||
fun PlayerBottomSheet(
|
fun PlayerBottomSheet(
|
||||||
player: Player?,
|
|
||||||
playerState: PlayerState?,
|
playerState: PlayerState?,
|
||||||
layoutState: BottomSheetState,
|
layoutState: BottomSheetState,
|
||||||
song: Song?,
|
song: Song?,
|
||||||
@@ -55,6 +55,7 @@ fun PlayerBottomSheet(
|
|||||||
val colorPalette = LocalColorPalette.current
|
val colorPalette = LocalColorPalette.current
|
||||||
val typography = LocalTypography.current
|
val typography = LocalTypography.current
|
||||||
|
|
||||||
|
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
val lyricsRoute = rememberLyricsRoute()
|
val lyricsRoute = rememberLyricsRoute()
|
||||||
@@ -175,6 +176,8 @@ fun PlayerBottomSheet(
|
|||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
lyricsRoute {
|
lyricsRoute {
|
||||||
|
val player = LocalPlayerServiceBinder.current?.player
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
LyricsView(
|
LyricsView(
|
||||||
@@ -238,7 +241,6 @@ fun PlayerBottomSheet(
|
|||||||
|
|
||||||
host {
|
host {
|
||||||
CurrentPlaylistView(
|
CurrentPlaylistView(
|
||||||
player = player,
|
|
||||||
playerState = playerState,
|
playerState = playerState,
|
||||||
layoutState = layoutState,
|
layoutState = layoutState,
|
||||||
onGlobalRouteEmitted = onGlobalRouteEmitted,
|
onGlobalRouteEmitted = onGlobalRouteEmitted,
|
||||||
|
|||||||
@@ -624,7 +624,6 @@ fun PlayerView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerBottomSheet(
|
PlayerBottomSheet(
|
||||||
player = player,
|
|
||||||
playerState = playerState,
|
playerState = playerState,
|
||||||
layoutState = rememberBottomSheetState(64.dp, layoutState.upperBound - 128.dp),
|
layoutState = rememberBottomSheetState(64.dp, layoutState.upperBound - 128.dp),
|
||||||
onGlobalRouteEmitted = layoutState.collapse,
|
onGlobalRouteEmitted = layoutState.collapse,
|
||||||
|
|||||||
Reference in New Issue
Block a user