Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWN-9014 - striga. kyc pending bottom sheet #1865

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -310,6 +311,10 @@ class HomeFragment :
replaceFragment(strigaKycFragmentFactory.kycFragment())
}

override fun showKycPendingDialog() {
StrigaKycPendingBottomSheet.show(parentFragmentManager)
}

override fun showTopupWalletDialog() {
TopUpWalletBottomSheet.show(parentFragmentManager)
}
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/org/p2p/wallet/home/ui/main/HomePresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -75,6 +77,7 @@ object StrigaSignupModule : InjectionModule {
bind<SmsInputContract.Presenter>()
named(SmsInputFactory.Type.Striga.name)
}
factoryOf(::StrigaSignupFinishPresenter) bind StrigaSignupFinishContract.Presenter::class
}

private fun Module.initDataLayer() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<MvpView>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,15 +15,15 @@ import org.p2p.wallet.utils.popBackStackTo
import org.p2p.wallet.utils.replaceFragment
import org.p2p.wallet.utils.viewbinding.viewBinding

class StrigaSignupFinishFragment : BaseMvpFragment<MvpView, NoOpPresenter<MvpView>>(
class StrigaSignupFinishFragment : BaseMvpFragment<MvpView, StrigaSignupFinishContract.Presenter>(
R.layout.fragment_striga_signup_finish
) {

companion object {
fun create(): StrigaSignupFinishFragment = StrigaSignupFinishFragment()
}

override val presenter = NoOpPresenter<MvpView>()
override val presenter: StrigaSignupFinishContract.Presenter by inject()

private val binding: FragmentStrigaSignupFinishBinding by viewBinding()

Expand Down
Original file line number Diff line number Diff line change
@@ -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<MvpView>(dispatchers.ui), StrigaSignupFinishContract.Presenter {

init {
appScope.launch(dispatchers.io) {
strigaUserInteractor.loadAndSaveUserStatusData()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe lifecycleScope.launch would be ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's safer to launch in a global context, who knows how quickly the response will arrive

}
}
}
Original file line number Diff line number Diff line change
@@ -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<MvpView, NoOpPresenter<MvpView>>(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<MvpView> = 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()
}
}
}
80 changes: 80 additions & 0 deletions app/src/main/res/layout/dialog_striga_kyc_pending.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/bg_snow_rounded_16"
android:backgroundTint="@color/bg_smoke">

<View
android:id="@+id/viewPointer"
android:layout_width="32dp"
android:layout_height="4dp"
android:layout_marginTop="6dp"
android:background="@drawable/shape_bottomsheet_pointer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/imageViewMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:src="@drawable/ic_clock"
app:layout_constraintBottom_toTopOf="@id/textViewTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/viewPointer" />

<TextView
android:id="@+id/textViewTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:paddingHorizontal="20dp"
android:text="@string/striga_dialog_kyc_pending_title"
android:textAlignment="center"
android:textAppearance="@style/UiKit.TextAppearance.SemiBold.Title2"
app:layout_constraintBottom_toTopOf="@id/textViewSubtitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/imageViewMain" />

<TextView
android:id="@+id/textViewSubtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:paddingHorizontal="20dp"
android:text="@string/striga_dialog_kyc_pending_subtitle"
android:textAlignment="center"
android:textAppearance="@style/UiKit.TextAppearance.Regular.Text3"
app:layout_constraintBottom_toTopOf="@id/buttonDone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textViewTitle" />

<org.p2p.uikit.components.UiKitButton
android:id="@+id/buttonDone"
style="@style/UiKit.Components.Button.Large"
android:layout_width="match_parent"
android:layout_height="@dimen/ui_kit_button_large_height"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="64dp"
android:backgroundTint="@color/night"
android:text="@string/common_got_it"
android:textColor="@color/lime"
app:iconTint="@color/night"
app:layout_constraintBottom_toTopOf="@id/space"
app:layout_constraintTop_toBottomOf="@id/textViewSubtitle" />

<Space
android:id="@+id/space"
android:layout_width="0dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/striga_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,8 @@
<string name="striga_kyc_signup_banner_identify_subtitle" />
<string name="striga_kyc_signup_banner_identify_action">Continue</string>

<string name="striga_dialog_kyc_pending_title">Your KYC verification is pending</string>
<string name="striga_dialog_kyc_pending_subtitle">We will update the status once it is finished</string>


</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<string name="common_close">Close</string>
<string name="common_reload">Reload</string>
<string name="common_great">Great!</string>
<string name="common_got_it">Got it</string>
<string name="common_settings">Settings</string>
<string name="common_copied">Copied to clipboard</string>
<string name="common_copied_with_emoji">👯‍ Copied to the clipboard</string>
Expand Down
Loading