Skip to content

Commit

Permalink
Fixed BackHandler logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pakka-papad committed Dec 2, 2023
1 parent 20f6973 commit 5a0eca9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/src/main/java/com/github/pakka_papad/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,19 @@ class HomeFragment : Fragment() {

val isExplorerAtRoot by viewModel.isExplorerAtRoot.collectAsStateWithLifecycle()

val isQueueBottomSheetExpanded by remember(playerScaffoldState.bottomSheetState) {
derivedStateOf {
playerScaffoldState.bottomSheetState.currentValue
.equals(SheetValue.Expanded)
}
}

BackHandler(
enabled = (currentScreen == Screens.Folders && !isExplorerAtRoot) || swipeableState.currentValue == 1,
onBack = {
if (swipeableState.currentValue == 1){
scope.launch {
if (playerScaffoldState.bottomSheetState.hasExpandedState) playerScaffoldState.bottomSheetState.hide()
if (isQueueBottomSheetExpanded) playerScaffoldState.bottomSheetState.hide()
else swipeableState.animateTo(0)
}
} else {
Expand Down Expand Up @@ -427,7 +434,7 @@ class HomeFragment : Fragment() {
queue = queue,
onFavouriteClicked = viewModel::changeFavouriteValue,
currentSong = it,
expanded = playerScaffoldState.bottomSheetState.hasExpandedState,
expanded = isQueueBottomSheetExpanded,
exoPlayer = exoPlayer,
onDrag = viewModel::onSongDrag
)
Expand Down

0 comments on commit 5a0eca9

Please sign in to comment.