Add Dimensions class
This commit is contained in:
@@ -37,8 +37,10 @@ import it.vfsfitvnm.vimusic.ui.components.BottomSheetState
|
||||
import it.vfsfitvnm.vimusic.ui.components.MusicBars
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.QueuedMediaItemMenu
|
||||
import it.vfsfitvnm.vimusic.ui.screens.SmallSongItemShimmer
|
||||
import it.vfsfitvnm.vimusic.ui.styling.Dimensions
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LightColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.px
|
||||
import it.vfsfitvnm.vimusic.utils.PlayerState
|
||||
|
||||
|
||||
@@ -52,14 +54,9 @@ fun CurrentPlaylistView(
|
||||
) {
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
val hapticFeedback = LocalHapticFeedback.current
|
||||
val density = LocalDensity.current
|
||||
val colorPalette = LocalColorPalette.current
|
||||
|
||||
val thumbnailSize = remember {
|
||||
density.run {
|
||||
54.dp.roundToPx()
|
||||
}
|
||||
}
|
||||
val thumbnailSize = Dimensions.thumbnails.song.px
|
||||
|
||||
val isPaused by derivedStateOf {
|
||||
playerState?.playbackState == Player.STATE_ENDED || playerState?.playWhenReady == false
|
||||
@@ -119,7 +116,7 @@ fun CurrentPlaylistView(
|
||||
color = Color.Black.copy(alpha = 0.25f),
|
||||
shape = ThumbnailRoundness.shape
|
||||
)
|
||||
.size(54.dp)
|
||||
.size(Dimensions.thumbnails.song)
|
||||
) {
|
||||
if (isPaused) {
|
||||
Image(
|
||||
@@ -175,7 +172,7 @@ fun CurrentPlaylistView(
|
||||
) {
|
||||
repeat(3) { index ->
|
||||
SmallSongItemShimmer(
|
||||
thumbnailSizeDp = 54.dp,
|
||||
thumbnailSizeDp = Dimensions.thumbnails.song,
|
||||
modifier = Modifier
|
||||
.alpha(1f - index * 0.125f)
|
||||
.fillMaxWidth()
|
||||
|
||||
@@ -27,6 +27,7 @@ import it.vfsfitvnm.vimusic.ui.components.BottomSheet
|
||||
import it.vfsfitvnm.vimusic.ui.components.BottomSheetState
|
||||
import it.vfsfitvnm.vimusic.ui.components.HorizontalTabPager
|
||||
import it.vfsfitvnm.vimusic.ui.components.rememberTabPagerState
|
||||
import it.vfsfitvnm.vimusic.ui.styling.Dimensions
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||
import it.vfsfitvnm.vimusic.utils.PlayerState
|
||||
@@ -60,7 +61,7 @@ fun PlayerBottomSheet(
|
||||
|
||||
BottomSheet(
|
||||
state = layoutState,
|
||||
peekHeight = 128.dp,
|
||||
peekHeight = Dimensions.playerBottomSheetPeekHeight,
|
||||
elevation = 16.dp,
|
||||
shape = RoundedCornerShape(topStart = 8.dp, topEnd = 8.dp),
|
||||
handleOutsideInteractionsWhenExpanded = true,
|
||||
|
||||
@@ -25,9 +25,7 @@ import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -45,9 +43,7 @@ import it.vfsfitvnm.vimusic.query
|
||||
import it.vfsfitvnm.vimusic.ui.components.*
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.LoadingOrError
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.QueuedMediaItemMenu
|
||||
import it.vfsfitvnm.vimusic.ui.styling.BlackColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||
import it.vfsfitvnm.vimusic.ui.styling.*
|
||||
import it.vfsfitvnm.vimusic.utils.*
|
||||
import it.vfsfitvnm.youtubemusic.YouTube
|
||||
import it.vfsfitvnm.youtubemusic.models.PlayerResponse
|
||||
@@ -67,26 +63,19 @@ fun PlayerView(
|
||||
val preferences = LocalPreferences.current
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
val density = LocalDensity.current
|
||||
val configuration = LocalConfiguration.current
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
val context = LocalContext.current
|
||||
|
||||
val player = binder?.player
|
||||
val playerState = rememberPlayerState(player)
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
player ?: return
|
||||
playerState?.mediaItem ?: return
|
||||
|
||||
val smallThumbnailSize = remember {
|
||||
density.run { 64.dp.roundToPx() }
|
||||
}
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
val (thumbnailSizeDp, thumbnailSizePx) = remember {
|
||||
val size = minOf(configuration.screenHeightDp, configuration.screenWidthDp).dp
|
||||
size to density.run { size.minus(64.dp).roundToPx() }
|
||||
val (thumbnailSizeDp, thumbnailSizePx) = Dimensions.thumbnails.player.song.let {
|
||||
it to (it - 64.dp).px
|
||||
}
|
||||
|
||||
BottomSheet(
|
||||
@@ -105,7 +94,7 @@ fun PlayerView(
|
||||
}
|
||||
.background(colorPalette.elevatedBackground)
|
||||
.drawBehind {
|
||||
val offset = 64.dp.toPx()
|
||||
val offset = Dimensions.thumbnails.player.songPreview.toPx()
|
||||
|
||||
drawLine(
|
||||
color = colorPalette.text,
|
||||
@@ -122,11 +111,11 @@ fun PlayerView(
|
||||
}
|
||||
) {
|
||||
AsyncImage(
|
||||
model = playerState.mediaMetadata.artworkUri.thumbnail(smallThumbnailSize),
|
||||
model = playerState.mediaMetadata.artworkUri.thumbnail(Dimensions.thumbnails.player.songPreview.px),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
.size(64.dp)
|
||||
.size(Dimensions.thumbnails.player.songPreview)
|
||||
)
|
||||
|
||||
Column(
|
||||
@@ -631,11 +620,11 @@ fun PlayerView(
|
||||
|
||||
PlayerBottomSheet(
|
||||
playerState = playerState,
|
||||
layoutState = rememberBottomSheetState(64.dp, layoutState.upperBound - 128.dp),
|
||||
layoutState = rememberBottomSheetState(64.dp, layoutState.upperBound - Dimensions.playerBottomSheetPeekHeight),
|
||||
onGlobalRouteEmitted = layoutState.collapse,
|
||||
song = song,
|
||||
modifier = Modifier
|
||||
.padding(bottom = 128.dp)
|
||||
.padding(bottom = Dimensions.playerBottomSheetPeekHeight)
|
||||
.align(Alignment.BottomCenter)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import it.vfsfitvnm.vimusic.Database
|
||||
import it.vfsfitvnm.vimusic.models.PlaylistPreview
|
||||
import it.vfsfitvnm.vimusic.ui.styling.Dimensions
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||
import it.vfsfitvnm.vimusic.utils.color
|
||||
@@ -30,11 +31,12 @@ import it.vfsfitvnm.vimusic.utils.thumbnail
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
|
||||
|
||||
@Composable
|
||||
fun PlaylistPreviewItem(
|
||||
playlistPreview: PlaylistPreview,
|
||||
modifier: Modifier = Modifier,
|
||||
thumbnailSize: Dp = 54.dp,
|
||||
thumbnailSize: Dp = Dimensions.thumbnails.song,
|
||||
) {
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
|
||||
@@ -25,6 +25,7 @@ import coil.request.ImageRequest
|
||||
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
|
||||
import it.vfsfitvnm.vimusic.models.DetailedSong
|
||||
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
|
||||
import it.vfsfitvnm.vimusic.ui.styling.Dimensions
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||
import it.vfsfitvnm.vimusic.utils.secondary
|
||||
@@ -113,7 +114,7 @@ fun SongItem(
|
||||
startContent = {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(54.dp)
|
||||
.size(Dimensions.thumbnails.song)
|
||||
) {
|
||||
AsyncImage(
|
||||
model = thumbnailModel,
|
||||
|
||||
Reference in New Issue
Block a user