Skip to content

Commit

Permalink
Merge pull request #518 from Shreyassp002/Feat-Songs-List
Browse files Browse the repository at this point in the history
MOBILE-212: Highlight current playing song & dynamic PlayButton
  • Loading branch information
07jasjeet authored Jan 26, 2025
2 parents 9f3783d + 7e7cc61 commit de22834
Show file tree
Hide file tree
Showing 26 changed files with 366 additions and 443 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ fun ListenCardSmall(
coverArtUrl: String?,
listenCount: Int? = null,
@DrawableRes errorAlbumArt: Int = R.drawable.ic_coverartarchive_logo_no_text,
enableDropdownIcon: Boolean = false,
onDropdownIconClick: () -> Unit = {},
dropDown: @Composable () -> Unit = {},
dropDown: @Composable (() -> Unit)? = null,
enableTrailingContent: Boolean = false,
trailingContent: @Composable (modifier: Modifier) -> Unit = {},
blurbContent: @Composable (ColumnScope.(modifier: Modifier) -> Unit)? = null,
color: Color = ListenBrainzTheme.colorScheme.level1,
isPlaying: Boolean = false,
color: Color = if (isPlaying) {
ListenBrainzTheme.colorScheme.level2
} else {
ListenBrainzTheme.colorScheme.level1
},
titleColor: Color = ListenBrainzTheme.colorScheme.listenText,
subtitleColor: Color = titleColor.copy(alpha = 0.7f),
goToArtistPage: (String) -> Unit,
Expand All @@ -94,7 +98,8 @@ fun ListenCardSmall(
contentAlignment = Alignment.CenterStart
) {

val (mainContentFraction, trailingContentFraction, dropDownButtonFraction) = remember(enableDropdownIcon, enableTrailingContent) {
val (mainContentFraction, trailingContentFraction, dropDownButtonFraction) = remember(dropDown != null, enableTrailingContent) {
val enableDropdownIcon = dropDown != null
when {
enableDropdownIcon && enableTrailingContent -> Triple(0.60f, 0.80f, 0.20f) // 0.20f (0.08f in whole) for dropdown and 0.80f (0.32f in whole) for trailing content
enableDropdownIcon && !enableTrailingContent -> Triple(0.92f, 0f, 1f) // 0.10f for dropdown
Expand Down Expand Up @@ -153,7 +158,7 @@ fun ListenCardSmall(
}

// Dropdown Icon
if (enableDropdownIcon) {
if (dropDown != null) {
DropdownButton(
modifier = Modifier
.fillMaxWidth(dropDownButtonFraction)
Expand All @@ -177,24 +182,68 @@ fun ListenCardSmall(
}
}

@Suppress("NOTHING_TO_INLINE")
@Composable
inline fun ListenCardSmallDefault(
fun ListenCardSmall(
modifier: Modifier = Modifier,
trackName: String,
artist: String,
coverArtUrl: String?,
listenCount: Int? = null,
@DrawableRes errorAlbumArt: Int = R.drawable.ic_coverartarchive_logo_no_text,
onDropdownIconClick: () -> Unit = {},
dropDown: @Composable () -> Unit = {},
enableTrailingContent: Boolean = false,
trailingContent: @Composable (modifier: Modifier) -> Unit = {},
blurbContent: @Composable (ColumnScope.(modifier: Modifier) -> Unit)? = null,
isPlaying: Boolean = false,
color: Color = if (isPlaying) {
ListenBrainzTheme.colorScheme.level2
} else {
ListenBrainzTheme.colorScheme.level1
},
titleColor: Color = ListenBrainzTheme.colorScheme.listenText,
subtitleColor: Color = titleColor.copy(alpha = 0.7f),
goToArtistPage: (String) -> Unit,
onClick: () -> Unit,
) {
ListenCardSmall(
modifier = modifier,
trackName = trackName,
artists = listOf(FeedListenArtist(artist, null, "")),
coverArtUrl = coverArtUrl,
listenCount = listenCount,
errorAlbumArt = errorAlbumArt,
onDropdownIconClick = onDropdownIconClick,
dropDown = dropDown,
enableTrailingContent = enableTrailingContent,
trailingContent = trailingContent,
blurbContent = blurbContent,
isPlaying = isPlaying,
color = color,
titleColor = titleColor,
subtitleColor = subtitleColor,
goToArtistPage = goToArtistPage,
onClick = onClick
)
}

@Composable
fun ListenCardSmallDefault(
modifier: Modifier = Modifier,
metadata: Metadata,
coverArtUrl: String?,
listenCount: Int? = null,
@DrawableRes errorAlbumArt: Int = R.drawable.ic_coverartarchive_logo_no_text,
enableTrailingContent: Boolean = false,
noinline trailingContent: @Composable (modifier: Modifier) -> Unit = {},
noinline blurbContent: @Composable (ColumnScope.(modifier: Modifier) -> Unit)? = null,
trailingContent: @Composable (modifier: Modifier) -> Unit = {},
blurbContent: @Composable (ColumnScope.(modifier: Modifier) -> Unit)? = null,
color: Color = ListenBrainzTheme.colorScheme.level1,
titleColor: Color = ListenBrainzTheme.colorScheme.listenText,
subtitleColor: Color = titleColor.copy(alpha = 0.7f),
noinline onDropdownError: suspend CoroutineScope.(error: ResponseError) -> Unit,
noinline onDropdownSuccess: suspend CoroutineScope.(message: String) -> Unit,
noinline goToArtistPage: (String) -> Unit,
noinline onClick: () -> Unit,
onDropdownError: suspend CoroutineScope.(error: ResponseError) -> Unit,
onDropdownSuccess: suspend CoroutineScope.(message: String) -> Unit,
goToArtistPage: (String) -> Unit,
onClick: () -> Unit,
) {
metadata.trackMetadata?.let {
var isDropdownExpanded by remember { mutableStateOf(false) }
Expand All @@ -208,7 +257,6 @@ inline fun ListenCardSmallDefault(
coverArtUrl = coverArtUrl,
listenCount = listenCount,
errorAlbumArt = errorAlbumArt,
enableDropdownIcon = true,
onDropdownIconClick = {
isDropdownExpanded = !isDropdownExpanded
},
Expand Down Expand Up @@ -331,7 +379,6 @@ private fun ListenCardSmallPreview() {
trackName = "Title",
artists = listOf(FeedListenArtist("Artist", "", "")),
coverArtUrl = "",
enableDropdownIcon = true,
enableTrailingContent = true,
trailingContent = { modifier ->
Column(modifier = modifier) {
Expand All @@ -357,7 +404,6 @@ private fun ListenCardSmallNoBlurbContentPreview() {
trackName = "Title",
artists = listOf(FeedListenArtist("Artist", "", "")),
coverArtUrl = "",
enableDropdownIcon = true,
enableTrailingContent = true,
trailingContent = { modifier ->
Column(modifier = modifier) {
Expand All @@ -378,7 +424,6 @@ private fun ListenCardSmallSimplePreview() {
trackName = "Title",
artists = listOf(FeedListenArtist("Artist", "", "")),
coverArtUrl = "",
enableDropdownIcon = true,
enableTrailingContent = false,
goToArtistPage = {},
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -34,6 +35,7 @@ import org.listenbrainz.android.ui.theme.ListenBrainzTheme
fun BottomNavigationBar(
modifier: Modifier = Modifier,
navController: NavController = rememberNavController(),
backgroundColor: Color = ListenBrainzTheme.colorScheme.nav,
backdropScaffoldState: BackdropScaffoldState = rememberBackdropScaffoldState(initialValue = BackdropValue.Revealed),
scrollToTop: () -> Unit,
username : String?,
Expand All @@ -46,7 +48,7 @@ fun BottomNavigationBar(
)
BottomNavigation(
modifier = modifier,
backgroundColor = ListenBrainzTheme.colorScheme.nav,
backgroundColor = backgroundColor,
elevation = 0.dp
) {
val coroutineScope = rememberCoroutineScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ fun OnAlbumClickScreen(albumID: Long) {
artists = listOf(FeedListenArtist(it.artist, null, "")),
coverArtUrl = it.albumArt,
errorAlbumArt = R.drawable.ic_erroralbumart,
enableDropdownIcon = true,
goToArtistPage = {},
onDropdownIconClick = {
albumCardMoreOptionsDropMenuExpanded = albumSongs.indexOf(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ fun OnArtistClickScreen(artistID: String, navigateToAlbum: (id: Long) -> Unit) {
artists = listOf(FeedListenArtist(it.artist, null, "")),
coverArtUrl = it.albumArt,
errorAlbumArt = R.drawable.ic_erroralbumart,
enableDropdownIcon = true,
onDropdownIconClick = {
artistCardMoreOptionsDropMenuExpanded = artistSongs.indexOf(it)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import androidx.compose.material.Checkbox
import androidx.compose.material.CheckboxDefaults
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.RepeatOn
Expand All @@ -60,7 +59,6 @@ import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
Expand Down
Loading

0 comments on commit de22834

Please sign in to comment.