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 e25b851c21..6c4f9e181e 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 @@ -15,9 +15,6 @@ internal sealed interface WalletCardState { /** Title */ val title: String - /** Additional text */ - val additionalInfo: TextReference? - /** Wallet image resource id */ @get:DrawableRes val imageResId: Int? @@ -33,36 +30,34 @@ internal sealed interface WalletCardState { * * @property id wallet id * @property title wallet name - * @property additionalInfo wallet additional info * @property imageResId wallet image resource id * @property onRenameClick lambda be invoked when Rename button is clicked * @property onDeleteClick lambda be invoked when Delete button is clicked + * @property additionalInfo wallet additional info * @property balance wallet balance */ data class Content( override val id: UserWalletId, override val title: String, - override val additionalInfo: TextReference, override val imageResId: Int?, override val onRenameClick: (UserWalletId, String) -> Unit, override val onDeleteClick: (UserWalletId) -> Unit, + val additionalInfo: TextReference, val balance: String, ) : WalletCardState /** * Wallet card hidden content state * - * @property id wallet id - * @property title wallet name - * @property additionalInfo wallet additional info - * @property imageResId wallet image resource id - * @property onRenameClick lambda be invoked when Rename button is clicked - * @property onDeleteClick lambda be invoked when Delete button is clicked + * @property id wallet id + * @property title wallet name + * @property imageResId wallet image resource id + * @property onRenameClick lambda be invoked when Rename button is clicked + * @property onDeleteClick lambda be invoked when Delete button is clicked */ data class HiddenContent( override val id: UserWalletId, override val title: String, - override val additionalInfo: TextReference = HIDDEN_BALANCE_TEXT, override val imageResId: Int?, override val onRenameClick: (UserWalletId, String) -> Unit, override val onDeleteClick: (UserWalletId) -> Unit, @@ -73,18 +68,18 @@ internal sealed interface WalletCardState { * * @property id wallet id * @property title wallet name - * @property additionalInfo wallet additional info * @property imageResId wallet image resource id * @property onRenameClick lambda be invoked when Rename button is clicked * @property onDeleteClick lambda be invoked when Delete button is clicked + * @property additionalInfo wallet additional info */ data class LockedContent( override val id: UserWalletId, override val title: String, - override val additionalInfo: TextReference? = null, override val imageResId: Int?, override val onRenameClick: (UserWalletId, String) -> Unit, override val onDeleteClick: (UserWalletId) -> Unit, + val additionalInfo: TextReference, ) : WalletCardState /** @@ -92,7 +87,6 @@ internal sealed interface WalletCardState { * * @property id wallet id * @property title wallet name - * @property additionalInfo wallet additional info * @property imageResId wallet image resource id * @property onRenameClick lambda be invoked when Rename button is clicked * @property onDeleteClick lambda be invoked when Delete button is clicked @@ -100,7 +94,6 @@ internal sealed interface WalletCardState { data class Error( override val id: UserWalletId, override val title: String, - override val additionalInfo: TextReference = EMPTY_BALANCE_TEXT, override val imageResId: Int?, override val onRenameClick: (UserWalletId, String) -> Unit, override val onDeleteClick: (UserWalletId) -> Unit, @@ -109,17 +102,15 @@ internal sealed interface WalletCardState { /** * Wallet card loading state * - * @property id wallet id - * @property title wallet name - * @property additionalInfo wallet additional info - * @property imageResId wallet image resource id - * @property onRenameClick lambda be invoked when Rename button is clicked - * @property onDeleteClick lambda be invoked when Delete button is clicked + * @property id wallet id + * @property title wallet name + * @property imageResId wallet image resource id + * @property onRenameClick lambda be invoked when Rename button is clicked + * @property onDeleteClick lambda be invoked when Delete button is clicked */ data class Loading( override val id: UserWalletId, override val title: String, - override val additionalInfo: TextReference? = 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/state/factory/WalletSkeletonStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt index 048164fe0b..28b5a530bb 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt @@ -4,7 +4,6 @@ import androidx.annotation.DrawableRes import com.tangem.common.Provider import com.tangem.core.ui.components.marketprice.MarketPriceBlockState import com.tangem.core.ui.components.transactions.state.TxHistoryState -import com.tangem.core.ui.extensions.TextReference import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.wallets.models.UserWallet import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory @@ -113,7 +112,7 @@ internal class WalletSkeletonStateConverter( return WalletCardState.LockedContent( id = walletId, title = name, - additionalInfo = createAdditionalInfo(), + additionalInfo = WalletAdditionalInfoFactory.resolve(wallet = this), imageResId = createImageResId(), onRenameClick = clickIntents::onRenameClick, onDeleteClick = clickIntents::onDeleteClick, @@ -124,21 +123,12 @@ internal class WalletSkeletonStateConverter( return WalletCardState.Loading( id = walletId, title = name, - additionalInfo = createAdditionalInfo(), imageResId = createImageResId(), onRenameClick = clickIntents::onRenameClick, onDeleteClick = clickIntents::onDeleteClick, ) } - private fun UserWallet.createAdditionalInfo(): TextReference? { - return if (isMultiCurrency) { - WalletAdditionalInfoFactory.resolve(wallet = this) - } else { - null - } - } - @DrawableRes private fun UserWallet.createImageResId(): Int? { return WalletImageResolver.resolve(userWallet = this) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt index c50bc11885..39f3eb7cc9 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt @@ -3,11 +3,9 @@ package com.tangem.feature.wallet.presentation.wallet.state.factory import com.tangem.common.Provider import com.tangem.core.ui.components.marketprice.MarketPriceBlockState import com.tangem.core.ui.components.transactions.state.TxHistoryState -import com.tangem.core.ui.extensions.TextReference import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.models.UserWalletId -import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory import com.tangem.feature.wallet.presentation.wallet.domain.WalletImageResolver import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState @@ -117,21 +115,12 @@ internal class WalletsUnlockStateConverter( return WalletCardState.Loading( id = id, title = title, - additionalInfo = userWallet.createAdditionalInfo(), imageResId = WalletImageResolver.resolve(userWallet = userWallet), onRenameClick = onRenameClick, onDeleteClick = onDeleteClick, ) } - private fun UserWallet.createAdditionalInfo(): TextReference? { - return if (isMultiCurrency) { - WalletAdditionalInfoFactory.resolve(wallet = this) - } else { - null - } - } - private fun WalletPullToRefreshConfig.stopRefreshing(): WalletPullToRefreshConfig { return copy(isRefreshing = false) } 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 0f3741535a..b9b6ac5d58 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 @@ -310,21 +310,17 @@ private fun Modifier.nonContentBalanceSize(dimens: TangemDimens): Modifier { @Composable private fun AdditionalInfo(state: WalletCardState, modifier: Modifier = Modifier) { AnimatedContent( - targetState = state.additionalInfo, + targetState = state, label = "Update the additional text", modifier = modifier, - ) { additionalInfo -> - if (additionalInfo != null) { - AdditionalInfoText(text = additionalInfo) - } else { - when (state) { - is WalletCardState.Loading -> { - RectangleShimmer(modifier = Modifier.nonContentAdditionalInfoSize(TangemTheme.dimens)) - } - is WalletCardState.LockedContent -> { - LockedContent(modifier = Modifier.nonContentAdditionalInfoSize(TangemTheme.dimens)) - } - else -> Unit + ) { animatedState -> + when (animatedState) { + is WalletCardState.Content -> AdditionalInfoText(text = animatedState.additionalInfo) + is WalletCardState.LockedContent -> AdditionalInfoText(text = animatedState.additionalInfo) + is WalletCardState.Error -> AdditionalInfoText(text = WalletCardState.EMPTY_BALANCE_TEXT) + is WalletCardState.HiddenContent -> AdditionalInfoText(text = WalletCardState.HIDDEN_BALANCE_TEXT) + is WalletCardState.Loading -> { + RectangleShimmer(modifier = Modifier.nonContentAdditionalInfoSize(dimens = TangemTheme.dimens)) } } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/utils/FiatBalanceToWalletCardConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/utils/FiatBalanceToWalletCardConverter.kt index 865ac6af77..d72d10693d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/utils/FiatBalanceToWalletCardConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/utils/FiatBalanceToWalletCardConverter.kt @@ -25,7 +25,7 @@ internal class FiatBalanceToWalletCardConverter( } private fun WalletCardState.toLoadingWalletCardState(): WalletCardState { - return WalletCardState.Loading(id, title, additionalInfo, imageResId, onRenameClick, onDeleteClick) + return WalletCardState.Loading(id, title, imageResId, onRenameClick, onDeleteClick) } private fun WalletCardState.toErrorWalletCardState(): WalletCardState { @@ -35,7 +35,6 @@ internal class FiatBalanceToWalletCardConverter( imageResId = imageResId, onDeleteClick = onDeleteClick, onRenameClick = onRenameClick, - additionalInfo = WalletAdditionalInfoFactory.resolve(wallet = currentWalletProvider()), ) } @@ -44,7 +43,6 @@ internal class FiatBalanceToWalletCardConverter( WalletCardState.HiddenContent( id = currentState.id, title = currentState.title, - additionalInfo = currentState.additionalInfo ?: WalletCardState.HIDDEN_BALANCE_TEXT, imageResId = currentState.imageResId, onRenameClick = currentState.onRenameClick, onDeleteClick = currentState.onDeleteClick,