mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
fix: back navigation from comment replies (#6954)
This commit is contained in:
parent
fc4055289e
commit
aef23e26e5
@ -4,6 +4,8 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.activity.ComponentDialog
|
||||||
|
import androidx.activity.addCallback
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.fragment.app.commit
|
import androidx.fragment.app.commit
|
||||||
@ -20,6 +22,14 @@ class CommentsSheet : ExpandablePlayerSheet() {
|
|||||||
|
|
||||||
private val commonPlayerViewModel: CommonPlayerViewModel by activityViewModels()
|
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(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
@ -70,6 +80,7 @@ class CommentsSheet : ExpandablePlayerSheet() {
|
|||||||
fun updateFragmentInfo(showBackButton: Boolean, title: String) {
|
fun updateFragmentInfo(showBackButton: Boolean, title: String) {
|
||||||
binding.btnBack.isVisible = showBackButton
|
binding.btnBack.isVisible = showBackButton
|
||||||
binding.commentsTitle.text = title
|
binding.commentsTitle.text = title
|
||||||
|
backPressedCallback?.isEnabled = showBackButton
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user