Updated on 2026-08-14

This commit is contained in:
Tangem 2024-04-17 10:42:01 +03:00
parent f8b66b9637
commit f117e5a246
7 changed files with 44 additions and 13 deletions

View file

@ -57,6 +57,21 @@ internal object TokenDetailsPreviewData {
),
)
val tokenInfoBlockStateWithLongNameNoStandard = TokenInfoBlockState(
name = "Tether (USDT) with long name test",
iconState = TokenInfoBlockState.IconState.TokenIcon(
url = "https://s3.eu-central-1.amazonaws.com/tangem.api/coins/large/stellar.png",
fallbackTint = Color.Cyan,
fallbackBackground = Color.Blue,
isGrayscale = false,
),
currency = TokenInfoBlockState.Currency.Token(
standardName = null,
networkIcon = R.drawable.img_shibarium_22,
networkName = "Shibarium",
),
)
val tokenInfoBlockState = TokenInfoBlockState(
name = "Tether USDT",
iconState = TokenInfoBlockState.IconState.CustomTokenIcon(

View file

@ -19,7 +19,7 @@ internal data class TokenInfoBlockState(
* @param networkIcon - token's network icon.
*/
data class Token(
val standardName: String,
val standardName: String?,
val networkName: String,
@DrawableRes val networkIcon: Int,
) : Currency()

View file

@ -8,6 +8,7 @@ import com.tangem.core.ui.extensions.networkIconResId
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.res.TangemTheme
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Network
import com.tangem.feature.tokendetails.presentation.tokendetails.state.*
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsActionButton
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsPullToRefreshConfig
@ -40,7 +41,7 @@ internal class TokenDetailsSkeletonStateConverter(
currency = when (value) {
is CryptoCurrency.Coin -> TokenInfoBlockState.Currency.Native
is CryptoCurrency.Token -> TokenInfoBlockState.Currency.Token(
standardName = value.network.standardType.name,
standardName = value.network.standardType.getSpecifiedNameOrNull(),
networkName = value.network.name,
networkIcon = value.networkIconResId,
)
@ -65,6 +66,9 @@ internal class TokenDetailsSkeletonStateConverter(
)
}
private fun Network.StandardType.getSpecifiedNameOrNull(): String? =
name.takeIf { this !is Network.StandardType.Unspecified }
private fun createMenu(cryptoCurrency: CryptoCurrency): TokenDetailsAppBarMenuConfig = TokenDetailsAppBarMenuConfig(
items = buildList {
if (featureToggles.isGenerateXPubEnabled() && isBitcoin(cryptoCurrency.network.id.value)) {

View file

@ -105,13 +105,22 @@ private const val SEPARATOR = " %image% "
@Composable
private fun extractNetwork(tokenCurrency: TokenInfoBlockState.Currency.Token): ExtractedTokenNetworkText {
val splitString = stringResource(
id = R.string.token_details_token_type_subtitle,
formatArgs = arrayOf(
tokenCurrency.standardName,
tokenCurrency.networkName,
),
).split(SEPARATOR)
val splitString = if (tokenCurrency.standardName != null) {
stringResource(
id = R.string.token_details_token_type_subtitle,
formatArgs = arrayOf(
tokenCurrency.standardName,
tokenCurrency.networkName,
),
).split(SEPARATOR)
} else {
stringResource(
id = R.string.token_details_token_type_subtitle_no_standard,
formatArgs = arrayOf(
tokenCurrency.networkName,
),
).split(SEPARATOR)
}
return remember(splitString) {
ExtractedTokenNetworkText(
@ -153,5 +162,6 @@ private class TokenInfoStateProvider : CollectionPreviewParameterProvider<TokenI
TokenDetailsPreviewData.tokenInfoBlockState,
TokenDetailsPreviewData.tokenInfoBlockStateWithLongName,
TokenDetailsPreviewData.tokenInfoBlockStateWithLongNameInMainCurrency,
TokenDetailsPreviewData.tokenInfoBlockStateWithLongNameNoStandard,
),
)