Improve MediaItemMenu UI

This commit is contained in:
vfsfitvnm 2022-10-07 12:08:52 +02:00
parent 3364bb9f30
commit b2ad011cfd
13 changed files with 440 additions and 431 deletions

View file

@ -60,7 +60,8 @@ fun BoxScope.FloatingActionsContainerWithScrollToTop(
) { ) {
val transitionState = remember { val transitionState = remember {
MutableTransitionState<ScrollingInfo?>(ScrollingInfo()) MutableTransitionState<ScrollingInfo?>(ScrollingInfo())
}.apply { targetState = if (visible) lazyListState.scrollingInfo() else null } }.apply { targetState = lazyListState.scrollingInfo() }
// }.apply { targetState = if (visible) lazyListState.scrollingInfo() else null }
FloatingActions( FloatingActions(
transitionState = transitionState, transitionState = transitionState,
@ -125,7 +126,7 @@ fun BoxScope.FloatingActions(
onScrollToTop() onScrollToTop()
} }
}, },
enabled = transition.targetState?.isScrollingDown == false && transition.targetState?.isFar == true, // enabled = transition.targetState?.isScrollingDown == false && transition.targetState?.isFar == true,
iconId = R.drawable.chevron_up, iconId = R.drawable.chevron_up,
modifier = Modifier modifier = Modifier
.padding(bottom = 16.dp) .padding(bottom = 16.dp)

View file

@ -2,20 +2,23 @@ package it.vfsfitvnm.vimusic.ui.components.themed
import android.content.Intent import android.content.Intent
import android.text.format.DateUtils import android.text.format.DateUtils
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedContentScope import androidx.compose.animation.AnimatedContentScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.tween
import androidx.compose.animation.with import androidx.compose.animation.with
import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.text.BasicText
@ -30,11 +33,13 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.layout.onPlaced
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.media3.common.MediaItem import androidx.media3.common.MediaItem
import it.vfsfitvnm.route.RouteHandler
import it.vfsfitvnm.vimusic.Database import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R import it.vfsfitvnm.vimusic.R
@ -42,13 +47,17 @@ import it.vfsfitvnm.vimusic.enums.PlaylistSortBy
import it.vfsfitvnm.vimusic.enums.SortOrder import it.vfsfitvnm.vimusic.enums.SortOrder
import it.vfsfitvnm.vimusic.models.DetailedSong import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.models.Playlist import it.vfsfitvnm.vimusic.models.Playlist
import it.vfsfitvnm.vimusic.models.Song
import it.vfsfitvnm.vimusic.models.SongPlaylistMap import it.vfsfitvnm.vimusic.models.SongPlaylistMap
import it.vfsfitvnm.vimusic.query import it.vfsfitvnm.vimusic.query
import it.vfsfitvnm.vimusic.transaction import it.vfsfitvnm.vimusic.transaction
import it.vfsfitvnm.vimusic.ui.items.SongItem
import it.vfsfitvnm.vimusic.ui.screens.albumRoute import it.vfsfitvnm.vimusic.ui.screens.albumRoute
import it.vfsfitvnm.vimusic.ui.screens.artistRoute import it.vfsfitvnm.vimusic.ui.screens.artistRoute
import it.vfsfitvnm.vimusic.ui.screens.viewPlaylistsRoute import it.vfsfitvnm.vimusic.ui.styling.Dimensions
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.ui.styling.favoritesIcon
import it.vfsfitvnm.vimusic.ui.styling.px
import it.vfsfitvnm.vimusic.utils.addNext import it.vfsfitvnm.vimusic.utils.addNext
import it.vfsfitvnm.vimusic.utils.asMediaItem import it.vfsfitvnm.vimusic.utils.asMediaItem
import it.vfsfitvnm.vimusic.utils.enqueue import it.vfsfitvnm.vimusic.utils.enqueue
@ -56,27 +65,9 @@ import it.vfsfitvnm.vimusic.utils.forcePlay
import it.vfsfitvnm.vimusic.utils.semiBold import it.vfsfitvnm.vimusic.utils.semiBold
import it.vfsfitvnm.youtubemusic.models.NavigationEndpoint import it.vfsfitvnm.youtubemusic.models.NavigationEndpoint
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf
@ExperimentalAnimationApi
@Composable
fun InFavoritesMediaItemMenu(
onDismiss: () -> Unit,
song: DetailedSong,
modifier: Modifier = Modifier,
) {
NonQueuedMediaItemMenu(
mediaItem = song.asMediaItem,
onDismiss = onDismiss,
onRemoveFromFavorites = {
query {
Database.like(song.id, null)
}
},
modifier = modifier
)
}
@ExperimentalAnimationApi @ExperimentalAnimationApi
@Composable @Composable
fun InHistoryMediaItemMenu( fun InHistoryMediaItemMenu(
@ -143,7 +134,6 @@ fun NonQueuedMediaItemMenu(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onRemoveFromPlaylist: (() -> Unit)? = null, onRemoveFromPlaylist: (() -> Unit)? = null,
onHideFromDatabase: (() -> Unit)? = null, onHideFromDatabase: (() -> Unit)? = null,
onRemoveFromFavorites: (() -> Unit)? = null,
) { ) {
val binder = LocalPlayerServiceBinder.current val binder = LocalPlayerServiceBinder.current
@ -164,7 +154,6 @@ fun NonQueuedMediaItemMenu(
onEnqueue = { binder?.player?.enqueue(mediaItem) }, onEnqueue = { binder?.player?.enqueue(mediaItem) },
onRemoveFromPlaylist = onRemoveFromPlaylist, onRemoveFromPlaylist = onRemoveFromPlaylist,
onHideFromDatabase = onHideFromDatabase, onHideFromDatabase = onHideFromDatabase,
onRemoveFromFavorites = onRemoveFromFavorites,
modifier = modifier modifier = modifier
) )
} }
@ -203,7 +192,6 @@ fun BaseMediaItemMenu(
onRemoveFromQueue: (() -> Unit)? = null, onRemoveFromQueue: (() -> Unit)? = null,
onRemoveFromPlaylist: (() -> Unit)? = null, onRemoveFromPlaylist: (() -> Unit)? = null,
onHideFromDatabase: (() -> Unit)? = null, onHideFromDatabase: (() -> Unit)? = null,
onRemoveFromFavorites: (() -> Unit)? = null
) { ) {
val context = LocalContext.current val context = LocalContext.current
@ -228,7 +216,6 @@ fun BaseMediaItemMenu(
} }
}, },
onHideFromDatabase = onHideFromDatabase, onHideFromDatabase = onHideFromDatabase,
onRemoveFromFavorites = onRemoveFromFavorites,
onRemoveFromPlaylist = onRemoveFromPlaylist, onRemoveFromPlaylist = onRemoveFromPlaylist,
onRemoveFromQueue = onRemoveFromQueue, onRemoveFromQueue = onRemoveFromQueue,
onGoToAlbum = albumRoute::global, onGoToAlbum = albumRoute::global,
@ -262,30 +249,38 @@ fun MediaItemMenu(
onEnqueue: (() -> Unit)? = null, onEnqueue: (() -> Unit)? = null,
onHideFromDatabase: (() -> Unit)? = null, onHideFromDatabase: (() -> Unit)? = null,
onRemoveFromQueue: (() -> Unit)? = null, onRemoveFromQueue: (() -> Unit)? = null,
onRemoveFromFavorites: (() -> Unit)? = null,
onRemoveFromPlaylist: (() -> Unit)? = null, onRemoveFromPlaylist: (() -> Unit)? = null,
onAddToPlaylist: ((Playlist, Int) -> Unit)? = null, onAddToPlaylist: ((Playlist, Int) -> Unit)? = null,
onGoToAlbum: ((String) -> Unit)? = null, onGoToAlbum: ((String) -> Unit)? = null,
onGoToArtist: ((String) -> Unit)? = null, onGoToArtist: ((String) -> Unit)? = null,
onShare: (() -> Unit)? = null onShare: () -> Unit
) { ) {
Menu(modifier = modifier) { val (colorPalette) = LocalAppearance.current
RouteHandler( val density = LocalDensity.current
var isViewingPlaylists by remember {
mutableStateOf(false)
}
var height by remember {
mutableStateOf(0.dp)
}
val likedAt by remember(mediaItem.mediaId) {
Database.likedAt(mediaItem.mediaId).distinctUntilChanged()
}.collectAsState(initial = null, context = Dispatchers.IO)
AnimatedContent(
targetState = isViewingPlaylists,
transitionSpec = { transitionSpec = {
when (targetState.route) { val animationSpec = tween<IntOffset>(400)
viewPlaylistsRoute -> slideIntoContainer(AnimatedContentScope.SlideDirection.Left) with val slideDirection = if (targetState) AnimatedContentScope.SlideDirection.Left else AnimatedContentScope.SlideDirection.Right
slideOutOfContainer(AnimatedContentScope.SlideDirection.Left)
else -> when (initialState.route) { slideIntoContainer(slideDirection, animationSpec) with
viewPlaylistsRoute -> slideIntoContainer(AnimatedContentScope.SlideDirection.Right) with slideOutOfContainer(slideDirection, animationSpec)
slideOutOfContainer(AnimatedContentScope.SlideDirection.Right)
else -> EnterTransition.None with ExitTransition.None
} }
} ) { currentIsViewingPlaylists ->
} if (currentIsViewingPlaylists) {
) {
viewPlaylistsRoute {
val playlistPreviews by remember { val playlistPreviews by remember {
Database.playlistPreviews(PlaylistSortBy.DateAdded, SortOrder.Descending) Database.playlistPreviews(PlaylistSortBy.DateAdded, SortOrder.Descending)
}.collectAsState(initial = emptyList(), context = Dispatchers.IO) }.collectAsState(initial = emptyList(), context = Dispatchers.IO)
@ -297,9 +292,7 @@ fun MediaItemMenu(
if (isCreatingNewPlaylist && onAddToPlaylist != null) { if (isCreatingNewPlaylist && onAddToPlaylist != null) {
TextFieldDialog( TextFieldDialog(
hintText = "Enter the playlist name", hintText = "Enter the playlist name",
onDismiss = { onDismiss = { isCreatingNewPlaylist = false },
isCreatingNewPlaylist = false
},
onDone = { text -> onDone = { text ->
onDismiss() onDismiss()
onAddToPlaylist(Playlist(name = text), 0) onAddToPlaylist(Playlist(name = text), 0)
@ -307,39 +300,40 @@ fun MediaItemMenu(
) )
} }
Column { BackHandler {
isViewingPlaylists = false
}
Menu(
modifier = modifier
.requiredHeight(height)
) {
Row( Row(
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
.fillMaxWidth() .fillMaxWidth()
) { ) {
MenuBackButton(onClick = pop) IconButton(
onClick = { isViewingPlaylists = false },
icon = R.drawable.chevron_back,
color = colorPalette.textSecondary,
modifier = Modifier
.padding(all = 4.dp)
.size(20.dp)
)
if (onAddToPlaylist != null) { if (onAddToPlaylist != null) {
MenuIconButton( SecondaryTextButton(
icon = R.drawable.add, text = "New playlist",
onClick = { onClick = { isCreatingNewPlaylist = true },
isCreatingNewPlaylist = true alternative = true
}
) )
} }
} }
onAddToPlaylist?.let { onAddToPlaylist -> onAddToPlaylist?.let { onAddToPlaylist ->
if (onRemoveFromFavorites == null) {
MenuEntry(
icon = R.drawable.heart,
text = "Favorites",
onClick = {
onDismiss()
query {
Database.insert(mediaItem)
Database.like(mediaItem.mediaId, System.currentTimeMillis())
}
}
)
}
playlistPreviews.forEach { playlistPreview -> playlistPreviews.forEach { playlistPreview ->
MenuEntry( MenuEntry(
icon = R.drawable.playlist, icon = R.drawable.playlist,
@ -356,15 +350,61 @@ fun MediaItemMenu(
} }
} }
} }
} } else {
Menu(
host { modifier = modifier
Column( .onPlaced { height = with(density) { it.size.height.toDp() } }
modifier = Modifier
.pointerInput(Unit) {
detectTapGestures { }
}
) { ) {
val thumbnailSizeDp = Dimensions.thumbnails.song
val thumbnailSizePx = thumbnailSizeDp.px
SongItem(
song = mediaItem,
thumbnailSizeDp = thumbnailSizeDp,
thumbnailSizePx = thumbnailSizePx,
trailingContent = {
IconButton(
icon = if (likedAt == null) R.drawable.heart_outline else R.drawable.heart,
color = colorPalette.favoritesIcon,
onClick = {
query {
if (Database.like(
mediaItem.mediaId,
if (likedAt == null) System.currentTimeMillis() else null
) == 0
) {
Database.insert(mediaItem, Song::toggleLike)
}
}
},
modifier = Modifier
.padding(all = 4.dp)
.size(18.dp)
)
},
modifier = Modifier
.clickable(onClick = onShare)
)
Spacer(
modifier = Modifier
.height(8.dp)
)
Spacer(
modifier = Modifier
.alpha(0.5f)
.align(Alignment.CenterHorizontally)
.background(colorPalette.textDisabled)
.height(1.dp)
.fillMaxWidth(1f)
)
Spacer(
modifier = Modifier
.height(8.dp)
)
onStartRadio?.let { onStartRadio -> onStartRadio?.let { onStartRadio ->
MenuEntry( MenuEntry(
icon = R.drawable.radio, icon = R.drawable.radio,
@ -412,13 +452,14 @@ fun MediaItemMenu(
// TODO: find solution to this shit // TODO: find solution to this shit
onShowSleepTimer?.let { onShowSleepTimer?.let {
val binder = LocalPlayerServiceBinder.current val binder = LocalPlayerServiceBinder.current
val (colorPalette, typography) = LocalAppearance.current val (_, typography) = LocalAppearance.current
var isShowingSleepTimerDialog by remember { var isShowingSleepTimerDialog by remember {
mutableStateOf(false) mutableStateOf(false)
} }
val sleepTimerMillisLeft by (binder?.sleepTimerMillisLeft ?: flowOf(null)) val sleepTimerMillisLeft by (binder?.sleepTimerMillisLeft
?: flowOf(null))
.collectAsState(initial = null) .collectAsState(initial = null)
if (isShowingSleepTimerDialog) { if (isShowingSleepTimerDialog) {
@ -437,7 +478,9 @@ fun MediaItemMenu(
} }
) )
} else { } else {
DefaultDialog(onDismiss = { isShowingSleepTimerDialog = false }) { DefaultDialog(onDismiss = {
isShowingSleepTimerDialog = false
}) {
var amount by remember { var amount by remember {
mutableStateOf(1) mutableStateOf(1)
} }
@ -548,9 +591,16 @@ fun MediaItemMenu(
if (onAddToPlaylist != null) { if (onAddToPlaylist != null) {
MenuEntry( MenuEntry(
icon = R.drawable.playlist, icon = R.drawable.playlist,
text = "Add to playlist or favorites", text = "Add to playlist",
onClick = { onClick = { isViewingPlaylists = true },
viewPlaylistsRoute() trailingContent = {
Image(
painter = painterResource(R.drawable.chevron_forward),
contentDescription = null,
colorFilter = androidx.compose.ui.graphics.ColorFilter.tint(colorPalette.textSecondary),
modifier = Modifier
.size(16.dp)
)
} }
) )
} }
@ -590,17 +640,6 @@ fun MediaItemMenu(
} }
} }
onShare?.let { onShare ->
MenuEntry(
icon = R.drawable.share_social,
text = "Share",
onClick = {
onDismiss()
onShare()
}
)
}
onRemoveFromQueue?.let { onRemoveFromQueue -> onRemoveFromQueue?.let { onRemoveFromQueue ->
MenuEntry( MenuEntry(
icon = R.drawable.trash, icon = R.drawable.trash,
@ -612,17 +651,6 @@ fun MediaItemMenu(
) )
} }
onRemoveFromFavorites?.let { onRemoveFromFavorites ->
MenuEntry(
icon = R.drawable.heart_dislike,
text = "Remove from favorites",
onClick = {
onDismiss()
onRemoveFromFavorites()
}
)
}
onRemoveFromPlaylist?.let { onRemoveFromPlaylist -> onRemoveFromPlaylist?.let { onRemoveFromPlaylist ->
MenuEntry( MenuEntry(
icon = R.drawable.trash, icon = R.drawable.trash,
@ -644,5 +672,4 @@ fun MediaItemMenu(
} }
} }
} }
}
} }

View file

@ -1,11 +1,11 @@
package it.vfsfitvnm.vimusic.ui.components.themed package it.vfsfitvnm.vimusic.ui.components.themed
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
@ -23,7 +23,6 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.ColorFilter
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 it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.utils.medium import it.vfsfitvnm.vimusic.utils.medium
import it.vfsfitvnm.vimusic.utils.secondary import it.vfsfitvnm.vimusic.utils.secondary
@ -54,7 +53,8 @@ fun MenuEntry(
text: String, text: String,
onClick: () -> Unit, onClick: () -> Unit,
secondaryText: String? = null, secondaryText: String? = null,
isEnabled: Boolean = true, enabled: Boolean = true,
trailingContent: (@Composable () -> Unit)? = null
) { ) {
val (colorPalette, typography) = LocalAppearance.current val (colorPalette, typography) = LocalAppearance.current
@ -62,9 +62,9 @@ fun MenuEntry(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(24.dp), horizontalArrangement = Arrangement.spacedBy(24.dp),
modifier = Modifier modifier = Modifier
.clickable(enabled = isEnabled, onClick = onClick) .clickable(enabled = enabled, onClick = onClick)
.fillMaxWidth() .fillMaxWidth()
.alpha(if (isEnabled) 1f else 0.4f) .alpha(if (enabled) 1f else 0.4f)
.padding(horizontal = 24.dp, vertical = 16.dp) .padding(horizontal = 24.dp, vertical = 16.dp)
) { ) {
Image( Image(
@ -75,7 +75,10 @@ fun MenuEntry(
.size(15.dp) .size(15.dp)
) )
Column { Column(
modifier = Modifier
.weight(1f)
) {
BasicText( BasicText(
text = text, text = text,
style = typography.xs.medium style = typography.xs.medium
@ -88,41 +91,7 @@ fun MenuEntry(
) )
} }
} }
trailingContent?.invoke()
} }
} }
@Composable
fun MenuIconButton(
@DrawableRes icon: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier
) {
val (colorPalette) = LocalAppearance.current
Box(
modifier = modifier
.padding(horizontal = 14.dp)
) {
Image(
painter = painterResource(icon),
contentDescription = null,
colorFilter = ColorFilter.tint(colorPalette.text),
modifier = Modifier
.clickable(onClick = onClick)
.padding(horizontal = 8.dp, vertical = 8.dp)
.size(20.dp)
)
}
}
@Composable
fun MenuBackButton(
onClick: () -> Unit,
modifier: Modifier = Modifier
) {
MenuIconButton(
icon = R.drawable.chevron_back,
onClick = onClick,
modifier = modifier
)
}

View file

@ -17,7 +17,8 @@ fun SecondaryTextButton(
text: String, text: String,
onClick: () -> Unit, onClick: () -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
isEnabled: Boolean = true enabled: Boolean = true,
alternative: Boolean = false
) { ) {
val (colorPalette, typography) = LocalAppearance.current val (colorPalette, typography) = LocalAppearance.current
@ -26,8 +27,8 @@ fun SecondaryTextButton(
style = typography.xxs.medium, style = typography.xxs.medium,
modifier = modifier modifier = modifier
.clip(RoundedCornerShape(16.dp)) .clip(RoundedCornerShape(16.dp))
.clickable(enabled = isEnabled, onClick = onClick) .clickable(enabled = enabled, onClick = onClick)
.background(colorPalette.background2) .background(if (alternative) colorPalette.background0 else colorPalette.background2)
.padding(all = 8.dp) .padding(all = 8.dp)
.padding(horizontal = 8.dp) .padding(horizontal = 8.dp)
) )

View file

@ -152,7 +152,7 @@ fun SongItem(
text = title ?: "", text = title ?: "",
style = typography.xs.semiBold, style = typography.xs.semiBold,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Clip, overflow = TextOverflow.Ellipsis,
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
) )

View file

@ -20,7 +20,6 @@ val playlistRoute = Route1<String?>("playlistRoute")
val searchResultRoute = Route1<String>("searchResultRoute") val searchResultRoute = Route1<String>("searchResultRoute")
val searchRoute = Route1<String>("searchRoute") val searchRoute = Route1<String>("searchRoute")
val settingsRoute = Route0("settingsRoute") val settingsRoute = Route0("settingsRoute")
val viewPlaylistsRoute = Route0("createPlaylistRoute")
@SuppressLint("ComposableNaming") @SuppressLint("ComposableNaming")
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View file

@ -88,7 +88,7 @@ fun AlbumSongs(
headerContent { headerContent {
SecondaryTextButton( SecondaryTextButton(
text = "Enqueue", text = "Enqueue",
isEnabled = songs.isNotEmpty(), enabled = songs.isNotEmpty(),
onClick = { onClick = {
binder?.player?.enqueue(songs.map(DetailedSong::asMediaItem)) binder?.player?.enqueue(songs.map(DetailedSong::asMediaItem))
} }

View file

@ -83,7 +83,7 @@ fun ArtistLocalSongs(
headerContent { headerContent {
SecondaryTextButton( SecondaryTextButton(
text = "Enqueue", text = "Enqueue",
isEnabled = !songs.isNullOrEmpty(), enabled = !songs.isNullOrEmpty(),
onClick = { onClick = {
binder?.player?.enqueue(songs!!.map(DetailedSong::asMediaItem)) binder?.player?.enqueue(songs!!.map(DetailedSong::asMediaItem))
} }

View file

@ -23,9 +23,8 @@ import it.vfsfitvnm.vimusic.savers.DetailedSongListSaver
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.components.themed.FloatingActionsContainerWithScrollToTop import it.vfsfitvnm.vimusic.ui.components.themed.FloatingActionsContainerWithScrollToTop
import it.vfsfitvnm.vimusic.ui.components.themed.Header import it.vfsfitvnm.vimusic.ui.components.themed.Header
import it.vfsfitvnm.vimusic.ui.components.themed.InFavoritesMediaItemMenu
import it.vfsfitvnm.vimusic.ui.components.themed.InHistoryMediaItemMenu import it.vfsfitvnm.vimusic.ui.components.themed.InHistoryMediaItemMenu
import it.vfsfitvnm.vimusic.ui.components.themed.PrimaryButton import it.vfsfitvnm.vimusic.ui.components.themed.NonQueuedMediaItemMenu
import it.vfsfitvnm.vimusic.ui.components.themed.SecondaryTextButton import it.vfsfitvnm.vimusic.ui.components.themed.SecondaryTextButton
import it.vfsfitvnm.vimusic.ui.items.SongItem import it.vfsfitvnm.vimusic.ui.items.SongItem
import it.vfsfitvnm.vimusic.ui.styling.Dimensions import it.vfsfitvnm.vimusic.ui.styling.Dimensions
@ -94,7 +93,7 @@ fun BuiltInPlaylistSongs(builtInPlaylist: BuiltInPlaylist) {
) { ) {
SecondaryTextButton( SecondaryTextButton(
text = "Enqueue", text = "Enqueue",
isEnabled = songs.isNotEmpty(), enabled = songs.isNotEmpty(),
onClick = { onClick = {
binder?.player?.enqueue(songs.map(DetailedSong::asMediaItem)) binder?.player?.enqueue(songs.map(DetailedSong::asMediaItem))
} }
@ -121,8 +120,8 @@ fun BuiltInPlaylistSongs(builtInPlaylist: BuiltInPlaylist) {
onLongClick = { onLongClick = {
menuState.display { menuState.display {
when (builtInPlaylist) { when (builtInPlaylist) {
BuiltInPlaylist.Favorites -> InFavoritesMediaItemMenu( BuiltInPlaylist.Favorites -> NonQueuedMediaItemMenu(
song = song, mediaItem = song.asMediaItem,
onDismiss = menuState::hide onDismiss = menuState::hide
) )

View file

@ -150,7 +150,7 @@ fun LocalPlaylistSongs(
Header(title = playlistWithSongs?.playlist?.name ?: "Unknown") { Header(title = playlistWithSongs?.playlist?.name ?: "Unknown") {
SecondaryTextButton( SecondaryTextButton(
text = "Enqueue", text = "Enqueue",
isEnabled = playlistWithSongs?.songs?.isNotEmpty() == true, enabled = playlistWithSongs?.songs?.isNotEmpty() == true,
onClick = { onClick = {
playlistWithSongs?.songs playlistWithSongs?.songs
?.map(DetailedSong::asMediaItem) ?.map(DetailedSong::asMediaItem)

View file

@ -351,7 +351,7 @@ fun Lyrics(
MenuEntry( MenuEntry(
icon = R.drawable.download, icon = R.drawable.download,
text = "Fetch lyrics again", text = "Fetch lyrics again",
isEnabled = lyrics != null, enabled = lyrics != null,
onClick = { onClick = {
menuState.hide() menuState.hide()
query { query {

View file

@ -125,7 +125,7 @@ fun PlaylistSongList(
Header(title = playlistPage?.title ?: "Unknown") { Header(title = playlistPage?.title ?: "Unknown") {
SecondaryTextButton( SecondaryTextButton(
text = "Enqueue", text = "Enqueue",
isEnabled = playlistPage?.songsPage?.items?.isNotEmpty() == true, enabled = playlistPage?.songsPage?.items?.isNotEmpty() == true,
onClick = { onClick = {
playlistPage?.songsPage?.items?.map(Innertube.SongItem::asMediaItem)?.let { mediaItems -> playlistPage?.songsPage?.items?.map(Innertube.SongItem::asMediaItem)?.let { mediaItems ->
binder?.player?.enqueue(mediaItems) binder?.player?.enqueue(mediaItems)

View file

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:pathData="M184,112l144,144l-144,144"
android:strokeLineJoin="round"
android:strokeWidth="48"
android:fillColor="#00000000"
android:strokeColor="#000"
android:strokeLineCap="round"/>
</vector>