Skip to content
Snippets Groups Projects
Commit 800b4b9c authored by Taras's avatar Taras
Browse files

Fix showing discard dialog

parent 55eb6454
No related branches found
No related tags found
No related merge requests found
package org.futo.circles.auth.feature.uia
import android.app.Dialog
import android.net.Uri
import android.os.Bundle
import android.view.View
......@@ -54,6 +55,14 @@ class UIADialogFragment :
childFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
object : Dialog(requireContext(), theme) {
@Suppress("OVERRIDE_DEPRECATION")
override fun onBackPressed() {
activity?.onBackPressedDispatcher?.onBackPressed()
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupViews()
......@@ -71,7 +80,7 @@ class UIADialogFragment :
else -> R.string.log_in
}
)
setNavigationOnClickListener { onBackPressed() }
setNavigationOnClickListener { handleBackAction() }
}
}
......@@ -178,10 +187,14 @@ class UIADialogFragment :
}
override fun onChildBackPress(callback: OnBackPressedCallback) {
handleBackAction(callback)
}
private fun handleBackAction(callback: OnBackPressedCallback? = null) {
val includedFragmentsManager = childNavHostFragment.childFragmentManager
if (includedFragmentsManager.backStackEntryCount == 1) {
cancelReAuth()
callback.remove()
callback?.remove()
onBackPressed()
} else {
showDiscardDialog()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment