allowing the child ftue fragments to determine if they're the back action is a hard exit

This commit is contained in:
Adam Brown 2022-07-26 11:53:04 +01:00
parent abab2a0db7
commit c66b1885ad

View file

@ -46,6 +46,7 @@ abstract class AbstractFtueAuthFragment<VB : ViewBinding> : VectorBaseFragment<V
// Due to async, we keep a boolean to avoid displaying twice the cancellation dialog // Due to async, we keep a boolean to avoid displaying twice the cancellation dialog
private var displayCancelDialog = true private var displayCancelDialog = true
protected open fun backIsHardExit() = true
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -115,7 +116,7 @@ abstract class AbstractFtueAuthFragment<VB : ViewBinding> : VectorBaseFragment<V
override fun onBackPressed(toolbarButton: Boolean): Boolean { override fun onBackPressed(toolbarButton: Boolean): Boolean {
return when { return when {
displayCancelDialog && viewModel.isRegistrationStarted -> { displayCancelDialog && viewModel.isRegistrationStarted && backIsHardExit() -> {
// Ask for confirmation before cancelling the registration // Ask for confirmation before cancelling the registration
MaterialAlertDialogBuilder(requireActivity()) MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.login_signup_cancel_confirmation_title) .setTitle(R.string.login_signup_cancel_confirmation_title)