Updated on 2026-08-14
This commit is contained in:
parent
cea4ba817a
commit
737bb507d9
19 changed files with 221 additions and 75 deletions
|
|
@ -6,11 +6,14 @@ import com.tangem.core.decompose.ui.UiMessageSender
|
|||
import com.tangem.core.res.R
|
||||
import com.tangem.core.ui.components.bottomsheets.message.*
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.message.DialogMessage
|
||||
import com.tangem.core.ui.message.EventMessageAction
|
||||
import com.tangem.core.ui.message.bottomSheetMessage
|
||||
import com.tangem.domain.feedback.GetWalletMetaInfoUseCase
|
||||
import com.tangem.domain.feedback.SendFeedbackEmailUseCase
|
||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.pay.TangemPayDetailsConfig
|
||||
import com.tangem.domain.pay.repository.OnboardingRepository
|
||||
import com.tangem.domain.pay.usecase.ProduceTangemPayInitialDataUseCase
|
||||
import com.tangem.domain.pay.usecase.TangemPayMainScreenCustomerInfoUseCase
|
||||
|
|
@ -26,6 +29,10 @@ internal interface TangemPayIntents {
|
|||
|
||||
fun onRefreshPayToken(userWalletId: UserWalletId)
|
||||
|
||||
fun openDetails(userWalletId: UserWalletId, config: TangemPayDetailsConfig)
|
||||
|
||||
fun onKycProgressClicked(userWalletId: UserWalletId)
|
||||
|
||||
fun onIssuingCardClicked()
|
||||
|
||||
fun onIssuingFailedClicked()
|
||||
|
|
@ -47,6 +54,7 @@ internal class TangemPayClickIntentsImplementor @Inject constructor(
|
|||
private val getWalletMetainfoUseCase: GetWalletMetaInfoUseCase,
|
||||
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
|
||||
private val tangemPayMainScreenCustomerInfoUseCase: TangemPayMainScreenCustomerInfoUseCase,
|
||||
private val tangemPayOnboardingRepository: OnboardingRepository,
|
||||
private val uiMessageSender: UiMessageSender,
|
||||
) : BaseWalletClickIntents(), TangemPayIntents {
|
||||
|
||||
|
|
@ -67,6 +75,51 @@ internal class TangemPayClickIntentsImplementor @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun openDetails(userWalletId: UserWalletId, config: TangemPayDetailsConfig) {
|
||||
router.openTangemPayDetails(
|
||||
userWalletId = userWalletId,
|
||||
config = config,
|
||||
)
|
||||
}
|
||||
|
||||
override fun onKycProgressClicked(userWalletId: UserWalletId) {
|
||||
val cancelKycConfirmDialogMessage = DialogMessage(
|
||||
title = resourceReference(R.string.tangempay_kyc_confirm_cancellation_alert_title),
|
||||
message = resourceReference(R.string.tangempay_kyc_confirm_cancellation_description),
|
||||
firstAction = EventMessageAction(
|
||||
title = resourceReference(R.string.common_not_now),
|
||||
onClick = { },
|
||||
),
|
||||
secondAction = EventMessageAction(
|
||||
title = resourceReference(R.string.common_confirm),
|
||||
onClick = { disableTangemPay(userWalletId) },
|
||||
),
|
||||
)
|
||||
val kycInfoBottomSheet = bottomSheetMessage {
|
||||
infoBlock {
|
||||
iconImage(res = com.tangem.core.ui.R.drawable.img_visa_notification)
|
||||
title = resourceReference(R.string.tangempay_kyc_in_progress)
|
||||
body = resourceReference(R.string.tangempay_kyc_in_progress_popup_description)
|
||||
}
|
||||
primaryButton {
|
||||
text = resourceReference(R.string.tangempay_kyc_in_progress_notification_button)
|
||||
onClick = {
|
||||
router.openTangemPayOnboarding(AppRoute.TangemPayOnboarding.Mode.ContinueOnboarding(userWalletId))
|
||||
closeBs()
|
||||
}
|
||||
}
|
||||
secondaryButton {
|
||||
text = resourceReference(R.string.tangempay_cancel_kyc)
|
||||
onClick = {
|
||||
uiMessageSender.send(cancelKycConfirmDialogMessage)
|
||||
closeBs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uiMessageSender.send(kycInfoBottomSheet)
|
||||
}
|
||||
|
||||
override fun onIssuingCardClicked() {
|
||||
val issuingBottomSheet = bottomSheetMessage {
|
||||
infoBlock {
|
||||
|
|
@ -132,4 +185,11 @@ internal class TangemPayClickIntentsImplementor @Inject constructor(
|
|||
onboardingRepository.setHideMainOnboardingBanner(userWalletId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun disableTangemPay(userWalletId: UserWalletId) {
|
||||
modelScope.launch {
|
||||
tangemPayOnboardingRepository.disableTangemPay(userWalletId)
|
||||
.onRight { tangemPayMainScreenCustomerInfoUseCase.fetch(userWalletId) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.common.ui.R
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.format.bigdecimal.fiat
|
||||
|
|
@ -11,11 +12,10 @@ import com.tangem.domain.pay.model.CustomerInfo.ProductInstance
|
|||
import com.tangem.domain.pay.model.MainScreenCustomerInfo
|
||||
import com.tangem.domain.pay.model.OrderStatus
|
||||
import com.tangem.domain.visa.model.TangemPayCardFrozenState
|
||||
import com.tangem.feature.wallet.child.wallet.model.intents.TangemPayIntents
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState.Progress
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.util.TangemPayStateCreator.createCancelledState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.util.TangemPayStateCreator.createIssueProgressState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.util.TangemPayStateCreator.createKycInProgressState
|
||||
import java.util.Currency
|
||||
|
||||
/**
|
||||
|
|
@ -26,12 +26,9 @@ private const val POLYGON_CHAIN_ID = 137
|
|||
|
||||
internal class TangemPayUpdateInfoStateTransformer(
|
||||
userWalletId: UserWalletId,
|
||||
private val value: MainScreenCustomerInfo? = null,
|
||||
private val value: MainScreenCustomerInfo,
|
||||
private val cardFrozenState: TangemPayCardFrozenState,
|
||||
private val onClickKyc: () -> Unit = {},
|
||||
private val onIssuingCard: () -> Unit = {},
|
||||
private val onIssuingFailed: () -> Unit = {},
|
||||
private val openDetails: (config: TangemPayDetailsConfig) -> Unit = {},
|
||||
private val tangemPayClickIntents: TangemPayIntents,
|
||||
) : WalletStateTransformer(userWalletId = userWalletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
|
|
@ -44,16 +41,15 @@ internal class TangemPayUpdateInfoStateTransformer(
|
|||
}
|
||||
|
||||
private fun createInitialState(): TangemPayState {
|
||||
val cardInfo = value?.info?.cardInfo
|
||||
val productInstance = value?.info?.productInstance
|
||||
val cardInfo = value.info.cardInfo
|
||||
val productInstance = value.info.productInstance
|
||||
|
||||
// when statement copied to WalletTangemPayAnalyticsEventSender. Be careful when editing.
|
||||
return when {
|
||||
value == null -> TangemPayState.Empty
|
||||
value.orderStatus == OrderStatus.CANCELED -> createCancelledState(onIssuingFailed)
|
||||
!value.info.isKycApproved -> createKycInProgressState(onClickKyc)
|
||||
value.orderStatus == OrderStatus.CANCELED -> createCancelledState()
|
||||
!value.info.isKycApproved -> createKycInProgressState()
|
||||
cardInfo != null && productInstance != null -> getCardInfoState(cardInfo, productInstance)
|
||||
else -> createIssueProgressState(onIssuingCard)
|
||||
else -> createIssueProgressState()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +59,8 @@ internal class TangemPayUpdateInfoStateTransformer(
|
|||
balanceText = TextReference.Str(getBalanceText(cardInfo)),
|
||||
balanceSymbol = stringReference("USDC"), // TODO hardcode for now
|
||||
onClick = {
|
||||
openDetails(
|
||||
tangemPayClickIntents.openDetails(
|
||||
userWalletId,
|
||||
TangemPayDetailsConfig(
|
||||
cardId = productInstance.cardId,
|
||||
isPinSet = cardInfo.isPinSet,
|
||||
|
|
@ -82,4 +79,28 @@ internal class TangemPayUpdateInfoStateTransformer(
|
|||
fiat(fiatCurrencyCode = currency.currencyCode, fiatCurrencySymbol = currency.symbol)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createKycInProgressState(): TangemPayState = Progress(
|
||||
title = TextReference.Res(R.string.tangempay_payment_account),
|
||||
description = TextReference.Res(R.string.tangempay_kyc_in_progress),
|
||||
buttonText = TextReference.Res(R.string.tangempay_kyc_in_progress_notification_button),
|
||||
iconRes = R.drawable.ic_promo_kyc_36,
|
||||
onButtonClick = { tangemPayClickIntents.onKycProgressClicked(userWalletId) },
|
||||
)
|
||||
|
||||
private fun createIssueProgressState(): TangemPayState = Progress(
|
||||
title = TextReference.Res(R.string.tangempay_payment_account),
|
||||
description = TextReference.Res(R.string.tangempay_issuing_your_card),
|
||||
buttonText = TextReference.EMPTY,
|
||||
iconRes = R.drawable.ic_tangem_pay_promo_card_36,
|
||||
onButtonClick = tangemPayClickIntents::onIssuingCardClicked,
|
||||
showProgress = true,
|
||||
)
|
||||
|
||||
private fun createCancelledState(): TangemPayState = TangemPayState.FailedIssue(
|
||||
title = TextReference.Res(R.string.tangempay_payment_account),
|
||||
description = TextReference.Res(R.string.tangempay_failed_to_issue_card),
|
||||
iconRes = R.drawable.ic_alert_24,
|
||||
onButtonClick = tangemPayClickIntents::onIssuingFailedClicked,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.util
|
||||
|
||||
import com.tangem.common.ui.R
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState.Progress
|
||||
|
||||
internal object TangemPayStateCreator {
|
||||
|
||||
fun createKycInProgressState(onClickKyc: () -> Unit): TangemPayState = Progress(
|
||||
title = TextReference.Res(R.string.tangempay_payment_account),
|
||||
description = TextReference.Res(R.string.tangempay_kyc_in_progress),
|
||||
buttonText = TextReference.Res(R.string.tangempay_kyc_in_progress_notification_button),
|
||||
iconRes = R.drawable.ic_promo_kyc_36,
|
||||
onButtonClick = onClickKyc,
|
||||
)
|
||||
|
||||
fun createIssueProgressState(onIssuingCardClick: () -> Unit): TangemPayState = Progress(
|
||||
title = TextReference.Res(R.string.tangempay_payment_account),
|
||||
description = TextReference.Res(R.string.tangempay_issuing_your_card),
|
||||
buttonText = TextReference.EMPTY,
|
||||
iconRes = R.drawable.ic_tangem_pay_promo_card_36,
|
||||
onButtonClick = onIssuingCardClick,
|
||||
showProgress = true,
|
||||
)
|
||||
|
||||
fun createCancelledState(onIssueFailedClick: () -> Unit): TangemPayState = TangemPayState.FailedIssue(
|
||||
title = TextReference.Res(R.string.tangempay_payment_account),
|
||||
description = TextReference.Res(R.string.tangempay_failed_to_issue_card),
|
||||
iconRes = R.drawable.ic_alert_24,
|
||||
onButtonClick = onIssueFailedClick,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.subscribers
|
||||
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.pay.model.MainCustomerInfoContentState
|
||||
|
|
@ -10,7 +9,6 @@ import com.tangem.domain.pay.repository.TangemPayCardDetailsRepository
|
|||
import com.tangem.domain.pay.usecase.TangemPayMainScreenCustomerInfoUseCase
|
||||
import com.tangem.domain.visa.model.TangemPayCardFrozenState
|
||||
import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents
|
||||
import com.tangem.feature.wallet.presentation.router.InnerWalletRouter
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletTangemPayAnalyticsEventSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.*
|
||||
|
|
@ -28,7 +26,6 @@ internal class TangemPayMainSubscriber @AssistedInject constructor(
|
|||
@Assisted private val userWallet: UserWallet,
|
||||
private val stateController: WalletStateController,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val innerWalletRouter: InnerWalletRouter,
|
||||
private val cardDetailsRepository: TangemPayCardDetailsRepository,
|
||||
private val tangemPayMainScreenCustomerInfoUseCase: TangemPayMainScreenCustomerInfoUseCase,
|
||||
private val analytics: WalletTangemPayAnalyticsEventSender,
|
||||
|
|
@ -102,19 +99,7 @@ internal class TangemPayMainSubscriber @AssistedInject constructor(
|
|||
userWalletId = userWalletId,
|
||||
value = data,
|
||||
cardFrozenState = cardFrozenState,
|
||||
onClickKyc = {
|
||||
innerWalletRouter.openTangemPayOnboarding(
|
||||
mode = AppRoute.TangemPayOnboarding.Mode.ContinueOnboarding(userWalletId),
|
||||
)
|
||||
},
|
||||
onIssuingCard = clickIntents::onIssuingCardClicked,
|
||||
onIssuingFailed = clickIntents::onIssuingFailedClicked,
|
||||
openDetails = { config ->
|
||||
innerWalletRouter.openTangemPayDetails(
|
||||
userWalletId = userWalletId,
|
||||
config = config,
|
||||
)
|
||||
},
|
||||
tangemPayClickIntents = clickIntents,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue