From cbc63952a33dcc7f3a954b57fd9a444ae0f5fdee Mon Sep 17 00:00:00 2001 From: Eduard Maximovich Date: Wed, 21 Jun 2023 17:48:36 +0400 Subject: [PATCH] PWN-9014 - striga. kyc pending bottom sheet --- .../p2p/wallet/home/ui/main/HomeContract.kt | 1 + .../p2p/wallet/home/ui/main/HomeFragment.kt | 5 ++ .../p2p/wallet/home/ui/main/HomePresenter.kt | 15 +++- .../wallet/striga/di/StrigaSignupModule.kt | 3 + .../finish/StrigaSignupFinishContract.kt | 9 +++ .../finish/StrigaSignupFinishFragment.kt | 6 +- .../finish/StrigaSignupFinishPresenter.kt | 21 +++++ .../striga/ui/StrigaKycPendingBottomSheet.kt | 37 +++++++++ .../res/layout/dialog_striga_kyc_pending.xml | 80 +++++++++++++++++++ app/src/main/res/values/striga_strings.xml | 3 + app/src/main/res/values/strings.xml | 1 + 11 files changed, 174 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishContract.kt create mode 100644 app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishPresenter.kt create mode 100644 app/src/main/java/org/p2p/wallet/striga/ui/StrigaKycPendingBottomSheet.kt create mode 100644 app/src/main/res/layout/dialog_striga_kyc_pending.xml diff --git a/app/src/main/java/org/p2p/wallet/home/ui/main/HomeContract.kt b/app/src/main/java/org/p2p/wallet/home/ui/main/HomeContract.kt index 2d5b710cea..b18aa62b52 100644 --- a/app/src/main/java/org/p2p/wallet/home/ui/main/HomeContract.kt +++ b/app/src/main/java/org/p2p/wallet/home/ui/main/HomeContract.kt @@ -42,6 +42,7 @@ interface HomeContract { fun navigateToBuyScreen(token: Token) fun navigateToNewBuyScreen(token: Token, fiatToken: String, fiatAmount: String?) fun navigateToKycStatus(status: StrigaKycStatusBanner) + fun showKycPendingDialog() fun showTopupWalletDialog() } diff --git a/app/src/main/java/org/p2p/wallet/home/ui/main/HomeFragment.kt b/app/src/main/java/org/p2p/wallet/home/ui/main/HomeFragment.kt index ad67b72f33..5f165cb8f5 100644 --- a/app/src/main/java/org/p2p/wallet/home/ui/main/HomeFragment.kt +++ b/app/src/main/java/org/p2p/wallet/home/ui/main/HomeFragment.kt @@ -53,6 +53,7 @@ import org.p2p.wallet.receive.solana.ReceiveSolanaFragment import org.p2p.wallet.root.RootListener import org.p2p.wallet.sell.ui.payload.SellPayloadFragment import org.p2p.wallet.settings.ui.settings.SettingsFragment +import org.p2p.wallet.striga.ui.StrigaKycPendingBottomSheet import org.p2p.wallet.striga.ui.TopUpWalletBottomSheet import org.p2p.wallet.transaction.model.NewShowProgress import org.p2p.wallet.utils.HomeScreenLayoutManager @@ -310,6 +311,10 @@ class HomeFragment : replaceFragment(strigaKycFragmentFactory.kycFragment()) } + override fun showKycPendingDialog() { + StrigaKycPendingBottomSheet.show(parentFragmentManager) + } + override fun showTopupWalletDialog() { TopUpWalletBottomSheet.show(parentFragmentManager) } diff --git a/app/src/main/java/org/p2p/wallet/home/ui/main/HomePresenter.kt b/app/src/main/java/org/p2p/wallet/home/ui/main/HomePresenter.kt index 35d89c0e9b..dbced379de 100644 --- a/app/src/main/java/org/p2p/wallet/home/ui/main/HomePresenter.kt +++ b/app/src/main/java/org/p2p/wallet/home/ui/main/HomePresenter.kt @@ -59,6 +59,7 @@ import org.p2p.wallet.infrastructure.network.provider.TokenKeyProvider import org.p2p.wallet.infrastructure.transactionmanager.TransactionManager import org.p2p.wallet.intercom.IntercomDeeplinkManager import org.p2p.wallet.intercom.IntercomService +import org.p2p.wallet.kyc.model.StrigaKycStatusBanner import org.p2p.wallet.kyc.model.StrigaKycUiBannerMapper import org.p2p.wallet.moonpay.analytics.BuyAnalytics import org.p2p.wallet.newsend.analytics.NewSendAnalytics @@ -333,10 +334,16 @@ class HomePresenter( override fun onBannerClicked(bannerTitleId: Int) { val statusFromKycBanner = strigaUiBannerMapper.onBannerClicked(bannerTitleId) - if (statusFromKycBanner != null) { - view?.navigateToKycStatus(statusFromKycBanner) - } else { - view?.showTopupWalletDialog() + when { + statusFromKycBanner == StrigaKycStatusBanner.PENDING -> { + view?.showKycPendingDialog() + } + statusFromKycBanner != null -> { + view?.navigateToKycStatus(statusFromKycBanner) + } + else -> { + view?.showTopupWalletDialog() + } } } diff --git a/app/src/main/java/org/p2p/wallet/striga/di/StrigaSignupModule.kt b/app/src/main/java/org/p2p/wallet/striga/di/StrigaSignupModule.kt index ae443ce355..406da8e14a 100644 --- a/app/src/main/java/org/p2p/wallet/striga/di/StrigaSignupModule.kt +++ b/app/src/main/java/org/p2p/wallet/striga/di/StrigaSignupModule.kt @@ -21,6 +21,8 @@ import org.p2p.wallet.smsinput.SmsInputFactory import org.p2p.wallet.smsinput.striga.StrigaSmsInputInteractor import org.p2p.wallet.smsinput.striga.StrigaSmsInputPresenter import org.p2p.wallet.striga.StrigaUserIdProvider +import org.p2p.wallet.striga.finish.StrigaSignupFinishContract +import org.p2p.wallet.striga.finish.StrigaSignupFinishPresenter import org.p2p.wallet.striga.onboarding.StrigaOnboardingContract import org.p2p.wallet.striga.onboarding.StrigaOnboardingPresenter import org.p2p.wallet.striga.onboarding.interactor.StrigaOnboardingInteractor @@ -75,6 +77,7 @@ object StrigaSignupModule : InjectionModule { bind() named(SmsInputFactory.Type.Striga.name) } + factoryOf(::StrigaSignupFinishPresenter) bind StrigaSignupFinishContract.Presenter::class } private fun Module.initDataLayer() { diff --git a/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishContract.kt b/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishContract.kt new file mode 100644 index 0000000000..7a1a472f6b --- /dev/null +++ b/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishContract.kt @@ -0,0 +1,9 @@ +package org.p2p.wallet.striga.finish + +import org.p2p.wallet.common.mvp.MvpPresenter +import org.p2p.wallet.common.mvp.MvpView + +interface StrigaSignupFinishContract { + + interface Presenter : MvpPresenter +} diff --git a/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishFragment.kt b/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishFragment.kt index 910f13373a..edbc1b262f 100644 --- a/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishFragment.kt +++ b/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishFragment.kt @@ -3,10 +3,10 @@ package org.p2p.wallet.striga.finish import androidx.activity.addCallback import android.os.Bundle import android.view.View +import org.koin.android.ext.android.inject import org.p2p.wallet.R import org.p2p.wallet.common.mvp.BaseMvpFragment import org.p2p.wallet.common.mvp.MvpView -import org.p2p.wallet.common.mvp.NoOpPresenter import org.p2p.wallet.databinding.FragmentStrigaSignupFinishBinding import org.p2p.wallet.home.ui.container.MainContainerFragment import org.p2p.wallet.intercom.IntercomService @@ -15,7 +15,7 @@ import org.p2p.wallet.utils.popBackStackTo import org.p2p.wallet.utils.replaceFragment import org.p2p.wallet.utils.viewbinding.viewBinding -class StrigaSignupFinishFragment : BaseMvpFragment>( +class StrigaSignupFinishFragment : BaseMvpFragment( R.layout.fragment_striga_signup_finish ) { @@ -23,7 +23,7 @@ class StrigaSignupFinishFragment : BaseMvpFragment() + override val presenter: StrigaSignupFinishContract.Presenter by inject() private val binding: FragmentStrigaSignupFinishBinding by viewBinding() diff --git a/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishPresenter.kt b/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishPresenter.kt new file mode 100644 index 0000000000..bbf5b47dd6 --- /dev/null +++ b/app/src/main/java/org/p2p/wallet/striga/finish/StrigaSignupFinishPresenter.kt @@ -0,0 +1,21 @@ +package org.p2p.wallet.striga.finish + +import kotlinx.coroutines.launch +import org.p2p.wallet.common.di.AppScope +import org.p2p.wallet.common.mvp.BasePresenter +import org.p2p.wallet.common.mvp.MvpView +import org.p2p.wallet.infrastructure.dispatchers.CoroutineDispatchers +import org.p2p.wallet.striga.user.interactor.StrigaUserInteractor + +class StrigaSignupFinishPresenter( + private val strigaUserInteractor: StrigaUserInteractor, + appScope: AppScope, + dispatchers: CoroutineDispatchers, +) : BasePresenter(dispatchers.ui), StrigaSignupFinishContract.Presenter { + + init { + appScope.launch(dispatchers.io) { + strigaUserInteractor.loadAndSaveUserStatusData() + } + } +} diff --git a/app/src/main/java/org/p2p/wallet/striga/ui/StrigaKycPendingBottomSheet.kt b/app/src/main/java/org/p2p/wallet/striga/ui/StrigaKycPendingBottomSheet.kt new file mode 100644 index 0000000000..44008f164a --- /dev/null +++ b/app/src/main/java/org/p2p/wallet/striga/ui/StrigaKycPendingBottomSheet.kt @@ -0,0 +1,37 @@ +package org.p2p.wallet.striga.ui + +import androidx.fragment.app.FragmentManager +import android.os.Bundle +import android.view.View +import org.p2p.wallet.R +import org.p2p.wallet.common.mvp.BaseMvpBottomSheet +import org.p2p.wallet.common.mvp.MvpView +import org.p2p.wallet.common.mvp.NoOpPresenter +import org.p2p.wallet.databinding.DialogStrigaKycPendingBinding +import org.p2p.wallet.utils.viewbinding.viewBinding + +class StrigaKycPendingBottomSheet : + BaseMvpBottomSheet>(R.layout.dialog_striga_kyc_pending) { + + companion object { + fun show(fm: FragmentManager) { + val tag = StrigaKycPendingBottomSheet::javaClass.name + if (fm.findFragmentByTag(tag) != null) return + StrigaKycPendingBottomSheet().show(fm, tag) + } + } + + override val presenter: NoOpPresenter = NoOpPresenter() + + private val binding: DialogStrigaKycPendingBinding by viewBinding() + + override fun getTheme(): Int = R.style.WalletTheme_BottomSheet_RoundedSnow + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.buttonDone.setOnClickListener { + dismiss() + } + } +} diff --git a/app/src/main/res/layout/dialog_striga_kyc_pending.xml b/app/src/main/res/layout/dialog_striga_kyc_pending.xml new file mode 100644 index 0000000000..94cdf26342 --- /dev/null +++ b/app/src/main/res/layout/dialog_striga_kyc_pending.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/striga_strings.xml b/app/src/main/res/values/striga_strings.xml index be7a2e092d..957e2623d8 100644 --- a/app/src/main/res/values/striga_strings.xml +++ b/app/src/main/res/values/striga_strings.xml @@ -119,5 +119,8 @@ Continue + Your KYC verification is pending + We will update the status once it is finished + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3df88d5804..1a0a16cc63 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,6 +12,7 @@ Close Reload Great! + Got it Settings Copied to clipboard 👯‍ Copied to the clipboard