Skip to content

Commit

Permalink
fix : allow swiping down in audio player to minimize audio player
Browse files Browse the repository at this point in the history
Added a function that allows to minimize audio player by swiping down
  • Loading branch information
akashs056 committed Feb 23, 2024
1 parent 4c8389a commit 4003537
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
binding.uploader.isSelected = true

binding.minimizePlayer.setOnClickListener {
val mainMotionLayout = mainActivity.binding.mainMotionLayout
mainMotionLayout.transitionToStart()
binding.playerMotionLayout.transitionToEnd()
minimizePlayer()
}

binding.autoPlay.isChecked = PlayerHelper.autoPlayEnabled
Expand Down Expand Up @@ -207,6 +205,12 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
if (!PlayerHelper.playAutomatically) updatePlayPauseButton()
}

private fun minimizePlayer() {
val mainMotionLayout = mainActivity.binding.mainMotionLayout
mainMotionLayout.transitionToStart()
binding.playerMotionLayout.transitionToEnd()
}

private fun killFragment() {
viewModel.isFullscreen.value = false
binding.playerMotionLayout.transitionToEnd()
Expand Down Expand Up @@ -251,6 +255,10 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
}
})

binding.playerMotionLayout.addSwipeDownListener {
minimizePlayer()
}

if (arguments?.getBoolean(IntentData.minimizeByDefault, false) != true) {
binding.playerMotionLayout.progress = 1f
binding.playerMotionLayout.transitionToStart()
Expand Down

1 comment on commit 4003537

@akashs056
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploading issue.mp4…

Please sign in to comment.