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 47d6b066db..345627ff8d 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 @@ -56,6 +56,7 @@ private const val HALF_OF_ITEM_WIDTH = 0.5 * [REDACTED_AUTHOR] */ +@Suppress("LongMethod") @Composable internal fun WalletCard(state: WalletCardState, isBalanceHidden: Boolean, modifier: Modifier = Modifier) { @Suppress("DestructuringDeclarationWithTooManyEntries") @@ -93,25 +94,29 @@ internal fun WalletCard(state: WalletCardState, isBalanceHidden: Boolean, modifi }, ) + val additionalText by remember(state.additionalInfo, isBalanceHidden) { + mutableStateOf( + if (state.additionalInfo?.hideable == true && isBalanceHidden) { + WalletCardState.HIDDEN_BALANCE_TEXT + } else { + state.additionalInfo?.content + }, + ) + } AdditionalInfo( - text = if (state.additionalInfo?.hideable == true && isBalanceHidden) { - WalletCardState.HIDDEN_BALANCE_TEXT - } else { - state.additionalInfo?.content - }, + text = additionalText, modifier = Modifier.constrainAs(additionalTextRef) { start.linkTo(parent.start) top.linkTo(balanceRef.bottom) bottom.linkTo(anchor = parent.bottom, margin = contentVerticalMargin) - when (state) { - is WalletCardState.Content, - is WalletCardState.Error, - -> { + if (additionalText != null) { + width = if (state.imageResId != null) { end.linkTo(imageRef.start) - width = Dimension.fillToConstraints + Dimension.fillToConstraints + } else { + Dimension.wrapContent } - else -> Unit } }, ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt index cb4da3165e..dc32847800 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt @@ -782,7 +782,7 @@ internal class WalletViewModel @Inject constructor( viewModelScope.launch(dispatchers.main) { singleWalletCryptoCurrencyStatus?.let { - updateButtons(wallet.walletId, it) + updateButtons(userWallet = wallet, currencyStatus = it) } val result = fetchCurrencyStatusUseCase(wallet.walletId, refresh = true) @@ -1183,7 +1183,7 @@ internal class WalletViewModel @Inject constructor( } updateNotifications(index) - updateButtons(wallet.walletId, status) + updateButtons(userWallet = wallet, currencyStatus = status) updateTxHistory(wallet.walletId, status.currency, refresh = false) } } @@ -1265,10 +1265,9 @@ internal class WalletViewModel @Inject constructor( } } - private suspend fun updateButtons(userWalletId: UserWalletId, currencyStatus: CryptoCurrencyStatus) { - val userWallet = getSelectedWallet() + private suspend fun updateButtons(userWallet: UserWallet, currencyStatus: CryptoCurrencyStatus) { getCryptoCurrencyActionsUseCase( - userWalletId = userWalletId, + userWalletId = userWallet.walletId, cryptoCurrencyStatus = currencyStatus, isSingleWalletWithTokens = userWallet.scanResponse.cardTypesResolver.isSingleWalletWithToken(), )