diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt index 42613794b0..9f6b97b22b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt @@ -39,7 +39,10 @@ internal object WalletPreviewData { id = UserWalletId(stringValue = "123"), title = "Wallet1Wallet1Wallet1Wallet1Wallet1Wallet1Wallet1Wallet1", balance = "8923,05312312312312312312331231231233432423423424234 $", - additionalInfo = TextReference.Str("3 cards • Seed phrase3 cards • Seed phraseцфвцфвфцвцфввцфвцф"), + additionalInfo = WalletAdditionalInfo( + hideable = false, + content = TextReference.Str("3 cards • Seed phrase3 cards • Seed phrasephrasephrasephrase"), + ), imageResId = R.drawable.ill_wallet2_cards3_120_106, onRenameClick = { _, _ -> }, onDeleteClick = {}, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletAdditionalInfoFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletAdditionalInfoFactory.kt index 9124311a34..40ba99fbde 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletAdditionalInfoFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletAdditionalInfoFactory.kt @@ -8,6 +8,7 @@ import com.tangem.core.ui.utils.BigDecimalFormatter import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.wallets.models.UserWallet import com.tangem.feature.wallet.impl.R +import com.tangem.feature.wallet.presentation.wallet.state.components.WalletAdditionalInfo import java.math.BigDecimal /** @@ -25,7 +26,7 @@ internal object WalletAdditionalInfoFactory { * @param wallet current wallet * @param currencyAmount amount of currency */ - fun resolve(wallet: UserWallet, currencyAmount: BigDecimal? = null): TextReference { + fun resolve(wallet: UserWallet, currencyAmount: BigDecimal? = null): WalletAdditionalInfo { return if (wallet.isMultiCurrency) { wallet.resolveMultiCurrencyInfo() } else { @@ -33,9 +34,14 @@ internal object WalletAdditionalInfoFactory { } } - private fun UserWallet.resolveMultiCurrencyInfo(): TextReference { + private fun UserWallet.resolveMultiCurrencyInfo(): WalletAdditionalInfo { return if (isLocked) { - getBackupInfoWithDivider(backupCardsCount = getCardsCount()) + TextReference.Res(R.string.common_locked) + WalletAdditionalInfo( + hideable = false, + content = getBackupInfoWithDivider( + backupCardsCount = getCardsCount(), + ) + TextReference.Res(R.string.common_locked), + ) } else { val cardTypeResolver = scanResponse.cardTypesResolver if (cardTypeResolver.isWallet2()) { @@ -46,10 +52,14 @@ internal object WalletAdditionalInfoFactory { } } - private fun UserWallet.resolveWallet2Info(): TextReference { + private fun UserWallet.resolveWallet2Info(): WalletAdditionalInfo { return if (isImported) { - getBackupInfoWithDivider(backupCardsCount = getCardsCount()) + - TextReference.Res(id = R.string.common_seed_phrase) + WalletAdditionalInfo( + hideable = false, + content = getBackupInfoWithDivider(backupCardsCount = getCardsCount()) + TextReference.Res( + id = R.string.common_seed_phrase, + ), + ) } else { getBackupInfo(backupCardsCount = getCardsCount()) } @@ -63,12 +73,14 @@ internal object WalletAdditionalInfoFactory { } } - private fun getBackupInfo(backupCardsCount: Int?): TextReference { - return if (backupCardsCount != null) { + private fun getBackupInfo(backupCardsCount: Int?): WalletAdditionalInfo { + val content = if (backupCardsCount != null) { getBackupInfoTextReference(count = backupCardsCount) } else { TextReference.EMPTY } + + return WalletAdditionalInfo(hideable = false, content = content) } private fun getBackupInfoTextReference(count: Int): TextReference { @@ -79,9 +91,9 @@ internal object WalletAdditionalInfoFactory { ) } - private fun UserWallet.resolveSingleCurrencyInfo(currencyAmount: BigDecimal?): TextReference { + private fun UserWallet.resolveSingleCurrencyInfo(currencyAmount: BigDecimal?): WalletAdditionalInfo { return if (isLocked) { - TextReference.Res(R.string.common_locked) + WalletAdditionalInfo(hideable = false, content = TextReference.Res(R.string.common_locked)) } else { val blockchain = scanResponse.cardTypesResolver.getBlockchain() val amount = currencyAmount?.let { @@ -92,7 +104,7 @@ internal object WalletAdditionalInfoFactory { ) } - TextReference.Str(value = amount.orEmpty()) + WalletAdditionalInfo(hideable = true, content = TextReference.Str(value = amount.orEmpty())) } } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletAdditionalInfo.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletAdditionalInfo.kt new file mode 100644 index 0000000000..612f2111e5 --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletAdditionalInfo.kt @@ -0,0 +1,10 @@ +package com.tangem.feature.wallet.presentation.wallet.state.components + +import androidx.compose.runtime.Immutable +import com.tangem.core.ui.extensions.TextReference + +@Immutable +data class WalletAdditionalInfo( + val hideable: Boolean, + val content: TextReference, +) \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletCardState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletCardState.kt index 13ce9569e8..5e74bd00af 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletCardState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletCardState.kt @@ -16,7 +16,8 @@ internal sealed interface WalletCardState { /** Title */ val title: String - val additionalInfo: TextReference? + /** Wallet additional info */ + val additionalInfo: WalletAdditionalInfo? /** Wallet image resource id */ @get:DrawableRes @@ -43,7 +44,7 @@ internal sealed interface WalletCardState { data class Content( override val id: UserWalletId, override val title: String, - override val additionalInfo: TextReference, + override val additionalInfo: WalletAdditionalInfo, override val imageResId: Int?, override val onRenameClick: (UserWalletId, String) -> Unit, override val onDeleteClick: (UserWalletId) -> Unit, @@ -64,7 +65,7 @@ internal sealed interface WalletCardState { data class LockedContent( override val id: UserWalletId, override val title: String, - override val additionalInfo: TextReference, + override val additionalInfo: WalletAdditionalInfo, override val imageResId: Int?, override val onRenameClick: (UserWalletId, String) -> Unit, override val onDeleteClick: (UserWalletId) -> Unit, @@ -86,7 +87,10 @@ internal sealed interface WalletCardState { override val onRenameClick: (UserWalletId, String) -> Unit, override val onDeleteClick: (UserWalletId) -> Unit, ) : WalletCardState { - override val additionalInfo: TextReference = EMPTY_BALANCE_TEXT + override val additionalInfo: WalletAdditionalInfo = WalletAdditionalInfo( + hideable = true, + content = EMPTY_BALANCE_TEXT, + ) } /** @@ -101,7 +105,7 @@ internal sealed interface WalletCardState { data class Loading( override val id: UserWalletId, override val title: String, - override val additionalInfo: TextReference? = null, + override val additionalInfo: WalletAdditionalInfo? = null, override val imageResId: Int?, override val onRenameClick: (UserWalletId, String) -> Unit, override val onDeleteClick: (UserWalletId) -> Unit, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletCard.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletCard.kt index be70f2f0bd..4f7ed253be 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletCard.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletCard.kt @@ -94,7 +94,11 @@ internal fun WalletCard(state: WalletCardState, isBalanceHidden: Boolean, modifi ) AdditionalInfo( - text = state.additionalInfo, + text = if (state.additionalInfo?.hideable == true && isBalanceHidden) { + WalletCardState.HIDDEN_BALANCE_TEXT + } else { + state.additionalInfo?.content + }, modifier = Modifier.constrainAs(additionalTextRef) { start.linkTo(parent.start) top.linkTo(balanceRef.bottom)