Tweak code
This commit is contained in:
@@ -2,5 +2,5 @@ package it.vfsfitvnm.vimusic.enums
|
|||||||
|
|
||||||
enum class BuiltInPlaylist {
|
enum class BuiltInPlaylist {
|
||||||
Favorites,
|
Favorites,
|
||||||
Cached
|
Offline
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ fun BuiltInPlaylistScreen(builtInPlaylist: BuiltInPlaylist) {
|
|||||||
val songs by remember(binder?.cache, builtInPlaylist) {
|
val songs by remember(binder?.cache, builtInPlaylist) {
|
||||||
when (builtInPlaylist) {
|
when (builtInPlaylist) {
|
||||||
BuiltInPlaylist.Favorites -> Database.favorites()
|
BuiltInPlaylist.Favorites -> Database.favorites()
|
||||||
BuiltInPlaylist.Cached -> Database.songsWithContentLength().map { songs ->
|
BuiltInPlaylist.Offline -> Database.songsWithContentLength().map { songs ->
|
||||||
songs.filter { song ->
|
songs.filter { song ->
|
||||||
song.contentLength?.let {
|
song.contentLength?.let {
|
||||||
binder?.cache?.isCached(song.song.id, 0, song.contentLength)
|
binder?.cache?.isCached(song.song.id, 0, song.contentLength)
|
||||||
@@ -114,7 +114,7 @@ fun BuiltInPlaylistScreen(builtInPlaylist: BuiltInPlaylist) {
|
|||||||
BasicText(
|
BasicText(
|
||||||
text = when (builtInPlaylist) {
|
text = when (builtInPlaylist) {
|
||||||
BuiltInPlaylist.Favorites -> "Favorites"
|
BuiltInPlaylist.Favorites -> "Favorites"
|
||||||
BuiltInPlaylist.Cached -> "Offline"
|
BuiltInPlaylist.Offline -> "Offline"
|
||||||
},
|
},
|
||||||
style = typography.m.semiBold
|
style = typography.m.semiBold
|
||||||
)
|
)
|
||||||
@@ -196,7 +196,7 @@ fun BuiltInPlaylistScreen(builtInPlaylist: BuiltInPlaylist) {
|
|||||||
menuContent = {
|
menuContent = {
|
||||||
when (builtInPlaylist) {
|
when (builtInPlaylist) {
|
||||||
BuiltInPlaylist.Favorites -> InFavoritesMediaItemMenu(song = song)
|
BuiltInPlaylist.Favorites -> InFavoritesMediaItemMenu(song = song)
|
||||||
BuiltInPlaylist.Cached -> InHistoryMediaItemMenu(song = song)
|
BuiltInPlaylist.Offline -> InHistoryMediaItemMenu(song = song)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ fun HomeScreen() {
|
|||||||
.clickable(
|
.clickable(
|
||||||
indication = rememberRipple(bounded = true),
|
indication = rememberRipple(bounded = true),
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
onClick = { builtInPlaylistRoute(BuiltInPlaylist.Cached) }
|
onClick = { builtInPlaylistRoute(BuiltInPlaylist.Offline) }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import it.vfsfitvnm.vimusic.utils.semiBold
|
|||||||
import it.vfsfitvnm.vimusic.utils.thumbnail
|
import it.vfsfitvnm.vimusic.utils.thumbnail
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PlaylistPreviewItem(
|
fun PlaylistPreviewItem(
|
||||||
@@ -52,7 +53,11 @@ fun PlaylistPreviewItem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val thumbnails by remember(playlistPreview.playlist.id) {
|
val thumbnails by remember(playlistPreview.playlist.id) {
|
||||||
Database.playlistThumbnailUrls(playlistPreview.playlist.id).distinctUntilChanged()
|
Database.playlistThumbnailUrls(playlistPreview.playlist.id).distinctUntilChanged().map {
|
||||||
|
it.map { url ->
|
||||||
|
url.thumbnail(thumbnailSizePx)
|
||||||
|
}
|
||||||
|
}
|
||||||
}.collectAsState(initial = emptyList(), context = Dispatchers.IO)
|
}.collectAsState(initial = emptyList(), context = Dispatchers.IO)
|
||||||
|
|
||||||
PlaylistItem(
|
PlaylistItem(
|
||||||
@@ -62,7 +67,7 @@ fun PlaylistPreviewItem(
|
|||||||
imageContent = {
|
imageContent = {
|
||||||
if (thumbnails.toSet().size == 1) {
|
if (thumbnails.toSet().size == 1) {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = thumbnails.first().thumbnail(thumbnailSizePx),
|
model = thumbnails.first(),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -81,7 +86,7 @@ fun PlaylistPreviewItem(
|
|||||||
Alignment.BottomEnd
|
Alignment.BottomEnd
|
||||||
).forEachIndexed { index, alignment ->
|
).forEachIndexed { index, alignment ->
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = thumbnails.getOrNull(index).thumbnail(thumbnailSizePx),
|
model = thumbnails.getOrNull(index),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
Reference in New Issue
Block a user