Find place for SongItem trailingIcon

This commit is contained in:
vfsfitvnm 2022-10-05 11:59:12 +02:00
parent 5e6787567e
commit aafb8f036d
4 changed files with 43 additions and 31 deletions

View file

@ -2,6 +2,7 @@ package it.vfsfitvnm.vimusic.ui.components.themed
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.Indication
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
@ -21,13 +22,15 @@ fun HeaderIconButton(
@DrawableRes icon: Int, @DrawableRes icon: Int,
color: Color, color: Color,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
enabled: Boolean = true enabled: Boolean = true,
indication: Indication? = null
) { ) {
IconButton( IconButton(
icon = icon, icon = icon,
color = color, color = color,
onClick = onClick, onClick = onClick,
enabled = enabled, enabled = enabled,
indication = indication,
modifier = modifier modifier = modifier
.padding(all = 4.dp) .padding(all = 4.dp)
.size(18.dp) .size(18.dp)
@ -40,7 +43,8 @@ fun IconButton(
@DrawableRes icon: Int, @DrawableRes icon: Int,
color: Color, color: Color,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
enabled: Boolean = true enabled: Boolean = true,
indication: Indication? = null
) { ) {
Image( Image(
painter = painterResource(icon), painter = painterResource(icon),
@ -48,7 +52,7 @@ fun IconButton(
colorFilter = ColorFilter.tint(color), colorFilter = ColorFilter.tint(color),
modifier = Modifier modifier = Modifier
.clickable( .clickable(
indication = rememberRipple(bounded = false), indication = indication ?: rememberRipple(bounded = false),
interactionSource = remember { MutableInteractionSource() }, interactionSource = remember { MutableInteractionSource() },
enabled = enabled, enabled = enabled,
onClick = onClick onClick = onClick

View file

@ -146,13 +146,27 @@ fun SongItem(
} }
ItemInfoContainer { ItemInfoContainer {
BasicText( trailingContent?.let {
Row(verticalAlignment = Alignment.CenterVertically) {
BasicText(
text = title ?: "",
style = typography.xs.semiBold,
maxLines = 1,
overflow = TextOverflow.Clip,
modifier = Modifier
.weight(1f)
)
it()
}
} ?: BasicText(
text = title ?: "", text = title ?: "",
style = typography.xs.semiBold, style = typography.xs.semiBold,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
) )
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
BasicText( BasicText(
text = authors ?: "", text = authors ?: "",

View file

@ -2,25 +2,21 @@ package it.vfsfitvnm.vimusic.ui.screens.localplaylist
import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
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.material.ripple.rememberRipple
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import it.vfsfitvnm.reordering.ReorderingLazyColumn import it.vfsfitvnm.reordering.ReorderingLazyColumn
import it.vfsfitvnm.reordering.animateItemPlacement import it.vfsfitvnm.reordering.animateItemPlacement
@ -41,6 +37,7 @@ import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.components.themed.ConfirmationDialog import it.vfsfitvnm.vimusic.ui.components.themed.ConfirmationDialog
import it.vfsfitvnm.vimusic.ui.components.themed.Header import it.vfsfitvnm.vimusic.ui.components.themed.Header
import it.vfsfitvnm.vimusic.ui.components.themed.HeaderIconButton import it.vfsfitvnm.vimusic.ui.components.themed.HeaderIconButton
import it.vfsfitvnm.vimusic.ui.components.themed.IconButton
import it.vfsfitvnm.vimusic.ui.components.themed.InPlaylistMediaItemMenu import it.vfsfitvnm.vimusic.ui.components.themed.InPlaylistMediaItemMenu
import it.vfsfitvnm.vimusic.ui.components.themed.PrimaryButton import it.vfsfitvnm.vimusic.ui.components.themed.PrimaryButton
import it.vfsfitvnm.vimusic.ui.components.themed.SecondaryTextButton import it.vfsfitvnm.vimusic.ui.components.themed.SecondaryTextButton
@ -134,6 +131,8 @@ fun LocalPlaylistSongs(
val thumbnailSizeDp = Dimensions.thumbnails.song val thumbnailSizeDp = Dimensions.thumbnails.song
val thumbnailSizePx = thumbnailSizeDp.px val thumbnailSizePx = thumbnailSizeDp.px
val rippleIndication = rememberRipple(bounded = false)
Box { Box {
ReorderingLazyColumn( ReorderingLazyColumn(
reorderingState = reorderingState, reorderingState = reorderingState,
@ -219,18 +218,14 @@ fun LocalPlaylistSongs(
thumbnailSizePx = thumbnailSizePx, thumbnailSizePx = thumbnailSizePx,
thumbnailSizeDp = thumbnailSizeDp, thumbnailSizeDp = thumbnailSizeDp,
trailingContent = { trailingContent = {
Image( IconButton(
painter = painterResource(R.drawable.reorder), icon = R.drawable.reorder,
contentDescription = null, color = colorPalette.textDisabled,
colorFilter = ColorFilter.tint(colorPalette.textSecondary), indication = rippleIndication,
onClick = {},
modifier = Modifier modifier = Modifier
.clickable { } .reorder(reorderingState = reorderingState, index = index)
.reorder( .size(18.dp)
reorderingState = reorderingState,
index = index
)
.padding(horizontal = 8.dp, vertical = 4.dp)
.size(20.dp)
) )
}, },
modifier = Modifier modifier = Modifier

View file

@ -27,6 +27,7 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.text.BasicText
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
@ -128,6 +129,8 @@ fun PlayerBottomSheet(
val paddingValues = WindowInsets.systemBars.asPaddingValues() val paddingValues = WindowInsets.systemBars.asPaddingValues()
val bottomPadding = paddingValues.calculateBottomPadding() val bottomPadding = paddingValues.calculateBottomPadding()
val rippleIndication = rememberRipple(bounded = false)
Column { Column {
ReorderingLazyColumn( ReorderingLazyColumn(
reorderingState = reorderingState, reorderingState = reorderingState,
@ -190,18 +193,14 @@ fun PlayerBottomSheet(
} }
}, },
trailingContent = { trailingContent = {
Image( IconButton(
painter = painterResource(R.drawable.reorder), icon = R.drawable.reorder,
contentDescription = null, color = colorPalette.textDisabled,
colorFilter = ColorFilter.tint(colorPalette.textSecondary), indication = rippleIndication,
onClick = {},
modifier = Modifier modifier = Modifier
.clickable { } .reorder(reorderingState = reorderingState, index = window.firstPeriodIndex)
.reorder( .size(18.dp)
reorderingState = reorderingState,
index = window.firstPeriodIndex
)
.padding(horizontal = 8.dp, vertical = 4.dp)
.size(20.dp)
) )
}, },
modifier = Modifier modifier = Modifier