Skip to content

Commit

Permalink
Merge pull request #512 from GautamCoder4019k/handle_back_press_in_pl…
Browse files Browse the repository at this point in the history
…ayer_screen

Fix: Back Press in Player Screen Does Not Close the Player
  • Loading branch information
07jasjeet authored Dec 27, 2024
2 parents 5624236 + 89ea0be commit 63f5aba
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.listenbrainz.android.ui.screens.brainzplayer


import androidx.activity.compose.BackHandler
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
Expand Down Expand Up @@ -144,7 +145,8 @@ fun BrainzPlayerBackDropScreen(
PlayerScreen(
currentlyPlayingSong = currentlyPlayingSong,
isShuffled = isShuffled,
repeatMode = repeatMode
repeatMode = repeatMode,
backdropScaffoldState = backdropScaffoldState
)
val songList = brainzPlayerViewModel.mediaItem.collectAsState().value.data ?: listOf()
SongViewPager(
Expand All @@ -165,7 +167,8 @@ fun PlayerScreen(
brainzPlayerViewModel: BrainzPlayerViewModel = viewModel(),
currentlyPlayingSong: Song,
isShuffled: Boolean,
repeatMode: RepeatMode
repeatMode: RepeatMode,
backdropScaffoldState: BackdropScaffoldState,
) {
val coroutineScope = rememberCoroutineScope()
val playlistViewModel = hiltViewModel<PlaylistViewModel>()
Expand All @@ -182,6 +185,14 @@ fun PlayerScreen(
} else {
println("Playlist is empty")
}

if(backdropScaffoldState.isConcealed){
BackHandler {
coroutineScope.launch {
backdropScaffoldState.reveal()
}
}
}
LazyColumn {
item {
songList.data?.let {
Expand Down

0 comments on commit 63f5aba

Please sign in to comment.