Add Dimensions class

This commit is contained in:
vfsfitvnm 2022-07-08 11:18:36 +02:00
parent 87b2ff3788
commit eb4e249443
16 changed files with 106 additions and 117 deletions

View file

@ -144,7 +144,7 @@ class MainActivity : ComponentActivity() {
PlayerView(
layoutState = rememberBottomSheetState(
lowerBound = 64.dp, upperBound = maxHeight
lowerBound = Dimensions.collapsedPlayer, upperBound = maxHeight
),
modifier = Modifier
.align(Alignment.BottomCenter)

View file

@ -23,7 +23,6 @@ import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
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
@ -39,8 +38,10 @@ import it.vfsfitvnm.vimusic.models.SongAlbumMap
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.*
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.ui.styling.px
import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.*
import it.vfsfitvnm.youtubemusic.YouTube
@ -109,18 +110,12 @@ fun AlbumScreen(
host {
val context = LocalContext.current
val density = LocalDensity.current
val binder = LocalPlayerServiceBinder.current
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
val menuState = LocalMenuState.current
val (thumbnailSizeDp, thumbnailSizePx) = remember {
density.run {
128.dp to 128.dp.roundToPx()
}
}
LazyColumn(
state = lazyListState,
@ -208,12 +203,12 @@ fun AlbumScreen(
.padding(bottom = 16.dp)
) {
AsyncImage(
model = album.thumbnailUrl?.thumbnail(thumbnailSizePx),
model = album.thumbnailUrl?.thumbnail(Dimensions.thumbnails.album.px),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier
.clip(ThumbnailRoundness.shape)
.size(thumbnailSizeDp)
.size(Dimensions.thumbnails.album)
)
Column(
@ -350,7 +345,7 @@ private fun LoadingOrError(
Spacer(
modifier = Modifier
.background(color = LocalColorPalette.current.darkGray, shape = ThumbnailRoundness.shape)
.size(128.dp)
.size(Dimensions.thumbnails.album)
)
Column(

View file

@ -20,7 +20,6 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
@ -37,8 +36,10 @@ import it.vfsfitvnm.vimusic.ui.components.themed.InHistoryMediaItemMenu
import it.vfsfitvnm.vimusic.ui.components.themed.LoadingOrError
import it.vfsfitvnm.vimusic.ui.components.themed.TextCard
import it.vfsfitvnm.vimusic.ui.components.themed.TextPlaceholder
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.ui.styling.px
import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.*
import it.vfsfitvnm.youtubemusic.YouTube
@ -76,7 +77,6 @@ fun ArtistScreen(
host {
val binder = LocalPlayerServiceBinder.current
val density = LocalDensity.current
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
@ -100,17 +100,7 @@ fun ArtistScreen(
}.distinctUntilChanged()
}.collectAsState(initial = null, context = Dispatchers.IO)
val (thumbnailSizeDp, thumbnailSizePx) = remember {
density.run {
192.dp to 192.dp.roundToPx()
}
}
val songThumbnailSizePx = remember {
density.run {
54.dp.roundToPx()
}
}
val songThumbnailSizePx = Dimensions.thumbnails.song.px
val songs by remember(browseId) {
Database.artistSongs(browseId)
@ -145,7 +135,7 @@ fun ArtistScreen(
item {
artistResult?.getOrNull()?.let { artist ->
AsyncImage(
model = artist.thumbnailUrl?.thumbnail(thumbnailSizePx),
model = artist.thumbnailUrl?.thumbnail(Dimensions.thumbnails.artist.px),
contentDescription = null,
modifier = Modifier
.clip(CircleShape)
@ -160,7 +150,7 @@ fun ArtistScreen(
}
}
}
.size(thumbnailSizeDp)
.size(Dimensions.thumbnails.artist)
)
BasicText(
@ -205,7 +195,8 @@ fun ArtistScreen(
.clickable {
binder?.playRadio(
NavigationEndpoint.Endpoint.Watch(
videoId = artist.radioVideoId ?: artist.shuffleVideoId,
videoId = artist.radioVideoId
?: artist.shuffleVideoId,
playlistId = artist.radioPlaylistId
)
)
@ -320,7 +311,7 @@ private fun LoadingOrError(
Spacer(
modifier = Modifier
.background(color = colorPalette.darkGray, shape = CircleShape)
.size(192.dp)
.size(Dimensions.thumbnails.artist)
)
TextPlaceholder(

View file

@ -18,7 +18,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.route.RouteHandler
@ -30,8 +29,10 @@ import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.*
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.ui.styling.px
import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.*
import kotlinx.coroutines.Dispatchers
@ -62,18 +63,13 @@ fun BuiltInPlaylistScreen(
}
host {
val density = LocalDensity.current
val menuState = LocalMenuState.current
val binder = LocalPlayerServiceBinder.current
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
val thumbnailSize = remember {
density.run {
54.dp.roundToPx()
}
}
val thumbnailSize = Dimensions.thumbnails.song.px
val songs by remember(binder?.cache, builtInPlaylist) {
when (builtInPlaylist) {
@ -90,7 +86,7 @@ fun BuiltInPlaylistScreen(
LazyColumn(
state = lazyListState,
contentPadding = PaddingValues(bottom = 64.dp),
contentPadding = PaddingValues(bottom = Dimensions.collapsedPlayer),
modifier = Modifier
.background(colorPalette.background)
.fillMaxSize()

View file

@ -48,8 +48,10 @@ import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.DropdownMenu
import it.vfsfitvnm.vimusic.ui.components.themed.InHistoryMediaItemMenu
import it.vfsfitvnm.vimusic.ui.components.themed.TextFieldDialog
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.ui.styling.px
import it.vfsfitvnm.vimusic.ui.views.PlaylistPreviewItem
import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.*
@ -148,13 +150,8 @@ fun HomeScreen() {
@Suppress("UNUSED_EXPRESSION") songCollection
val binder = LocalPlayerServiceBinder.current
val density = LocalDensity.current
val thumbnailSize = remember {
density.run {
54.dp.roundToPx()
}
}
val thumbnailSize = Dimensions.thumbnails.song.px
var isGridExpanded by remember {
mutableStateOf(false)

View file

@ -14,7 +14,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.route.RouteHandler
@ -27,7 +26,9 @@ import it.vfsfitvnm.vimusic.transaction
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.*
import it.vfsfitvnm.vimusic.ui.styling.Dimensions
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
import it.vfsfitvnm.vimusic.ui.styling.px
import it.vfsfitvnm.vimusic.utils.asMediaItem
import it.vfsfitvnm.vimusic.utils.enqueue
import it.vfsfitvnm.vimusic.utils.forcePlayAtIndex
@ -36,6 +37,7 @@ import it.vfsfitvnm.youtubemusic.YouTube
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@ExperimentalAnimationApi
@Composable
fun IntentUriScreen(uri: Uri) {
@ -60,9 +62,10 @@ fun IntentUriScreen(uri: Uri) {
host {
val menuState = LocalMenuState.current
val colorPalette = LocalColorPalette.current
val density = LocalDensity.current
val binder = LocalPlayerServiceBinder.current
val thumbnailSizePx = Dimensions.thumbnails.song.px
var itemsResult by remember(uri) {
mutableStateOf<Result<List<YouTube.Item.Song>>?>(null)
}
@ -125,7 +128,7 @@ fun IntentUriScreen(uri: Uri) {
LazyColumn(
state = lazyListState,
horizontalAlignment = Alignment.CenterHorizontally,
contentPadding = PaddingValues(bottom = 64.dp),
contentPadding = PaddingValues(bottom = Dimensions.collapsedPlayer),
modifier = Modifier
.background(colorPalette.background)
.fillMaxSize()
@ -189,7 +192,6 @@ fun IntentUriScreen(uri: Uri) {
}
}
itemsResult?.getOrNull()?.let { items ->
if (items.isEmpty()) {
item {
@ -205,7 +207,7 @@ fun IntentUriScreen(uri: Uri) {
) { index, item ->
SmallSongItem(
song = item,
thumbnailSizePx = density.run { 54.dp.roundToPx() },
thumbnailSizePx = thumbnailSizePx,
onClick = {
binder?.stopRadio()
binder?.player?.forcePlayAtIndex(items.map(YouTube.Item.Song::asMediaItem), index)
@ -239,7 +241,7 @@ private fun LoadingOrError(
) {
repeat(5) { index ->
SmallSongItemShimmer(
thumbnailSizeDp = 54.dp,
thumbnailSizeDp = Dimensions.thumbnails.song,
modifier = Modifier
.alpha(1f - index * 0.175f)
.fillMaxWidth()

View file

@ -17,7 +17,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
@ -26,14 +25,16 @@ import it.vfsfitvnm.reordering.verticalDragAfterLongPressToReorder
import it.vfsfitvnm.route.RouteHandler
import it.vfsfitvnm.vimusic.*
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.models.PlaylistWithSongs
import it.vfsfitvnm.vimusic.models.SongPlaylistMap
import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.*
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.ui.styling.px
import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.*
import kotlinx.coroutines.Dispatchers
@ -68,7 +69,6 @@ fun LocalPlaylistScreen(
}
host {
val density = LocalDensity.current
val hapticFeedback = LocalHapticFeedback.current
val menuState = LocalMenuState.current
@ -76,11 +76,7 @@ fun LocalPlaylistScreen(
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
val thumbnailSize = remember {
density.run {
54.dp.roundToPx()
}
}
val thumbnailSize = Dimensions.thumbnails.song.px
val reorderingState = rememberReorderingState(playlistWithSongs.songs)
@ -124,7 +120,7 @@ fun LocalPlaylistScreen(
LazyColumn(
state = lazyListState,
contentPadding = PaddingValues(bottom = 64.dp),
contentPadding = PaddingValues(bottom = Dimensions.collapsedPlayer),
modifier = Modifier
.background(colorPalette.background)
.fillMaxSize()

View file

@ -20,7 +20,6 @@ import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
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
@ -36,8 +35,10 @@ import it.vfsfitvnm.vimusic.transaction
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.*
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.ui.styling.px
import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.*
import it.vfsfitvnm.youtubemusic.YouTube
@ -70,24 +71,14 @@ fun PlaylistScreen(
host {
val context = LocalContext.current
val density = LocalDensity.current
val binder = LocalPlayerServiceBinder.current
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
val menuState = LocalMenuState.current
val (thumbnailSizeDp, thumbnailSizePx) = remember {
density.run {
128.dp to 128.dp.roundToPx()
}
}
val (songThumbnailSizeDp, songThumbnailSizePx) = remember {
density.run {
54.dp to 54.dp.roundToPx()
}
}
val thumbnailSizePx = Dimensions.thumbnails.playlist.px
val songThumbnailSizePx = Dimensions.thumbnails.song.px
var playlist by remember {
mutableStateOf<Result<YouTube.PlaylistOrAlbum>?>(null)
@ -239,7 +230,7 @@ fun PlaylistScreen(
contentScale = ContentScale.Crop,
modifier = Modifier
.clip(ThumbnailRoundness.shape)
.size(thumbnailSizeDp)
.size(Dimensions.thumbnails.playlist)
)
Column(
@ -372,7 +363,7 @@ fun PlaylistScreen(
contentScale = ContentScale.Crop,
modifier = Modifier
.clip(ThumbnailRoundness.shape)
.size(songThumbnailSizeDp)
.size(Dimensions.thumbnails.song)
)
}
},
@ -414,7 +405,7 @@ private fun LoadingOrError(
Spacer(
modifier = Modifier
.background(color = colorPalette.darkGray, shape = ThumbnailRoundness.shape)
.size(128.dp)
.size(Dimensions.thumbnails.playlist)
)
Column(
@ -439,7 +430,7 @@ private fun LoadingOrError(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier
.alpha(0.6f - it * 0.1f)
.height(54.dp)
.height(Dimensions.thumbnails.song)
.fillMaxWidth()
.padding(vertical = 4.dp, horizontal = 16.dp)
) {

View file

@ -20,7 +20,6 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
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
@ -37,8 +36,10 @@ import it.vfsfitvnm.vimusic.ui.components.themed.LoadingOrError
import it.vfsfitvnm.vimusic.ui.components.themed.NonQueuedMediaItemMenu
import it.vfsfitvnm.vimusic.ui.components.themed.TextCard
import it.vfsfitvnm.vimusic.ui.components.themed.TextPlaceholder
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.ui.styling.px
import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.*
import it.vfsfitvnm.youtubemusic.YouTube
@ -52,7 +53,6 @@ fun SearchResultScreen(
query: String,
onSearchAgain: () -> Unit,
) {
val density = LocalDensity.current
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
val preferences = LocalPreferences.current
@ -83,11 +83,7 @@ fun SearchResultScreen(
}
}
val thumbnailSizePx = remember {
density.run {
54.dp.roundToPx()
}
}
val thumbnailSizePx = Dimensions.thumbnails.song.px
val albumRoute = rememberAlbumRoute()
val playlistRoute = rememberPlaylistRoute()
@ -118,7 +114,7 @@ fun SearchResultScreen(
LazyColumn(
state = lazyListState,
horizontalAlignment = Alignment.CenterHorizontally,
contentPadding = PaddingValues(bottom = 64.dp),
contentPadding = PaddingValues(bottom = Dimensions.collapsedPlayer),
modifier = Modifier
.background(colorPalette.background)
.fillMaxSize()
@ -212,7 +208,7 @@ fun SearchResultScreen(
) { item ->
SmallItem(
item = item,
thumbnailSizeDp = 54.dp,
thumbnailSizeDp = Dimensions.thumbnails.song,
thumbnailSizePx = thumbnailSizePx,
onClick = {
when (item) {
@ -571,7 +567,7 @@ private fun LoadingOrError(
repeat(itemCount) { index ->
if (isLoadingArtists) {
SmallArtistItemShimmer(
thumbnailSizeDp = 54.dp,
thumbnailSizeDp = Dimensions.thumbnails.song,
modifier = Modifier
.alpha(1f - index * 0.125f)
.fillMaxWidth()
@ -579,7 +575,7 @@ private fun LoadingOrError(
)
} else {
SmallSongItemShimmer(
thumbnailSizeDp = 54.dp,
thumbnailSizeDp = Dimensions.thumbnails.song,
modifier = Modifier
.alpha(1f - index * 0.125f)
.fillMaxWidth()

View file

@ -36,6 +36,7 @@ import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.query
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.LoadingOrError
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.medium
@ -245,7 +246,7 @@ fun SearchScreen(
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(bottom = 64.dp)
.padding(bottom = Dimensions.collapsedPlayer)
) {
history?.forEach { searchQuery ->
Row(

View file

@ -0,0 +1,34 @@
package it.vfsfitvnm.vimusic.ui.styling
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@Suppress("ClassName")
object Dimensions {
object thumbnails {
val album = 128.dp
val artist = 192.dp
val song = 54.dp
val playlist = album
object player {
val songPreview = collapsedPlayer
val song: Dp
@Composable
get() = with (LocalConfiguration.current) {
minOf(screenHeightDp, screenWidthDp)
}.dp
}
}
val collapsedPlayer = 64.dp
val playerBottomSheetPeekHeight = 128.dp
}
inline val Dp.px: Int
@Composable
inline get() = with (LocalDensity.current) { roundToPx() }

View file

@ -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()

View file

@ -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,

View file

@ -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)
)
}

View file

@ -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

View file

@ -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,