Updated on 2026-08-14

This commit is contained in:
Tangem 2024-04-22 18:24:54 +03:00
parent 4c0e92ffc6
commit ee3d9ff43b
2 changed files with 15 additions and 9 deletions

View file

@ -20,17 +20,22 @@ class CryptoCurrencyToIconStateConverter : Converter<CryptoCurrencyStatus, Token
}
}
fun convertWithGrayscale(value: CryptoCurrencyStatus): TokenIconState {
fun convertCustom(
value: CryptoCurrencyStatus,
forceGrayscale: Boolean,
showCustomTokenBadge: Boolean,
): TokenIconState {
return when (val currency = value.currency) {
is CryptoCurrency.Coin -> getIconStateForCoin(
coin = currency,
isUnreachable = value.value.isError,
forceGrayscale = true,
forceGrayscale = forceGrayscale,
)
is CryptoCurrency.Token -> getIconStateForToken(
token = currency,
isErrorStatus = value.value.isError,
forceGrayscale = true,
forceGrayscale = forceGrayscale,
showCustomBadge = showCustomTokenBadge,
)
}
}
@ -58,6 +63,7 @@ class CryptoCurrencyToIconStateConverter : Converter<CryptoCurrencyStatus, Token
private fun getIconStateForToken(
token: CryptoCurrency.Token,
isErrorStatus: Boolean,
showCustomBadge: Boolean = true,
forceGrayscale: Boolean = false,
): TokenIconState {
val grayScale = forceGrayscale || token.network.isTestnet || isErrorStatus
@ -78,7 +84,7 @@ class CryptoCurrencyToIconStateConverter : Converter<CryptoCurrencyStatus, Token
isGrayscale = grayScale,
fallbackTint = tint,
fallbackBackground = background,
showCustomBadge = token.isCustom, // `true` for tokens with custom derivation
showCustomBadge = token.isCustom && showCustomBadge, // `true` for tokens with custom derivation
)
}
}

View file

@ -46,11 +46,11 @@ internal class SendAmountStateConverter(
segmentedButtonConfig = persistentListOf(
SendAmountSegmentedButtonsConfig(
title = stringReference(status.currency.symbol),
iconState = if (noFeeRate) {
iconStateConverter.convertWithGrayscale(status)
} else {
iconStateConverter.convert(status)
},
iconState = iconStateConverter.convertCustom(
value = status,
forceGrayscale = noFeeRate,
showCustomTokenBadge = false,
),
isFiat = false,
),
SendAmountSegmentedButtonsConfig(