diff --git a/app/src/main/java/org/listenbrainz/android/ui/components/BrainzPlayerListenCard.kt b/app/src/main/java/org/listenbrainz/android/ui/components/BrainzPlayerListenCard.kt index b7bc40e9..e7150730 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/components/BrainzPlayerListenCard.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/components/BrainzPlayerListenCard.kt @@ -1,6 +1,7 @@ package org.listenbrainz.android.ui.components import androidx.annotation.DrawableRes +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -19,16 +20,21 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.FilterQuality import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import coil.compose.AsyncImage import coil.request.ImageRequest import org.listenbrainz.android.R import org.listenbrainz.android.model.feed.FeedListenArtist import org.listenbrainz.android.ui.theme.ListenBrainzTheme +import org.listenbrainz.android.util.BrainzPlayerExtensions.toSong +import org.listenbrainz.android.viewmodel.BrainzPlayerViewModel @Composable fun BrainzPlayerListenCard( @@ -40,11 +46,21 @@ fun BrainzPlayerListenCard( onDropdownIconClick: () -> Unit = {}, dropDown: @Composable () -> Unit = {}, dropDownState: Boolean = false, - onPlayIconClick: () -> Unit + onPlayIconClick: () -> Unit, + mediaId: Long? = null, + viewModel: BrainzPlayerViewModel = hiltViewModel() ) { + val currentlyPlayingSong = viewModel.currentlyPlayingSong.collectAsStateWithLifecycle().value.toSong + val titleColor = if (currentlyPlayingSong.mediaID == mediaId) { + Color(0xFFB94FE5) + } else { + ListenBrainzTheme.colorScheme.listenText + } + Surface( modifier = modifier - .fillMaxWidth(), + .fillMaxWidth() + .clickable { onPlayIconClick() }, shape = ListenBrainzTheme.shapes.listenCardSmall, shadowElevation = 4.dp, color = ListenBrainzTheme.colorScheme.level1 @@ -72,22 +88,15 @@ fun BrainzPlayerListenCard( title = title, goToArtistPage = {}, artists = listOf(FeedListenArtist(subTitle, null, "")), + titleColor = titleColor ) } Box(modifier = Modifier .fillMaxWidth(0.275f) .align(Alignment.CenterEnd)){ - DropdownButton (modifier = Modifier.align(Alignment.Center), onDropdownIconClick = onDropdownIconClick) + DropdownButton (modifier = Modifier.align(Alignment.CenterEnd), onDropdownIconClick = onDropdownIconClick) if(dropDownState) dropDown() - PlayButton (modifier = Modifier.align(Alignment.CenterEnd)) { - onPlayIconClick() - } } - - - - - } } } @@ -109,22 +118,6 @@ private fun DropdownButton(modifier: Modifier = Modifier, onDropdownIconClick: ( } } -@Composable -private fun PlayButton(modifier: Modifier = Modifier, onPlayIconClick: () -> Unit) { - - IconButton( - modifier = modifier, - onClick = onPlayIconClick - ) { - Icon( - painter = painterResource(id = R.drawable.brainz_player_play_button), - contentDescription = "", - tint = ListenBrainzTheme.colorScheme.hint, - modifier = Modifier.padding(horizontal = ListenBrainzTheme.paddings.insideCard) - ) - } -} - @Composable private fun AlbumArt( coverArtUrl: String?, @@ -147,6 +140,4 @@ private fun AlbumArt( filterQuality = FilterQuality.Low, contentDescription = "Album Cover Art" ) -} - - +} \ No newline at end of file diff --git a/app/src/main/java/org/listenbrainz/android/ui/navigation/BottomNavigationBar.kt b/app/src/main/java/org/listenbrainz/android/ui/navigation/BottomNavigationBar.kt index 9471bfcf..0b22f0b3 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/navigation/BottomNavigationBar.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/navigation/BottomNavigationBar.kt @@ -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 @@ -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?, @@ -46,7 +48,7 @@ fun BottomNavigationBar( ) BottomNavigation( modifier = modifier, - backgroundColor = ListenBrainzTheme.colorScheme.nav, + backgroundColor = backgroundColor, elevation = 0.dp ) { val coroutineScope = rememberCoroutineScope() diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/AlbumsOverviewScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/AlbumsOverviewScreen.kt index 977a3a9e..d4cd5ea6 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/AlbumsOverviewScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/AlbumsOverviewScreen.kt @@ -54,14 +54,21 @@ fun AlbumsOverViewScreen( ) for (j in 1..albumsStarting[startingLetter]!!.size) { val coverArt = albumsStarting[startingLetter]!![j - 1].albumArt - BrainzPlayerListenCard(title = albumsStarting[startingLetter]!![j - 1].title, subTitle = albumsStarting[startingLetter]!![j - 1].artist, coverArtUrl = coverArt, errorAlbumArt = R.drawable.ic_erroralbumart, modifier = Modifier.padding( - start = 10.dp, - end = 10.dp, - top = 3.dp, - bottom = 3.dp - ), onPlayIconClick = { - onPlayIconClick(albumsStarting[startingLetter]!![j-1]) - }) + BrainzPlayerListenCard( + title = albumsStarting[startingLetter]!![j - 1].title, + subTitle = albumsStarting[startingLetter]!![j - 1].artist, + coverArtUrl = coverArt, + errorAlbumArt = R.drawable.ic_erroralbumart, + modifier = Modifier.padding( + start = 10.dp, + end = 10.dp, + top = 3.dp, + bottom = 3.dp + ), + onPlayIconClick = { + onPlayIconClick(albumsStarting[startingLetter]!![j-1]) + } + ) Spacer(modifier = Modifier.height(10.dp)) } } diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/ArtistsOverviewScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/ArtistsOverviewScreen.kt index 3a886e6b..f02324e3 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/ArtistsOverviewScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/ArtistsOverviewScreen.kt @@ -71,12 +71,30 @@ fun ArtistsOverviewScreen( val artist = artistsStarting[startingLetter]!![j-1] if (artistsStarting[startingLetter]!![j - 1].albums.isNotEmpty()) coverArt = artistsStarting[startingLetter]!![j - 1].albums[0].albumArt - BrainzPlayerListenCard(title = artistsStarting[startingLetter]!![j - 1].name, subTitle = when (artistsStarting[startingLetter]!![j - 1].songs.size) { - 1 -> "1 track" - else -> "${artistsStarting[startingLetter]!![j - 1].songs.size} tracks" - }, coverArtUrl = coverArt, errorAlbumArt = R.drawable.ic_artist, onPlayIconClick = { - onPlayClick(artistsStarting[startingLetter]!![j-1]) - }, modifier = Modifier.padding(start = 10.dp, end = 10.dp), dropDown = { BrainzPlayerDropDownMenu(onAddToNewPlaylist = {onAddToNewPlaylist(artist)}, onAddToExistingPlaylist = {onAddToExistingPlaylist(artist)},onAddToQueue = {onAddToQueue(artist)}, onPlayNext = {onPlayNext(artist)},expanded = dropdownState == Pair(i,j-1), onDismiss = {dropdownState = Pair(-1,-1)})}, onDropdownIconClick = {dropdownState = Pair(i,j-1)}, dropDownState = dropdownState == Pair(i,j-1)) + BrainzPlayerListenCard( + title = artistsStarting[startingLetter]!![j - 1].name, + subTitle = when (artistsStarting[startingLetter]!![j - 1].songs.size) { + 1 -> "1 track" + else -> "${artistsStarting[startingLetter]!![j - 1].songs.size} tracks" + }, + coverArtUrl = coverArt, + errorAlbumArt = R.drawable.ic_artist, + onPlayIconClick = { + onPlayClick(artistsStarting[startingLetter]!![j-1]) + }, + modifier = Modifier.padding(start = 10.dp, end = 10.dp), + dropDown = { + BrainzPlayerDropDownMenu( + onAddToNewPlaylist = {onAddToNewPlaylist(artist)}, + onAddToExistingPlaylist = {onAddToExistingPlaylist(artist)}, + onAddToQueue = {onAddToQueue(artist)}, + onPlayNext = {onPlayNext(artist)}, + expanded = dropdownState == Pair(i,j-1), + onDismiss = {dropdownState = Pair(-1,-1)} + ) + }, + onDropdownIconClick = {dropdownState = Pair(i,j-1)}, dropDownState = dropdownState == Pair(i,j-1) + ) Spacer(modifier = Modifier.height(10.dp)) } } diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/RecentPlaysOverviewScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/RecentPlaysOverviewScreen.kt index 593e0478..e6d6edad 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/RecentPlaysOverviewScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/RecentPlaysOverviewScreen.kt @@ -43,7 +43,7 @@ fun RecentPlaysScreen( .background( brush = ListenBrainzTheme.colorScheme.gradientBrush ) - .padding(top = 15.dp, bottom = 15.dp, start = 10.dp)) { + .padding(top = 15.dp, bottom = 15.dp, start = 10.dp, end = 10.dp)) { Text( "Played Today", color = ListenBrainzTheme.colorScheme.lbSignature, @@ -58,7 +58,7 @@ fun RecentPlaysScreen( .background( brush = ListenBrainzTheme.colorScheme.gradientBrush ) - .padding(top = 15.dp, bottom = 15.dp, start = 10.dp)) { + .padding(top = 15.dp, bottom = 15.dp, start = 10.dp, end = 10.dp)) { Text( "Played This Week", color = ListenBrainzTheme.colorScheme.lbSignature, @@ -87,14 +87,26 @@ private fun PlayedToday( )) { itemsIndexed(songsPlayedToday){ index, it -> - BrainzPlayerListenCard(title = it.title, subTitle = it.artist, coverArtUrl = it.albumArt, errorAlbumArt = R.drawable.ic_erroralbumart, onPlayIconClick = {onPlayIconClick(it)}, onDropdownIconClick = {dropDownState.value = Pair(1,index)}, dropDownState = dropDownState.value == Pair(1,index),dropDown = {BrainzPlayerDropDownMenu( - expanded = dropDownState.value == Pair(1,index), - onDismiss = {dropDownState.value = Pair(-1,-1)}, - onAddToQueue = {onAddToQueue(it)}, - onPlayNext = {onPlayNext(it)}, - onAddToExistingPlaylist = {onAddToExistingPlaylist(it)}, - onAddToNewPlaylist = {onAddToNewPlaylist(it)} - )}) + BrainzPlayerListenCard( + title = it.title, + subTitle = it.artist, + coverArtUrl = it.albumArt, + errorAlbumArt = R.drawable.ic_erroralbumart, + onPlayIconClick = { onPlayIconClick(it) }, + onDropdownIconClick = {dropDownState.value = Pair(1,index)}, + dropDownState = dropDownState.value == Pair(1,index), + dropDown = { + BrainzPlayerDropDownMenu( + expanded = dropDownState.value == Pair(1,index), + onDismiss = {dropDownState.value = Pair(-1,-1)}, + onAddToQueue = {onAddToQueue(it)}, + onPlayNext = {onPlayNext(it)}, + onAddToExistingPlaylist = {onAddToExistingPlaylist(it)}, + onAddToNewPlaylist = {onAddToNewPlaylist(it)} + ) + }, + mediaId = it.mediaID + ) Spacer(modifier = Modifier.height(5.dp)) } @@ -118,14 +130,25 @@ private fun PlayedThisWeek( )) { itemsIndexed(songsPlayedThisWeek){ index, it -> - BrainzPlayerListenCard(title = it.title, subTitle = it.artist, coverArtUrl = it.albumArt, errorAlbumArt = R.drawable.ic_erroralbumart, onPlayIconClick = {onPlayIconClick(it)}, onDropdownIconClick = {dropDownState.value = Pair(2,index)}, dropDownState = dropDownState.value == Pair(2,index),dropDown = {BrainzPlayerDropDownMenu( - expanded = dropDownState.value == Pair(2,index), - onDismiss = {dropDownState.value = Pair(-1,-1)}, - onAddToQueue = {onAddToQueue(it)}, - onPlayNext = {onPlayNext(it)}, - onAddToExistingPlaylist = {onAddToExistingPlaylist(it)}, - onAddToNewPlaylist = {onAddToNewPlaylist(it)} - )}) + BrainzPlayerListenCard( + title = it.title, + subTitle = it.artist, + coverArtUrl = it.albumArt, + errorAlbumArt = R.drawable.ic_erroralbumart, + onPlayIconClick = { onPlayIconClick(it) }, + onDropdownIconClick = { dropDownState.value = Pair(2,index) }, + dropDownState = dropDownState.value == Pair(2,index), + dropDown = { + BrainzPlayerDropDownMenu( + expanded = dropDownState.value == Pair(2,index), + onDismiss = {dropDownState.value = Pair(-1,-1)}, + onAddToQueue = {onAddToQueue(it)}, + onPlayNext = {onPlayNext(it)}, + onAddToExistingPlaylist = {onAddToExistingPlaylist(it)}, + onAddToNewPlaylist = {onAddToNewPlaylist(it)} + ) + } + ) Spacer(modifier = Modifier.height(5.dp)) } } diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/SongsOverviewScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/SongsOverviewScreen.kt index 845357a6..b67a7f1e 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/SongsOverviewScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/brainzplayer/overview/SongsOverviewScreen.kt @@ -56,9 +56,15 @@ fun SongsOverviewScreen( val song: Song = songsStarting[startingLetter]!![j-1] var coverArt: String? = null coverArt = songsStarting[startingLetter]!![j - 1].albumArt - BrainzPlayerListenCard(modifier = Modifier.padding(start= 10.dp, end = 10.dp),title = songsStarting[startingLetter]!![j - 1].title, subTitle = songsStarting[startingLetter]!![j - 1].artist, coverArtUrl = coverArt, errorAlbumArt = R.drawable.ic_erroralbumart){ - onPlayIconClick(song,songsStarting[startingLetter]!!) - } + BrainzPlayerListenCard( + modifier = Modifier.padding(start = 10.dp, end = 10.dp), + title = songsStarting[startingLetter]!![j - 1].title, + subTitle = songsStarting[startingLetter]!![j - 1].artist, + coverArtUrl = coverArt, + errorAlbumArt = R.drawable.ic_erroralbumart, + onPlayIconClick = { onPlayIconClick(song, songsStarting[startingLetter]!!) }, + mediaId = song.mediaID + ) Spacer(modifier = Modifier.height(10.dp)) } } diff --git a/app/src/main/java/org/listenbrainz/android/util/SongViewPager.kt b/app/src/main/java/org/listenbrainz/android/util/SongViewPager.kt index 25266c09..25d11467 100644 --- a/app/src/main/java/org/listenbrainz/android/util/SongViewPager.kt +++ b/app/src/main/java/org/listenbrainz/android/util/SongViewPager.kt @@ -113,7 +113,7 @@ fun SongViewPager( state = pagerState, modifier = modifier .fillMaxWidth() - .dynamicBackgroundFromAlbumArt(currentlyPlayingSong.albumArt) + .background(viewModel.playerBackGroundColor) ) { Column( modifier = Modifier diff --git a/app/src/main/java/org/listenbrainz/android/viewmodel/BrainzPlayerViewModel.kt b/app/src/main/java/org/listenbrainz/android/viewmodel/BrainzPlayerViewModel.kt index d4890ce9..8abd3747 100644 --- a/app/src/main/java/org/listenbrainz/android/viewmodel/BrainzPlayerViewModel.kt +++ b/app/src/main/java/org/listenbrainz/android/viewmodel/BrainzPlayerViewModel.kt @@ -70,6 +70,7 @@ class BrainzPlayerViewModel @Inject constructor( var isSearching by mutableStateOf(false) var playerBackGroundColor by mutableStateOf(Color.Transparent) + private set init { updatePlayerPosition() @@ -86,7 +87,6 @@ class BrainzPlayerViewModel @Inject constructor( it.toSong } _mediaItems.value = Resource(Resource.Status.SUCCESS, songs) - } }) viewModelScope.launch(Dispatchers.IO) {