Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/src/main/java/com/github/libretube/ui/sheets/CommentsSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.ComponentDialog
import androidx.activity.addCallback
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.commit
Expand All @@ -20,6 +22,14 @@ class CommentsSheet : ExpandablePlayerSheet() {

private val commonPlayerViewModel: CommonPlayerViewModel by activityViewModels()

private val backPressedCallback by lazy(LazyThreadSafetyMode.NONE) {
(dialog as ComponentDialog?)?.onBackPressedDispatcher?.addCallback(owner = viewLifecycleOwner, enabled = false) {
if (childFragmentManager.backStackEntryCount > 0) {
childFragmentManager.popBackStack()
}
}
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down Expand Up @@ -70,6 +80,7 @@ class CommentsSheet : ExpandablePlayerSheet() {
fun updateFragmentInfo(showBackButton: Boolean, title: String) {
binding.btnBack.isVisible = showBackButton
binding.commentsTitle.text = title
backPressedCallback?.isEnabled = showBackButton
}

companion object {
Expand Down
Loading