From 4964c9f15114b83c042fb08326a7f5d964658b45 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 27 Apr 2022 16:49:05 +0100 Subject: [PATCH] showing loading spinner when returning to the email verification waiting screen --- .../ftueauth/FtueAuthWaitForEmailFragment.kt | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt index 7dc18ab283..9bd2eaf0d7 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt @@ -21,6 +21,7 @@ import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import com.airbnb.mvrx.args import im.vector.app.R import im.vector.app.databinding.FragmentFtueWaitForEmailVerificationBinding @@ -41,6 +42,7 @@ data class FtueAuthWaitForEmailFragmentArgument( class FtueAuthWaitForEmailFragment @Inject constructor() : AbstractFtueAuthFragment() { private val params: FtueAuthWaitForEmailFragmentArgument by args() + private var inferHasLeftAndReturnedToScreen = false override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueWaitForEmailVerificationBinding { return FragmentFtueWaitForEmailVerificationBinding.inflate(inflater, container, false) @@ -51,20 +53,30 @@ class FtueAuthWaitForEmailFragment @Inject constructor() : AbstractFtueAuthFragm setupUi() } + private fun setupUi() { + views.accountCreatedSubtitle.text = getString(R.string.ftue_auth_email_verification_subtitle, params.email) + } + override fun onResume() { super.onResume() + showLoadingIfReturningToScreen() viewModel.handle(OnboardingAction.PostRegisterAction(RegisterAction.CheckIfEmailHasBeenValidated(0))) } + private fun showLoadingIfReturningToScreen() { + when (inferHasLeftAndReturnedToScreen){ + true -> views.accountCreatedWaiting.isVisible = true + false -> { + inferHasLeftAndReturnedToScreen = true + } + } + } + override fun onPause() { super.onPause() viewModel.handle(OnboardingAction.StopEmailValidationCheck) } - private fun setupUi() { - views.accountCreatedSubtitle.text = getString(R.string.ftue_auth_email_verification_subtitle, params.email) - } - override fun resetViewModel() { viewModel.handle(OnboardingAction.ResetAuthenticationAttempt) }