Updated on 2026-08-14
This commit is contained in:
parent
6ed1946ac3
commit
aac48015b3
88 changed files with 335 additions and 239 deletions
|
|
@ -45,6 +45,7 @@ internal class HotCryptoPortfolioDataLoader @Inject constructor(
|
|||
val accountsWithHotCrypto = walletAccounts.accountStatuses.map { accountStatus ->
|
||||
val account: AccountStatus.CryptoPortfolio = when (accountStatus) {
|
||||
is AccountStatus.CryptoPortfolio -> accountStatus
|
||||
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
|
||||
}
|
||||
val addedHotCrypto = mapOfAddedCurrencies[account.account].orEmpty()
|
||||
HotCryptoPortfolioData.Account(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ internal class OnrampAddTokenUiBuilder @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun createPortfolio(tokenToAdd: AddHotCryptoData): PortfolioSelectUM {
|
||||
val accountIcon: AccountIconUM.CryptoPortfolio?
|
||||
val accountIcon: AccountIconUM?
|
||||
val portfolioName: TextReference
|
||||
val isAccountMode = isAccountsModeEnabledUseCase.invokeSync()
|
||||
when (isAccountMode) {
|
||||
|
|
@ -50,6 +50,7 @@ internal class OnrampAddTokenUiBuilder @Inject constructor(
|
|||
portfolioName = accountStatus.account.accountName.toUM().value
|
||||
accountIcon = when (accountStatus) {
|
||||
is AccountStatus.CryptoPortfolio -> CryptoPortfolioIconConverter.convert(accountStatus.account.icon)
|
||||
is AccountStatus.Payment -> AccountIconUM.Payment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ internal class LoadingAccountTokenItemConverter(
|
|||
).convert(TotalFiatBalance.Failed),
|
||||
isExpanded = true,
|
||||
isCollapsable = false,
|
||||
tokens = currencies.flattenCurrencies().map(LoadingTokenListItemConverter::convert).toPersistentList(),
|
||||
tokens = currencies.flattenCurrencies()
|
||||
.map { LoadingTokenListItemConverter.convert(it.currency) }
|
||||
.toPersistentList(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.features.onramp.swap.availablepairs.entity.converters
|
|||
import com.tangem.core.ui.components.currency.icon.CurrencyIconState
|
||||
import com.tangem.core.ui.components.token.state.TokenItemState
|
||||
import com.tangem.core.ui.components.tokenlist.state.TokensListItemUM
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
|
|
@ -11,12 +12,12 @@ import com.tangem.utils.converter.Converter
|
|||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal object LoadingTokenListItemConverter : Converter<CryptoCurrencyStatus, TokensListItemUM.Token> {
|
||||
internal object LoadingTokenListItemConverter : Converter<CryptoCurrency, TokensListItemUM.Token> {
|
||||
|
||||
override fun convert(value: CryptoCurrencyStatus): TokensListItemUM.Token {
|
||||
override fun convert(value: CryptoCurrency): TokensListItemUM.Token {
|
||||
return TokensListItemUM.Token(
|
||||
state = TokenItemState.Loading(
|
||||
id = value.currency.id.value,
|
||||
id = value.id.value,
|
||||
iconState = CurrencyIconState.Loading,
|
||||
titleState = TokenItemState.TitleState.Loading,
|
||||
subtitleState = TokenItemState.SubtitleState.Loading,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ internal class SetLoadingTokenItemsTransformer(
|
|||
|
||||
override fun transform(prevState: TokenListUM): TokenListUM {
|
||||
return prevState.copy(
|
||||
availableItems = LoadingTokenListItemConverter.convertList(input = statuses).toImmutableList(),
|
||||
availableItems = LoadingTokenListItemConverter.convertList(
|
||||
input = statuses.map(CryptoCurrencyStatus::currency),
|
||||
).toImmutableList(),
|
||||
unavailableItems = persistentListOf(),
|
||||
warning = null,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.tangem.domain.core.utils.lceLoading
|
|||
import com.tangem.domain.markets.GetMarketsTokenListFlowUseCase
|
||||
import com.tangem.domain.models.account.Account
|
||||
import com.tangem.domain.models.account.AccountStatus
|
||||
import com.tangem.domain.models.account.filterCryptoPortfolio
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.models.tokenlist.TokenList
|
||||
|
|
@ -287,7 +288,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
|
|||
): TokenListUMTransformer {
|
||||
val (appCurrency, isBalanceHidden) = appCurrencyAndBalanceHiding
|
||||
|
||||
val filterByQueryAccountList = accountList
|
||||
val filterByQueryAccountList: Map<Account.CryptoPortfolio, List<CryptoCurrencyStatus>> = accountList
|
||||
.associate { accountStatus ->
|
||||
when (accountStatus) {
|
||||
is AccountStatus.CryptoPortfolio -> {
|
||||
|
|
@ -300,6 +301,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
|
|||
|
||||
accountStatus.account to statuses
|
||||
}
|
||||
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
|
||||
}
|
||||
}
|
||||
.filterValues { it.isNotEmpty() }
|
||||
|
|
@ -360,7 +362,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
|
|||
onRefresh = {
|
||||
modelScope.launch {
|
||||
if (networkInfo != null) {
|
||||
accountList.filterIsInstance<AccountStatus.CryptoPortfolio>()
|
||||
accountList.filterCryptoPortfolio()
|
||||
.forEach { (_, currencies) ->
|
||||
updateAvailablePairs(networkInfo, currencies.flattenCurrencies())
|
||||
}
|
||||
|
|
@ -384,7 +386,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
|
|||
val accountList = accountListFlow.firstOrNull() ?: return@collectLatest
|
||||
updateAvailablePairs(
|
||||
networkInfo = networkInfo,
|
||||
statuses = accountList.filterIsInstance<AccountStatus.CryptoPortfolio>()
|
||||
statuses = accountList.filterCryptoPortfolio()
|
||||
.flatMap { accountStatus ->
|
||||
accountStatus.flattenCurrencies()
|
||||
}.toSet().toList(),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.tangem.features.onramp.tokenlist.entity.transformer
|
|||
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.models.account.AccountStatus
|
||||
import com.tangem.domain.models.account.filterCryptoPortfolio
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.features.onramp.swap.availablepairs.entity.converters.LoadingAccountTokenItemConverter
|
||||
import com.tangem.features.onramp.swap.availablepairs.entity.converters.LoadingTokenListItemConverter
|
||||
import com.tangem.features.onramp.tokenlist.entity.TokenListUM
|
||||
|
|
@ -22,6 +24,7 @@ internal class SetLoadingAccountTokenListTransformer(
|
|||
val totalTokensCount = accountList.sumOf { account ->
|
||||
when (account) {
|
||||
is AccountStatus.CryptoPortfolio -> account.tokenList.flattenCurrencies().size
|
||||
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +34,7 @@ internal class SetLoadingAccountTokenListTransformer(
|
|||
tokensListData = if (isAccountsMode) {
|
||||
TokenListUMData.AccountList(
|
||||
tokensList = accountListItemConverter.convertList(
|
||||
accountList.filterIsInstance<AccountStatus.CryptoPortfolio>(),
|
||||
accountList.filterCryptoPortfolio(),
|
||||
).toPersistentList(),
|
||||
totalTokensCount = totalTokensCount,
|
||||
)
|
||||
|
|
@ -40,8 +43,9 @@ internal class SetLoadingAccountTokenListTransformer(
|
|||
tokensList = accountList.flatMap { account ->
|
||||
when (account) {
|
||||
is AccountStatus.CryptoPortfolio -> LoadingTokenListItemConverter.convertList(
|
||||
account.tokenList.flattenCurrencies(),
|
||||
account.tokenList.flattenCurrencies().map(CryptoCurrencyStatus::currency),
|
||||
)
|
||||
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
|
||||
}
|
||||
}.toPersistentList(),
|
||||
totalTokensCount = totalTokensCount,
|
||||
|
|
|
|||
|
|
@ -295,13 +295,16 @@ internal class OnrampTokenListModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun AccountStatusList.filterAccountsByQuery(query: String) = accountStatuses.asSequence()
|
||||
private fun AccountStatusList.filterAccountsByQuery(
|
||||
query: String,
|
||||
): Map<Account.CryptoPortfolio, List<CryptoCurrencyStatus>> = accountStatuses.asSequence()
|
||||
.associate { accountStatus ->
|
||||
when (accountStatus) {
|
||||
is AccountStatus.CryptoPortfolio -> {
|
||||
val filteredList = accountStatus.tokenList.flattenCurrencies().filterByQuery(query = query)
|
||||
accountStatus.account to filteredList
|
||||
}
|
||||
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
|
||||
}
|
||||
}.filter { (_, value) -> value.isNotEmpty() }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue