mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
feat: dismiss chapters sheet when minimizing video
This commit is contained in:
parent
c881b6ff5c
commit
fd0b89cfc7
@ -517,7 +517,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
mainMotionLayout.progress = abs(progress)
|
mainMotionLayout.progress = abs(progress)
|
||||||
}
|
}
|
||||||
disableController()
|
disableController()
|
||||||
commentsViewModel.setCommentSheetExpand(false)
|
commonPlayerViewModel.setSheetExpand(false)
|
||||||
transitionEndId = endId
|
transitionEndId = endId
|
||||||
transitionStartId = startId
|
transitionStartId = startId
|
||||||
}
|
}
|
||||||
@ -530,7 +530,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
// re-enable captions
|
// re-enable captions
|
||||||
updateCurrentSubtitle(viewModel.currentSubtitle)
|
updateCurrentSubtitle(viewModel.currentSubtitle)
|
||||||
binding.player.useController = true
|
binding.player.useController = true
|
||||||
commentsViewModel.setCommentSheetExpand(true)
|
commonPlayerViewModel.setSheetExpand(true)
|
||||||
mainMotionLayout.progress = 0F
|
mainMotionLayout.progress = 0F
|
||||||
changeOrientationMode()
|
changeOrientationMode()
|
||||||
} else if (currentId == transitionEndId) {
|
} else if (currentId == transitionEndId) {
|
||||||
@ -538,7 +538,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
// disable captions temporarily
|
// disable captions temporarily
|
||||||
updateCurrentSubtitle(null)
|
updateCurrentSubtitle(null)
|
||||||
disableController()
|
disableController()
|
||||||
commentsViewModel.setCommentSheetExpand(null)
|
commonPlayerViewModel.setSheetExpand(null)
|
||||||
binding.sbSkipBtn.isGone = true
|
binding.sbSkipBtn.isGone = true
|
||||||
if (NavBarHelper.hasTabs()) {
|
if (NavBarHelper.hasTabs()) {
|
||||||
mainMotionLayout.progress = 1F
|
mainMotionLayout.progress = 1F
|
||||||
@ -773,7 +773,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
updateFullscreenOrientation()
|
updateFullscreenOrientation()
|
||||||
|
|
||||||
commentsViewModel.setCommentSheetExpand(null)
|
commonPlayerViewModel.setSheetExpand(null)
|
||||||
|
|
||||||
updateResolution(true)
|
updateResolution(true)
|
||||||
openOrCloseFullscreenDialog(true)
|
openOrCloseFullscreenDialog(true)
|
||||||
|
@ -30,22 +30,13 @@ class CommentsViewModel : ViewModel() {
|
|||||||
private val _commentCountLiveData = MutableLiveData<Long>()
|
private val _commentCountLiveData = MutableLiveData<Long>()
|
||||||
val commentCountLiveData: LiveData<Long> = _commentCountLiveData
|
val commentCountLiveData: LiveData<Long> = _commentCountLiveData
|
||||||
|
|
||||||
val commentSheetExpand = MutableLiveData<Boolean?>()
|
|
||||||
|
|
||||||
private val _currentCommentsPosition = MutableLiveData(0)
|
private val _currentCommentsPosition = MutableLiveData(0)
|
||||||
val currentCommentsPosition: LiveData<Int> = _currentCommentsPosition
|
val currentCommentsPosition: LiveData<Int> = _currentCommentsPosition
|
||||||
|
|
||||||
private val _currentRepliesPosition = MutableLiveData(0)
|
private val _currentRepliesPosition = MutableLiveData(0)
|
||||||
val currentRepliesPosition: LiveData<Int> = _currentRepliesPosition
|
val currentRepliesPosition: LiveData<Int> = _currentRepliesPosition
|
||||||
|
|
||||||
fun setCommentSheetExpand(value: Boolean?) {
|
|
||||||
if (commentSheetExpand.value != value) {
|
|
||||||
commentSheetExpand.value = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
setCommentSheetExpand(null)
|
|
||||||
_currentCommentsPosition.value = 0
|
_currentCommentsPosition.value = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,16 @@ package com.github.libretube.ui.models
|
|||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import com.github.libretube.extensions.updateIfChanged
|
||||||
|
|
||||||
class CommonPlayerViewModel : ViewModel() {
|
class CommonPlayerViewModel : ViewModel() {
|
||||||
val isMiniPlayerVisible = MutableLiveData(false)
|
val isMiniPlayerVisible = MutableLiveData(false)
|
||||||
val isFullscreen = MutableLiveData(false)
|
val isFullscreen = MutableLiveData(false)
|
||||||
var maxSheetHeightPx = 0
|
var maxSheetHeightPx = 0
|
||||||
|
|
||||||
|
val sheetExpand = MutableLiveData<Boolean?>()
|
||||||
|
|
||||||
|
fun setSheetExpand(state: Boolean?) {
|
||||||
|
sheetExpand.updateIfChanged(state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import com.github.libretube.databinding.BottomSheetBinding
|
|||||||
import com.github.libretube.ui.adapters.ChaptersAdapter
|
import com.github.libretube.ui.adapters.ChaptersAdapter
|
||||||
import com.github.libretube.ui.models.ChaptersViewModel
|
import com.github.libretube.ui.models.ChaptersViewModel
|
||||||
|
|
||||||
class ChaptersBottomSheet : UndimmedBottomSheet() {
|
class ChaptersBottomSheet : ExpandablePlayerSheet() {
|
||||||
private var _binding: BottomSheetBinding? = null
|
private var _binding: BottomSheetBinding? = null
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
@ -12,15 +12,13 @@ import androidx.fragment.app.setFragmentResult
|
|||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.databinding.CommentsSheetBinding
|
import com.github.libretube.databinding.CommentsSheetBinding
|
||||||
import com.github.libretube.ui.fragments.CommentsMainFragment
|
import com.github.libretube.ui.fragments.CommentsMainFragment
|
||||||
import com.github.libretube.ui.models.CommentsViewModel
|
|
||||||
import com.github.libretube.ui.models.CommonPlayerViewModel
|
import com.github.libretube.ui.models.CommonPlayerViewModel
|
||||||
|
|
||||||
class CommentsSheet : UndimmedBottomSheet() {
|
class CommentsSheet : ExpandablePlayerSheet() {
|
||||||
private var _binding: CommentsSheetBinding? = null
|
private var _binding: CommentsSheetBinding? = null
|
||||||
val binding get() = _binding!!
|
val binding get() = _binding!!
|
||||||
|
|
||||||
private val commonPlayerViewModel: CommonPlayerViewModel by activityViewModels()
|
private val commonPlayerViewModel: CommonPlayerViewModel by activityViewModels()
|
||||||
private val commentsViewModel: CommentsViewModel by activityViewModels()
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
@ -56,15 +54,6 @@ class CommentsSheet : UndimmedBottomSheet() {
|
|||||||
childFragmentManager.commit {
|
childFragmentManager.commit {
|
||||||
replace<CommentsMainFragment>(R.id.commentFragContainer, args = arguments)
|
replace<CommentsMainFragment>(R.id.commentFragContainer, args = arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
commentsViewModel.setCommentSheetExpand(true)
|
|
||||||
commentsViewModel.commentSheetExpand.observe(viewLifecycleOwner) {
|
|
||||||
when (it) {
|
|
||||||
true -> expand()
|
|
||||||
false -> expand(true)
|
|
||||||
else -> dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.github.libretube.ui.sheets
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.github.libretube.ui.models.CommonPlayerViewModel
|
||||||
|
|
||||||
|
abstract class ExpandablePlayerSheet: UndimmedBottomSheet() {
|
||||||
|
private val commonPlayerViewModel: CommonPlayerViewModel by activityViewModels()
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
commonPlayerViewModel.setSheetExpand(true)
|
||||||
|
commonPlayerViewModel.sheetExpand.observe(viewLifecycleOwner) {
|
||||||
|
when (it) {
|
||||||
|
true -> expand()
|
||||||
|
false -> expand(true)
|
||||||
|
else -> dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
commonPlayerViewModel.setSheetExpand(null)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user