Updated on 2026-08-14
This commit is contained in:
parent
075db99e51
commit
2bf26305e4
4 changed files with 59 additions and 30 deletions
|
|
@ -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<TangemPayCard>.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(
|
||||
|
|
|
|||
|
|
@ -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<Card>,
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
|
@ -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<T
|
|||
TangemPayDetailsBalanceBlockState.Card(
|
||||
lastDigits = "1234",
|
||||
onClick = {},
|
||||
isReissuingOrClosing = false,
|
||||
isEnabled = false,
|
||||
isFrozen = false,
|
||||
isIssuing = false,
|
||||
state = TangemPayCardUiState.Active,
|
||||
),
|
||||
TangemPayDetailsBalanceBlockState.Card(
|
||||
lastDigits = "3456",
|
||||
onClick = {},
|
||||
isReissuingOrClosing = false,
|
||||
isEnabled = true,
|
||||
isFrozen = false,
|
||||
isIssuing = false,
|
||||
state = TangemPayCardUiState.Active,
|
||||
),
|
||||
),
|
||||
onAddCardClick = {},
|
||||
|
|
@ -527,14 +526,14 @@ internal class TangemPayDetailsUMProvider : CollectionPreviewParameterProvider<T
|
|||
TangemPayDetailsBalanceBlockState.Card(
|
||||
lastDigits = "1234",
|
||||
onClick = {},
|
||||
isReissuingOrClosing = true,
|
||||
isFrozen = false,
|
||||
isEnabled = true,
|
||||
isIssuing = false,
|
||||
state = TangemPayCardUiState.InProgress,
|
||||
),
|
||||
),
|
||||
onAddCardClick = {},
|
||||
isAddCardEnabled = true,
|
||||
progressBanner = CardsProgressBannerUM.Reissuing,
|
||||
),
|
||||
),
|
||||
isBalanceHidden = false,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.util.fastAny
|
||||
import androidx.compose.ui.util.fastForEach
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.tangem.core.ui.components.SpacerW
|
||||
|
|
@ -56,6 +55,8 @@ import com.tangem.features.tangempay.components.express.PreviewEmptyExpressTrans
|
|||
import com.tangem.features.tangempay.components.txHistory.PreviewTangemPayTxHistoryComponent
|
||||
import com.tangem.features.tangempay.components.txHistory.TangemPayTxHistoryComponent
|
||||
import com.tangem.features.tangempay.details.impl.R
|
||||
import com.tangem.features.tangempay.entity.CardsProgressBannerUM
|
||||
import com.tangem.features.tangempay.entity.TangemPayCardUiState
|
||||
import com.tangem.features.tangempay.entity.TangemPayDetailsBalanceBlockState
|
||||
import com.tangem.features.tangempay.entity.TangemPayDetailsTopBarConfig
|
||||
import com.tangem.features.tangempay.entity.TangemPayDetailsUM
|
||||
|
|
@ -159,8 +160,20 @@ private fun LazyListScope.payDetailsBody(state: TangemPayDetailsUM) {
|
|||
ActionBlock(actionButtons = state.balanceBlockState.actionButtons)
|
||||
}
|
||||
}
|
||||
when {
|
||||
state.balanceBlockState.cardsBlockState?.cards?.fastAny { it.isReissuingOrClosing } == true -> {
|
||||
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue