From 2bf26305e4d49bf45e0264f0c4eaaef456519042 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 19 Jun 2026 06:29:34 -0700 Subject: [PATCH] Updated on 2026-08-14 --- .../entity/TangemPayDetailsStateFactory.kt | 12 +++++-- .../tangempay/entity/TangemPayDetailsUM.kt | 25 ++++++++++++-- .../tangempay/ui/TangemPayDetailsScreen.kt | 19 +++++------ .../tangempay/ui/TangemPayDetailsScreenV2.kt | 33 +++++++++++-------- 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsStateFactory.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsStateFactory.kt index b1a1c7fb6d..9cc41144ee 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsStateFactory.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsStateFactory.kt @@ -11,6 +11,7 @@ import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.generated.icons.Icons import com.tangem.core.ui.res.generated.icons.ic_document_20 import com.tangem.domain.models.account.PaymentAccountStatusValue +import com.tangem.domain.models.pay.TangemPayCard import com.tangem.domain.models.pay.TangemPayCardFrozenState import com.tangem.domain.models.pay.TangemPayCardState import com.tangem.domain.models.pay.isFrozen @@ -81,16 +82,15 @@ internal class TangemPayDetailsStateFactory( TangemPayDetailsBalanceBlockState.Card( lastDigits = cardItem.lastDigits, onClick = { intents.onCardClick(cardItem.id) }, - isReissuingOrClosing = cardItem.state == TangemPayCardState.Reissuing || - cardItem.state == TangemPayCardState.Closing, isEnabled = status.error == null, isFrozen = cardItem.isFrozen, - isIssuing = cardItem.state == TangemPayCardState.Issuing, + state = cardItem.state.toUiState(), ) } .toImmutableList(), onAddCardClick = intents::onAddCardClick, isAddCardEnabled = isAddCardEnabled, + progressBanner = status.cards.resolveProgressBanner(), ), ), isBalanceHidden = false, @@ -104,6 +104,12 @@ internal class TangemPayDetailsStateFactory( ) } + private fun List.resolveProgressBanner(): CardsProgressBannerUM? = when { + any { it.state == TangemPayCardState.Reissuing } -> CardsProgressBannerUM.Reissuing + any { it.state == TangemPayCardState.Issuing } -> CardsProgressBannerUM.Issuing + else -> null + } + fun getDeactivatedState(): TangemPayDetailsUM { return TangemPayDetailsUM( topBarConfig = TangemPayDetailsTopBarConfig( diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsUM.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsUM.kt index 523b1c4650..93713fe0a9 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsUM.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsUM.kt @@ -7,6 +7,7 @@ import com.tangem.core.ui.components.containers.pullToRefresh.PullToRefreshConfi import com.tangem.core.ui.components.notifications.NotificationConfig import com.tangem.core.ui.extensions.TextReference import com.tangem.domain.models.pay.TangemPayCardFrozenState +import com.tangem.domain.models.pay.TangemPayCardState import kotlinx.collections.immutable.ImmutableList internal enum class CardDataType { @@ -94,13 +95,13 @@ internal sealed class TangemPayDetailsBalanceBlockState { val cards: ImmutableList, val onAddCardClick: () -> Unit, val isAddCardEnabled: Boolean, + val progressBanner: CardsProgressBannerUM? = null, ) data class Card( val lastDigits: String, val onClick: () -> Unit, - val isReissuingOrClosing: Boolean, - val isIssuing: Boolean, + val state: TangemPayCardUiState, val isFrozen: Boolean, val isEnabled: Boolean, ) @@ -109,4 +110,22 @@ internal sealed class TangemPayDetailsBalanceBlockState { internal data class AddToWalletBlockState( val onClick: () -> Unit, val onClickClose: () -> Unit, -) \ No newline at end of file +) + +internal enum class TangemPayCardUiState { + Active, + InProgress, +} + +internal enum class CardsProgressBannerUM { + Issuing, + Reissuing, +} + +internal fun TangemPayCardState.toUiState(): TangemPayCardUiState = when (this) { + TangemPayCardState.Active -> TangemPayCardUiState.Active + TangemPayCardState.Issuing, + TangemPayCardState.Reissuing, + TangemPayCardState.Closing, + -> TangemPayCardUiState.InProgress +} \ No newline at end of file diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreen.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreen.kt index 6de094b16c..f4e2a0a1f5 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreen.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreen.kt @@ -33,7 +33,6 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import androidx.compose.ui.util.fastAny import androidx.compose.ui.util.fastForEach import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.tangem.core.ui.components.RectangleShimmer @@ -132,7 +131,8 @@ internal fun TangemPayDetailsScreen( }, ) - if (state.balanceBlockState.cardsBlockState?.cards?.fastAny { it.isReissuingOrClosing } == true) { + val progressBanner = state.balanceBlockState.cardsBlockState?.progressBanner + if (progressBanner == CardsProgressBannerUM.Reissuing) { item( key = "REISSUE_MESSAGE", content = { @@ -315,6 +315,7 @@ private fun CardsBlockRow( @Composable private fun TangemPayCardItem(card: TangemPayDetailsBalanceBlockState.Card, modifier: Modifier = Modifier) { + val isCardInProcess = card.state == TangemPayCardUiState.InProgress Box( modifier = modifier .clip(RoundedCornerShape(4.dp)) @@ -329,7 +330,7 @@ private fun TangemPayCardItem(card: TangemPayDetailsBalanceBlockState.Card, modi .alpha(if (card.isEnabled) 1f else DISABLED_ALPHA) .fillMaxSize(), painter = painterResource( - if (card.isReissuingOrClosing) { + if (isCardInProcess) { R.drawable.img_visa_card_inactive_48_32 } else { R.drawable.img_visa_card_48_32 @@ -337,7 +338,7 @@ private fun TangemPayCardItem(card: TangemPayDetailsBalanceBlockState.Card, modi ), contentDescription = null, ) - if (!card.isReissuingOrClosing) { + if (!isCardInProcess) { Text( modifier = Modifier .align(Alignment.BottomStart) @@ -486,18 +487,16 @@ internal class TangemPayDetailsUMProvider : CollectionPreviewParameterProvider { + + if (state.errorNotificationConfig != null) { + item("errorSessionBannerBlock") { + ErrorMessage( + config = state.errorNotificationConfig, + modifier = Modifier.padding(horizontal = TangemTheme.dimens2.x4), + ) + } + } + + val progressBanner = state.balanceBlockState.cardsBlockState?.progressBanner + + when (progressBanner) { + CardsProgressBannerUM.Reissuing -> { item("reissuingBannerBlock") { TangemMessage( modifier = Modifier.padding(horizontal = TangemTheme.dimens2.x4), @@ -169,7 +182,7 @@ private fun LazyListScope.payDetailsBody(state: TangemPayDetailsUM) { ) } } - state.balanceBlockState.cardsBlockState?.cards?.fastAny { it.isIssuing } == true -> { + CardsProgressBannerUM.Issuing -> { item("issuingBannerBlock") { TangemMessage( modifier = Modifier.padding(horizontal = TangemTheme.dimens2.x4), @@ -187,15 +200,7 @@ private fun LazyListScope.payDetailsBody(state: TangemPayDetailsUM) { ) } } - else -> { - if (state.errorNotificationConfig != null) { - item("errorSessionBannerBlock") { - ErrorMessage( - config = state.errorNotificationConfig, - modifier = Modifier.padding(horizontal = TangemTheme.dimens2.x4), - ) - } - } + null -> { if (state.addToWalletBlockState != null) { item("addToWalletBannerBlock") { TangemPayAddToWalletBlock( @@ -385,7 +390,7 @@ private fun CardsBlock( ) { items(items = cardsBlockState.cards) { item -> TangemPayCardView( - isIssueInProgress = item.isIssuing || item.isReissuingOrClosing, + isIssueInProgress = item.state != TangemPayCardUiState.Active, lastDigits = item.lastDigits, onClick = item.onClick, isEnabled = item.isEnabled,