Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-08 16:02:56 +05:00
parent cd4227fcb1
commit f76f28ae0c

View file

@ -1,5 +1,6 @@
package com.tangem.features.nft.details.entity.transformer
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.fiat
@ -8,6 +9,7 @@ import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.nft.models.NFTSalePrice
import com.tangem.features.nft.details.entity.NFTAssetUM
import com.tangem.features.nft.details.entity.NFTDetailsUM
import com.tangem.features.nft.impl.R
import com.tangem.utils.transformer.Transformer
internal class NFTPriceChangeTransformer(
@ -18,10 +20,7 @@ internal class NFTPriceChangeTransformer(
override fun transform(prevState: NFTDetailsUM): NFTDetailsUM {
val topInfo = prevState.nftAsset.topInfo as? NFTAssetUM.TopInfo.Content ?: return prevState
return prevState.copy(
nftAsset = prevState.nftAsset.copy(
topInfo = topInfo.copy(
salePrice = when (nftSalePrice) {
val salePrice = when (nftSalePrice) {
is NFTSalePrice.Empty,
is NFTSalePrice.Error,
-> NFTAssetUM.SalePrice.Empty
@ -45,8 +44,26 @@ internal class NFTPriceChangeTransformer(
},
),
)
},
),
}
val hasSalePrice = salePrice !is NFTAssetUM.SalePrice.Empty
val newTopInfo = if (
topInfo.rarity is NFTAssetUM.Rarity.Empty &&
topInfo.description.isNullOrEmpty() &&
!hasSalePrice
) {
NFTAssetUM.TopInfo.Empty
} else {
topInfo.copy(
title = resourceReference(R.string.nft_details_last_sale_price).takeIf { hasSalePrice },
salePrice = salePrice,
)
}
return prevState.copy(
nftAsset = prevState.nftAsset.copy(
topInfo = newTopInfo,
),
)
}