diff --git a/auth/src/main/java/org/futo/circles/auth/feature/uia/UIADialogFragment.kt b/auth/src/main/java/org/futo/circles/auth/feature/uia/UIADialogFragment.kt index 246475f862a72026bef1429ab8c43d52452c9592..9e388e25924c96fa1ceee881b1aa04a30b44c4f5 100644 --- a/auth/src/main/java/org/futo/circles/auth/feature/uia/UIADialogFragment.kt +++ b/auth/src/main/java/org/futo/circles/auth/feature/uia/UIADialogFragment.kt @@ -1,5 +1,6 @@ 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()