Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-01 13:27:07 +03:00
parent 7fb32453ca
commit c1517d09fe
22 changed files with 246 additions and 66 deletions

View file

@ -426,6 +426,8 @@ internal class WalletModel @Inject constructor(
value = data,
cardFrozenState = cardFrozenState,
onClickKyc = innerWalletRouter::openTangemPayOnboarding,
onIssuingCard = clickIntents::onIssuingCardClicked,
onIssuingFailed = clickIntents::onIssuingFailedClicked,
openDetails = { config ->
innerWalletRouter.openTangemPayDetails(
userWalletId = userWalletId,

View file

@ -1,12 +1,23 @@
package com.tangem.feature.wallet.child.wallet.model.intents
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.decompose.ui.UiMessageSender
import com.tangem.core.res.R
import com.tangem.core.ui.components.bottomsheets.message.MessageBottomSheetUMV2
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.message.BottomSheetMessageV2
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.models.wallet.requireColdWallet
import com.tangem.domain.pay.repository.OnboardingRepository
import com.tangem.domain.pay.usecase.ProduceTangemPayInitialDataUseCase
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
import com.tangem.feature.wallet.child.wallet.model.TangemPayMainInfoManager
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
import com.tangem.features.tangempay.TangemPayFeatureToggles
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.launch
import javax.inject.Inject
@ -15,15 +26,26 @@ internal interface TangemPayIntents {
suspend fun onPullToRefresh()
fun onRefreshPayToken(userWalletId: UserWalletId)
fun onIssuingCardClicked()
fun onIssuingFailedClicked()
fun onPaySupportClick()
}
@Suppress("LongParameterList")
@ModelScoped
internal class TangemPayClickIntentsImplementor @Inject constructor(
private val stateHolder: WalletStateController,
private val featureToggles: TangemPayFeatureToggles,
private val onboardingRepository: OnboardingRepository,
private val produceInitialDataTangemPay: ProduceTangemPayInitialDataUseCase,
private val getWalletMetainfoUseCase: GetWalletMetaInfoUseCase,
private val getUserWalletUseCase: GetUserWalletUseCase,
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
private val tangemPayInfoManager: TangemPayMainInfoManager,
private val uiMessageSender: UiMessageSender,
) : BaseWalletClickIntents(), TangemPayIntents {
override suspend fun onPullToRefresh() {
@ -42,4 +64,72 @@ internal class TangemPayClickIntentsImplementor @Inject constructor(
tangemPayInfoManager.refreshTangemPayInfo(userWalletId)
}
}
override fun onIssuingCardClicked() {
val icon = MessageBottomSheetUMV2.Icon(
res = com.tangem.core.ui.R.drawable.ic_clock_24,
backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.Informative,
)
val info = MessageBottomSheetUMV2.InfoBlock(
title = resourceReference(R.string.tangempay_issuing_your_card),
body = resourceReference(R.string.tangempay_issuing_your_card_description),
)
val button = MessageBottomSheetUMV2.Button(
text = resourceReference(R.string.common_got_it),
onClick = { closeBs() },
)
val issuingBottomSheet = BottomSheetMessageV2(
messageBottomSheetUMV2 = MessageBottomSheetUMV2(
elements = persistentListOf(icon, info, button),
),
)
uiMessageSender.send(issuingBottomSheet)
}
override fun onIssuingFailedClicked() {
val icon = MessageBottomSheetUMV2.Icon(
res = com.tangem.core.ui.R.drawable.ic_alert_24,
backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.Warning,
type = MessageBottomSheetUMV2.Icon.Type.Warning,
)
val info = MessageBottomSheetUMV2.InfoBlock(
title = resourceReference(R.string.tangempay_failed_to_issue_card),
body = resourceReference(R.string.tangempay_failed_to_issue_card_support_description),
)
val button = MessageBottomSheetUMV2.Button(
text = resourceReference(R.string.details_row_title_contact_to_support),
onClick = {
onPaySupportClick()
closeBs()
},
)
val issuingBottomSheet = BottomSheetMessageV2(
messageBottomSheetUMV2 = MessageBottomSheetUMV2(
elements = persistentListOf(icon, info, button),
),
)
uiMessageSender.send(issuingBottomSheet)
}
override fun onPaySupportClick() {
modelScope.launch {
val userWalletId = stateHolder.getSelectedWalletId()
val userWallet = getUserWalletUseCase.invoke(userWalletId).getOrNull() ?: return@launch
val cardInfo = getWalletMetainfoUseCase.invoke(
userWallet.requireColdWallet().scanResponse,
).getOrNull() ?: return@launch
sendFeedbackEmailUseCase(
FeedbackEmailType.Visa.FailedIssueCard(
walletMetaInfo = cardInfo,
),
)
}
}
}

View file

@ -7,10 +7,10 @@ import com.tangem.core.decompose.di.ModelScoped
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.requireColdWallet
import com.tangem.domain.visa.GetVisaCurrencyUseCase
import com.tangem.domain.visa.GetVisaTxDetailsUseCase
import com.tangem.domain.visa.model.VisaTxDetails
import com.tangem.domain.models.wallet.requireColdWallet
import com.tangem.domain.wallets.usecase.GetWalletsUseCase
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
import com.tangem.feature.wallet.presentation.wallet.state.transformers.converter.BalancesAndLimitsBottomSheetConverter

View file

@ -138,7 +138,6 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
private val userWalletsListRepository: UserWalletsListRepository,
private val setShouldShowNotificationUseCase: SetShouldShowNotificationUseCase,
private val notificationsRepository: NotificationsRepository,
private val messageSender: UiMessageSender,
private val setNotificationsEnabledUseCase: SetNotificationsEnabledUseCase,
private val getWalletsListForEnablingUseCase: GetWalletsForAutomaticallyPushEnablingUseCase,
private val uiMessageSender: UiMessageSender,
@ -492,7 +491,7 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
}
}
}
messageSender.send(message)
uiMessageSender.send(message)
}
}
}

View file

@ -18,9 +18,17 @@ internal sealed class TangemPayState {
val showProgress: Boolean = false,
) : TangemPayState()
data class FailedIssue(
val title: TextReference,
val description: TextReference,
@DrawableRes val iconRes: Int,
val onButtonClick: () -> Unit,
) : TangemPayState()
data class Card(
val lastFourDigits: TextReference,
val balanceText: TextReference,
val balanceSymbol: TextReference,
val onClick: () -> Unit,
) : TangemPayState()

View file

@ -1,15 +1,18 @@
package com.tangem.feature.wallet.presentation.wallet.state.transformers
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.pay.TangemPayDetailsConfig
import com.tangem.domain.pay.model.CustomerInfo.CardInfo
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.presentation.wallet.state.model.TangemPayState
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
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
@ -24,6 +27,8 @@ internal class TangemPayInitialStateTransformer(
private val value: MainScreenCustomerInfo? = null,
private val cardFrozenState: TangemPayCardFrozenState,
private val onClickKyc: () -> Unit = {},
private val onIssuingCard: () -> Unit = {},
private val onIssuingFailed: () -> Unit = {},
private val openDetails: (config: TangemPayDetailsConfig) -> Unit = {},
) : WalletScreenStateTransformer {
@ -37,9 +42,10 @@ internal class TangemPayInitialStateTransformer(
val productInstance = value?.info?.productInstance
return when {
value == null -> TangemPayState.Empty
value.orderStatus == OrderStatus.CANCELED -> createCancelledState(onIssuingFailed)
!value.info.isKycApproved -> createKycInProgressState(onClickKyc)
cardInfo != null && productInstance != null -> getCardInfoState(cardInfo, productInstance)
else -> createIssueProgressState()
else -> createIssueProgressState(onIssuingCard)
}
}
@ -47,6 +53,7 @@ internal class TangemPayInitialStateTransformer(
TangemPayState.Card(
lastFourDigits = TextReference.Str("*${cardInfo.lastFourDigits}"),
balanceText = TextReference.Str(getBalanceText(cardInfo)),
balanceSymbol = stringReference("USDC"), // TODO hardcode for now
onClick = {
openDetails(
TangemPayDetailsConfig(

View file

@ -1,10 +0,0 @@
package com.tangem.feature.wallet.presentation.wallet.state.transformers
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
import com.tangem.feature.wallet.presentation.wallet.state.util.TangemPayStateCreator.createIssueProgressState
internal class TangemPayIssueProgressStateTransformer : WalletScreenStateTransformer {
override fun transform(prevState: WalletScreenState): WalletScreenState =
prevState.copy(tangemPayState = createIssueProgressState())
}

View file

@ -8,19 +8,26 @@ import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState.
internal object TangemPayStateCreator {
fun createKycInProgressState(onClickKyc: () -> Unit): TangemPayState = Progress(
title = TextReference.Res(R.string.tangempay_kyc_in_progress_notification_title),
description = TextReference.EMPTY,
title = TextReference.Res(R.string.tangempay_payment_account),
description = TextReference.Res(R.string.tangempay_kyc_in_progress_notification_title),
buttonText = TextReference.Res(R.string.tangempay_kyc_in_progress_notification_button),
iconRes = R.drawable.ic_promo_kyc_36,
onButtonClick = onClickKyc,
)
fun createIssueProgressState(): TangemPayState = Progress(
title = TextReference.Res(R.string.tangempay_issue_card_notification_title),
description = TextReference.Res(R.string.tangempay_issue_card_notification_description),
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 = {},
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,
)
}

View file

@ -2,13 +2,11 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurren
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
@ -39,9 +37,9 @@ internal fun TangemPayCardMainBlock(
verticalAlignment = Alignment.CenterVertically,
) {
Image(
painter = painterResource(R.drawable.img_tangem_pay_card_main_36),
painter = painterResource(R.drawable.img_visa_36),
contentDescription = null,
modifier = Modifier.size(36.dp).clip(CircleShape),
modifier = Modifier.size(36.dp),
)
Spacer(Modifier.width(12.dp))
@ -58,23 +56,15 @@ internal fun TangemPayCardMainBlock(
Spacer(Modifier.height(6.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
Image(
painter = painterResource(R.drawable.img_visa_label_26_16),
contentDescription = null,
modifier = Modifier.size(26.dp, 16.dp),
)
Spacer(Modifier.width(4.dp))
Text(
text = state.lastFourDigits.resolveReference(),
style = TangemTheme.typography.caption2,
color = TangemTheme.colors.text.tertiary,
)
}
Text(
text = state.lastFourDigits.resolveReference(),
style = TangemTheme.typography.caption2,
color = TangemTheme.colors.text.tertiary,
)
}
Box(
Column(
modifier = Modifier.fillMaxHeight(),
contentAlignment = Alignment.TopEnd,
horizontalAlignment = Alignment.End,
) {
Text(
text = state.balanceText.resolveReference().orMaskWithStars(isBalanceHidden),
@ -82,6 +72,13 @@ internal fun TangemPayCardMainBlock(
color = TangemTheme.colors.text.primary1,
textAlign = TextAlign.End,
)
Text(
text = state.balanceSymbol.resolveReference(),
style = TangemTheme.typography.body2,
color = TangemTheme.colors.text.tertiary,
textAlign = TextAlign.End,
)
}
}
}

View file

@ -0,0 +1,37 @@
package com.tangem.feature.wallet.presentation.wallet.ui.components.visa
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import com.tangem.core.ui.components.block.BlockCard
import com.tangem.core.ui.components.inputrow.InputRowImageBase
import com.tangem.core.ui.res.TangemTheme
import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState
@Composable
internal fun TangemPayFailedIssueState(state: TangemPayState.FailedIssue) {
BlockCard(
modifier = Modifier
.clip(RoundedCornerShape(size = TangemTheme.dimens.radius14))
.background(TangemTheme.colors.background.primary),
) {
InputRowImageBase(
modifier = Modifier
.padding(
all = TangemTheme.dimens.spacing12,
)
.clickable(onClick = { state.onButtonClick }),
subtitle = state.title,
caption = state.description,
subtitleColor = TangemTheme.colors.text.primary1,
captionColor = TangemTheme.colors.text.tertiary,
iconResWebp = com.tangem.core.ui.R.drawable.img_visa_36,
iconEndRes = state.iconRes,
endIconTint = TangemTheme.colors.icon.warning,
)
}
}

View file

@ -3,15 +3,10 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.visa
import android.content.res.Configuration
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.tangem.common.ui.R
import com.tangem.core.ui.components.notifications.Notification
import com.tangem.core.ui.components.notifications.NotificationConfig
import com.tangem.core.ui.components.notifications.NotificationConfig.ButtonsState.*
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
@ -22,27 +17,12 @@ import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrenc
@Composable
internal fun TangemPayMainScreenBlock(state: TangemPayState, isBalanceHidden: Boolean, modifier: Modifier = Modifier) {
when (state) {
is Progress -> {
Notification(
modifier = modifier
.fillMaxWidth(),
config = NotificationConfig(
title = state.title,
iconSize = 36.dp,
subtitle = state.description,
iconResId = state.iconRes,
buttonsState = SecondaryButtonConfig(
text = state.buttonText,
onClick = state.onButtonClick,
shouldShowProgress = state.showProgress,
),
),
)
}
is Progress -> TangemPayProgressState(state)
is TangemPayState.Card -> TangemPayCardMainBlock(state, isBalanceHidden, modifier)
is TangemPayState.Empty -> Unit
is TangemPayState.RefreshNeeded -> TangemPayRefreshBlock(state, modifier)
is TangemPayState.TemporaryUnavailable -> TangemPayUnavailableBlock(state, modifier)
is TangemPayState.FailedIssue -> TangemPayFailedIssueState(state)
}
}
@ -90,6 +70,7 @@ private fun TangemPayMainScreenBlockPreview() {
TangemPayState.Card(
lastFourDigits = TextReference.Str("*1234"),
balanceText = TextReference.Str("$ 0.00"),
balanceSymbol = TextReference.Str("USDC"),
onClick = {},
),
isBalanceHidden = false,

View file

@ -0,0 +1,36 @@
package com.tangem.feature.wallet.presentation.wallet.ui.components.visa
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import com.tangem.core.ui.R
import com.tangem.core.ui.components.block.BlockCard
import com.tangem.core.ui.components.inputrow.InputRowImageBase
import com.tangem.core.ui.res.TangemTheme
import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState
@Composable
internal fun TangemPayProgressState(state: TangemPayState.Progress) {
BlockCard(
modifier = Modifier
.clip(RoundedCornerShape(size = TangemTheme.dimens.radius14))
.background(TangemTheme.colors.background.primary),
) {
InputRowImageBase(
modifier = Modifier
.padding(
all = TangemTheme.dimens.spacing12,
)
.clickable(onClick = { state.onButtonClick }),
subtitle = state.title,
caption = state.description,
subtitleColor = TangemTheme.colors.text.primary1,
captionColor = TangemTheme.colors.text.tertiary,
iconResWebp = R.drawable.img_visa_36,
)
}
}