Updated on 2026-08-14

This commit is contained in:
Tangem 2022-05-25 15:53:41 +03:00
parent 97dfc6c840
commit 9c237134f1
3 changed files with 22 additions and 11 deletions

View file

@ -26,7 +26,12 @@ import com.tangem.tap.domain.extensions.toSendableAmounts
import com.tangem.tap.domain.tokens.BlockchainNetwork
import com.tangem.tap.features.onboarding.products.twins.redux.TwinCardsState
import com.tangem.tap.features.tokens.redux.TokenWithBlockchain
import com.tangem.tap.features.wallet.models.*
import com.tangem.tap.features.wallet.models.PendingTransaction
import com.tangem.tap.features.wallet.models.TotalBalance
import com.tangem.tap.features.wallet.models.WalletRent
import com.tangem.tap.features.wallet.models.WalletWarning
import com.tangem.tap.features.wallet.models.toPendingTransactions
import com.tangem.tap.features.wallet.models.toPendingTransactionsForToken
import com.tangem.tap.features.wallet.ui.BalanceStatus
import com.tangem.tap.features.wallet.ui.BalanceWidgetData
import com.tangem.tap.network.exchangeServices.CurrencyExchangeManager
@ -278,7 +283,7 @@ data class WalletState(
}
fun updateTotalBalance(
totalBalance: TotalBalance
totalBalance: TotalBalance?
): WalletState {
return this.copy(
totalBalance = totalBalance

View file

@ -9,12 +9,14 @@ import java.math.BigDecimal
fun obtainTotalBalance(
wallets: List<WalletData>,
appCurrency: FiatCurrency
): TotalBalance {
return TotalBalance(
state = wallets.findTotalBalanceState(),
fiatAmount = wallets.calculateTotalFiatAmount(),
fiatCurrency = appCurrency
)
): TotalBalance? {
return if (wallets.isNotEmpty()) {
TotalBalance(
state = wallets.findTotalBalanceState(),
fiatAmount = wallets.calculateTotalFiatAmount(),
fiatCurrency = appCurrency
)
} else null
}
private fun List<WalletData>.findTotalBalanceState(): TotalBalance.State {

View file

@ -55,7 +55,6 @@ class MultiWalletView : WalletView {
btnScanMultiwallet.show()
rvMultiwallet.show()
btnAddToken.show()
lCardTotalBalance.root.show()
setupWalletCardNumber(binding)
}
@ -102,7 +101,7 @@ class MultiWalletView : WalletView {
val fragment = fragment ?: return
val binding = binding ?: return
state.totalBalance?.let { handleTotalBalance(binding, it) }
handleTotalBalance(binding, state.totalBalance)
walletsAdapter.submitList(state.walletsData, state.primaryBlockchain, state.primaryToken)
binding.btnAddToken.setOnClickListener {
@ -135,8 +134,13 @@ class MultiWalletView : WalletView {
private fun handleTotalBalance(
binding: FragmentWalletBinding,
totalBalance: TotalBalance,
totalBalance: TotalBalance?,
) = with(binding.lCardTotalBalance) {
if (totalBalance == null) {
this.root.hide()
return@with
}
tvBalance.animateVisibility(
show = totalBalance.state != TotalBalance.State.Loading,
hiddenVisibility = View.INVISIBLE