Updated on 2026-08-14
This commit is contained in:
parent
90e783441c
commit
5ae5b86980
5 changed files with 78 additions and 39 deletions
|
|
@ -10,6 +10,7 @@ import com.tangem.core.ui.format.bigdecimal.format
|
|||
import com.tangem.core.ui.format.bigdecimal.percent
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.onramp.model.HotCryptoCurrency
|
||||
import com.tangem.domain.tokens.model.Quote
|
||||
import com.tangem.utils.converter.Converter
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ internal class HotTokenItemStateConverter(
|
|||
id = value.cryptoCurrency.id.value,
|
||||
iconState = CryptoCurrencyToIconStateConverter().convert(value.cryptoCurrency),
|
||||
titleState = TokenItemState.TitleState.Content(text = stringReference(value.cryptoCurrency.name)),
|
||||
subtitleState = value.getCryptoPriceState(appCurrency),
|
||||
subtitleState = value.quote.getCryptoPriceState(appCurrency),
|
||||
fiatAmountState = null,
|
||||
subtitle2State = null,
|
||||
onItemClick = onItemClick.let { onItemClick -> { onItemClick(it, value) } },
|
||||
|
|
@ -37,12 +38,17 @@ internal class HotTokenItemStateConverter(
|
|||
)
|
||||
}
|
||||
|
||||
private fun HotCryptoCurrency.getCryptoPriceState(appCurrency: AppCurrency): TokenItemState.SubtitleState {
|
||||
return TokenItemState.SubtitleState.CryptoPriceContent(
|
||||
price = fiatRate.getFormattedCryptoPrice(appCurrency),
|
||||
priceChangePercent = priceChange.format { percent() },
|
||||
type = priceChange.getPriceChangeType(),
|
||||
)
|
||||
private fun Quote.getCryptoPriceState(appCurrency: AppCurrency): TokenItemState.SubtitleState {
|
||||
return when (this) {
|
||||
is Quote.Empty -> TokenItemState.SubtitleState.Unknown
|
||||
is Quote.Value -> {
|
||||
TokenItemState.SubtitleState.CryptoPriceContent(
|
||||
price = fiatRate.getFormattedCryptoPrice(appCurrency),
|
||||
priceChangePercent = priceChange.format { percent() },
|
||||
type = priceChange.getPriceChangeType(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun BigDecimal.getFormattedCryptoPrice(appCurrency: AppCurrency): String {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue