Updated on 2026-08-14
This commit is contained in:
commit
e767dcc032
15 changed files with 288 additions and 84 deletions
|
|
@ -28,6 +28,7 @@ dependencies {
|
|||
|
||||
/** Domain modules */
|
||||
implementation(projects.domain.appCurrency.models)
|
||||
implementation(projects.domain.appCurrency)
|
||||
implementation(projects.domain.models)
|
||||
implementation(projects.domain.nft)
|
||||
implementation(projects.domain.nft.models)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package com.tangem.features.nft.collections.entity
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
||||
@Immutable
|
||||
internal sealed class NFTSalePriceUM {
|
||||
data object Loading : NFTSalePriceUM()
|
||||
data object Failed : NFTSalePriceUM()
|
||||
data class Content(val price: String) : NFTSalePriceUM()
|
||||
data class Content(val price: TextReference) : NFTSalePriceUM()
|
||||
}
|
||||
|
|
@ -2,10 +2,9 @@ package com.tangem.features.nft.collections.entity.transformer
|
|||
|
||||
import com.tangem.core.ui.components.fields.entity.SearchBarUM
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.getActiveIconRes
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.extensions.*
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
import com.tangem.domain.nft.models.*
|
||||
import com.tangem.features.nft.collections.entity.*
|
||||
import com.tangem.features.nft.impl.R
|
||||
|
|
@ -146,20 +145,31 @@ internal class UpdateDataStateTransformer(
|
|||
)
|
||||
}
|
||||
|
||||
private fun NFTAsset.transform(collectionName: String): NFTCollectionAssetUM = NFTCollectionAssetUM(
|
||||
id = id.toString(),
|
||||
name = name.orEmpty(),
|
||||
imageUrl = media?.url,
|
||||
price = when (val salePrice = salePrice) {
|
||||
is NFTSalePrice.Empty -> NFTSalePriceUM.Failed
|
||||
is NFTSalePrice.Loading -> NFTSalePriceUM.Loading
|
||||
is NFTSalePrice.Error -> NFTSalePriceUM.Failed
|
||||
is NFTSalePrice.Value -> NFTSalePriceUM.Content(salePrice.value.toString())
|
||||
},
|
||||
onItemClick = {
|
||||
onAssetClick(this, collectionName)
|
||||
},
|
||||
)
|
||||
private fun NFTAsset.transform(collectionName: String): NFTCollectionAssetUM {
|
||||
return NFTCollectionAssetUM(
|
||||
id = id.toString(),
|
||||
name = name.orEmpty(),
|
||||
imageUrl = media?.url,
|
||||
price = when (val salePrice = salePrice) {
|
||||
is NFTSalePrice.Empty -> NFTSalePriceUM.Failed
|
||||
is NFTSalePrice.Loading -> NFTSalePriceUM.Loading
|
||||
is NFTSalePrice.Error -> NFTSalePriceUM.Failed
|
||||
is NFTSalePrice.Value -> NFTSalePriceUM.Content(
|
||||
price = stringReference(
|
||||
salePrice.value.format {
|
||||
crypto(
|
||||
symbol = salePrice.symbol,
|
||||
decimals = salePrice.decimals,
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
onItemClick = {
|
||||
onAssetClick(this, collectionName)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
private fun NFTCollection.isExpanded(state: NFTCollectionsStateUM): Boolean =
|
||||
(state.content as? NFTCollectionsUM.Content)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import coil.request.ImageRequest
|
|||
import com.tangem.core.ui.components.RectangleShimmer
|
||||
import com.tangem.core.ui.components.SpacerH12
|
||||
import com.tangem.core.ui.components.SpacerH2
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.features.nft.collections.entity.NFTCollectionAssetUM
|
||||
|
|
@ -116,7 +117,9 @@ private class NFTCollectionAssetProvider : CollectionPreviewParameterProvider<NF
|
|||
id = "item3",
|
||||
name = "Nethers #0855",
|
||||
imageUrl = "img",
|
||||
price = NFTSalePriceUM.Content("0.05 ETH"),
|
||||
price = NFTSalePriceUM.Content(
|
||||
price = stringReference("0.05 ETH"),
|
||||
),
|
||||
onItemClick = { },
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.tangem.core.ui.components.fields.entity.SearchBarUM
|
|||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
|
|
@ -338,7 +339,9 @@ private fun Preview_NFTCollectionsContent() {
|
|||
id = "item1",
|
||||
name = "Nethers #0854",
|
||||
imageUrl = "img",
|
||||
price = NFTSalePriceUM.Content("0.05 ETH"),
|
||||
price = NFTSalePriceUM.Content(
|
||||
price = stringReference("0.05 ETH"),
|
||||
),
|
||||
onItemClick = { },
|
||||
),
|
||||
NFTCollectionAssetUM(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import com.tangem.core.ui.components.TextShimmer
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.features.nft.collections.entity.NFTSalePriceUM
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ internal fun NFTSalePrice(state: NFTSalePriceUM, modifier: Modifier = Modifier)
|
|||
is NFTSalePriceUM.Content -> {
|
||||
Text(
|
||||
modifier = modifier,
|
||||
text = state.price,
|
||||
text = state.price.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
maxLines = 1,
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ package com.tangem.features.nft.details.entity
|
|||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.components.atoms.text.TextEllipsis
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import java.math.BigDecimal
|
||||
|
||||
data class NFTAssetUM(
|
||||
val name: String,
|
||||
|
|
@ -41,11 +39,9 @@ data class NFTAssetUM(
|
|||
data object Loading : SalePrice()
|
||||
data object Empty : SalePrice()
|
||||
data class Content(
|
||||
val value: BigDecimal,
|
||||
val symbol: String,
|
||||
val decimals: Int,
|
||||
val rate: BigDecimal?,
|
||||
val appCurrency: AppCurrency,
|
||||
val isFlickering: Boolean,
|
||||
val cryptoPrice: TextReference,
|
||||
val fiatPrice: TextReference,
|
||||
) : SalePrice()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.tangem.features.nft.details.entity
|
||||
|
||||
import com.tangem.core.ui.components.containers.pullToRefresh.PullToRefreshConfig
|
||||
|
||||
internal data class NFTDetailsUM(
|
||||
val nftAsset: NFTAssetUM,
|
||||
val pullToRefreshConfig: PullToRefreshConfig,
|
||||
val onBackClick: () -> Unit,
|
||||
val onReadMoreClick: () -> Unit,
|
||||
val onSeeAllTraitsClick: () -> Unit,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
package com.tangem.features.nft.details.entity.factory
|
||||
|
||||
import com.tangem.core.ui.components.atoms.text.TextEllipsis
|
||||
import com.tangem.core.ui.components.containers.pullToRefresh.PullToRefreshConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
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
|
||||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.nft.models.NFTAsset
|
||||
import com.tangem.domain.nft.models.NFTSalePrice
|
||||
import com.tangem.features.nft.details.entity.NFTAssetUM
|
||||
|
|
@ -12,17 +17,24 @@ import com.tangem.features.nft.impl.R
|
|||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
internal class NFTDetailsUMFactory(
|
||||
private val appCurrency: AppCurrency,
|
||||
private val onBackClick: () -> Unit,
|
||||
private val onReadMoreClick: () -> Unit,
|
||||
private val onSeeAllTraitsClick: () -> Unit,
|
||||
private val onExploreClick: () -> Unit,
|
||||
private val onSendClick: () -> Unit,
|
||||
private val onRefresh: () -> Unit,
|
||||
private val onInfoBlockClick: (title: TextReference, text: TextReference) -> Unit,
|
||||
) {
|
||||
|
||||
fun getInitialState(nftAsset: NFTAsset): NFTDetailsUM = NFTDetailsUM(
|
||||
nftAsset = nftAsset.transform(),
|
||||
pullToRefreshConfig = PullToRefreshConfig(
|
||||
isRefreshing = false,
|
||||
onRefresh = { onRefresh() },
|
||||
),
|
||||
onBackClick = onBackClick,
|
||||
onReadMoreClick = onReadMoreClick,
|
||||
onSeeAllTraitsClick = onSeeAllTraitsClick,
|
||||
|
|
@ -52,7 +64,7 @@ internal class NFTDetailsUMFactory(
|
|||
} else {
|
||||
null
|
||||
},
|
||||
salePrice = NFTAssetUM.SalePrice.Empty,
|
||||
salePrice = toSalePrice(),
|
||||
description = description,
|
||||
rarity = if (rarity != null) {
|
||||
NFTAssetUM.Rarity.Content(
|
||||
|
|
@ -91,6 +103,32 @@ internal class NFTDetailsUMFactory(
|
|||
|
||||
private fun NFTAsset.hasSalePrice() = salePrice !is NFTSalePrice.Empty && salePrice !is NFTSalePrice.Error
|
||||
|
||||
private fun NFTAsset.toSalePrice() = when (val price = salePrice) {
|
||||
is NFTSalePrice.Empty,
|
||||
is NFTSalePrice.Error,
|
||||
-> NFTAssetUM.SalePrice.Empty
|
||||
is NFTSalePrice.Loading -> NFTAssetUM.SalePrice.Loading
|
||||
is NFTSalePrice.Value -> NFTAssetUM.SalePrice.Content(
|
||||
isFlickering = false,
|
||||
cryptoPrice = stringReference(
|
||||
price.value.format {
|
||||
crypto(
|
||||
symbol = price.symbol,
|
||||
decimals = price.decimals,
|
||||
)
|
||||
},
|
||||
),
|
||||
fiatPrice = stringReference(
|
||||
price.fiatValue.format {
|
||||
fiat(
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
private fun NFTAsset.buildBaseInfoItems() = when (val id = id) {
|
||||
is NFTAsset.Identifier.EVM -> persistentListOf(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package com.tangem.features.nft.details.entity.transformer
|
||||
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
import com.tangem.core.ui.format.bigdecimal.fiat
|
||||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
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.utils.transformer.Transformer
|
||||
|
||||
internal class NFTPriceChangeTransformer(
|
||||
private val appCurrency: AppCurrency,
|
||||
private val nftSalePrice: NFTSalePrice,
|
||||
) : Transformer<NFTDetailsUM> {
|
||||
|
||||
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) {
|
||||
is NFTSalePrice.Empty,
|
||||
is NFTSalePrice.Error,
|
||||
-> NFTAssetUM.SalePrice.Empty
|
||||
is NFTSalePrice.Loading -> NFTAssetUM.SalePrice.Loading
|
||||
is NFTSalePrice.Value -> NFTAssetUM.SalePrice.Content(
|
||||
isFlickering = false,
|
||||
cryptoPrice = stringReference(
|
||||
nftSalePrice.value.format {
|
||||
crypto(
|
||||
symbol = nftSalePrice.symbol,
|
||||
decimals = nftSalePrice.decimals,
|
||||
)
|
||||
},
|
||||
),
|
||||
fiatPrice = stringReference(
|
||||
nftSalePrice.fiatValue.format {
|
||||
fiat(
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.tangem.features.nft.details.entity.transformer
|
||||
|
||||
import com.tangem.features.nft.details.entity.NFTAssetUM
|
||||
import com.tangem.features.nft.details.entity.NFTDetailsUM
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
internal object NFTPriceUpdatingTransformer : Transformer<NFTDetailsUM> {
|
||||
|
||||
override fun transform(prevState: NFTDetailsUM): NFTDetailsUM {
|
||||
val topInfo = prevState.nftAsset.topInfo as? NFTAssetUM.TopInfo.Content ?: return prevState
|
||||
val salePrice = topInfo.salePrice as? NFTAssetUM.SalePrice.Content
|
||||
return prevState.copy(
|
||||
nftAsset = prevState.nftAsset.copy(
|
||||
topInfo = topInfo.copy(
|
||||
salePrice = salePrice?.copy(
|
||||
isFlickering = true,
|
||||
) ?: topInfo.salePrice,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.nft.details.model
|
||||
|
||||
import arrow.core.getOrElse
|
||||
import com.arkivanov.decompose.router.slot.SlotNavigation
|
||||
import com.arkivanov.decompose.router.slot.activate
|
||||
import com.tangem.common.routing.AppRoute
|
||||
|
|
@ -12,20 +13,31 @@ import com.tangem.core.navigation.url.UrlOpener
|
|||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.nft.FetchNFTCollectionAssetsUseCase
|
||||
import com.tangem.domain.nft.FetchNFTPriceUseCase
|
||||
import com.tangem.domain.nft.GetNFTExploreUrlUseCase
|
||||
import com.tangem.domain.nft.GetNFTPriceUseCase
|
||||
import com.tangem.domain.nft.analytics.NFTAnalyticsEvent
|
||||
import com.tangem.features.nft.details.NFTDetailsComponent
|
||||
import com.tangem.features.nft.details.entity.NFTAssetUM
|
||||
import com.tangem.features.nft.details.entity.NFTDetailsBottomSheetConfig
|
||||
import com.tangem.features.nft.details.entity.NFTDetailsUM
|
||||
import com.tangem.features.nft.details.entity.factory.NFTDetailsUMFactory
|
||||
import com.tangem.features.nft.details.entity.transformer.NFTPriceChangeTransformer
|
||||
import com.tangem.features.nft.details.entity.transformer.NFTPriceUpdatingTransformer
|
||||
import com.tangem.features.nft.impl.R
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import com.tangem.utils.transformer.update
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@ModelScoped
|
||||
internal class NFTDetailsModel @Inject constructor(
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
|
|
@ -33,6 +45,10 @@ internal class NFTDetailsModel @Inject constructor(
|
|||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
private val urlOpener: UrlOpener,
|
||||
private val getNFTExploreUrlUseCase: GetNFTExploreUrlUseCase,
|
||||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
private val getNFTPriceUseCase: GetNFTPriceUseCase,
|
||||
private val fetchNFTCollectionAssetsUseCase: FetchNFTCollectionAssetsUseCase,
|
||||
private val fetchNFTPriceUseCase: FetchNFTPriceUseCase,
|
||||
paramsContainer: ParamsContainer,
|
||||
) : Model() {
|
||||
|
||||
|
|
@ -40,23 +56,88 @@ internal class NFTDetailsModel @Inject constructor(
|
|||
|
||||
val state: StateFlow<NFTDetailsUM> get() = _state
|
||||
|
||||
private var appCurrency: AppCurrency = AppCurrency.Default
|
||||
|
||||
private val stateFactory: NFTDetailsUMFactory = NFTDetailsUMFactory(
|
||||
appCurrency = appCurrency,
|
||||
onBackClick = { params.onBackClick() },
|
||||
onReadMoreClick = ::onReadMoreClick,
|
||||
onSeeAllTraitsClick = { params.onAllTraitsClick() },
|
||||
onExploreClick = ::onExploreClick,
|
||||
onSendClick = ::onSendClick,
|
||||
onInfoBlockClick = ::onInfoBlockClick,
|
||||
onRefresh = ::onRefresh,
|
||||
)
|
||||
|
||||
private val _state = MutableStateFlow(
|
||||
value = stateFactory.getInitialState(params.nftAsset),
|
||||
)
|
||||
private val _state by lazy {
|
||||
MutableStateFlow(
|
||||
value = stateFactory.getInitialState(params.nftAsset),
|
||||
)
|
||||
}
|
||||
|
||||
val bottomSheetNavigation: SlotNavigation<NFTDetailsBottomSheetConfig> = SlotNavigation()
|
||||
|
||||
init {
|
||||
analyticsEventHandler.send(NFTAnalyticsEvent.Details.ScreenOpened(params.nftAsset.network.name))
|
||||
initAppCurrency()
|
||||
subscribeToPriceChanges()
|
||||
}
|
||||
|
||||
private fun initAppCurrency() {
|
||||
modelScope.launch {
|
||||
appCurrency = getSelectedAppCurrencyUseCase.invokeSync().getOrElse { AppCurrency.Default }
|
||||
}
|
||||
}
|
||||
|
||||
private fun subscribeToPriceChanges() {
|
||||
_state.update(NFTPriceUpdatingTransformer)
|
||||
modelScope.launch {
|
||||
getNFTPriceUseCase(params.userWalletId, params.nftAsset)
|
||||
.fold(
|
||||
ifLeft = {
|
||||
Timber.w(it)
|
||||
},
|
||||
ifRight = { quoteFlow ->
|
||||
quoteFlow
|
||||
.distinctUntilChanged()
|
||||
.onEach { salePrice ->
|
||||
_state.update(
|
||||
NFTPriceChangeTransformer(
|
||||
appCurrency = appCurrency,
|
||||
nftSalePrice = salePrice,
|
||||
),
|
||||
)
|
||||
}.launchIn(modelScope)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onRefresh() {
|
||||
_state.update {
|
||||
it.copy(pullToRefreshConfig = it.pullToRefreshConfig.copy(isRefreshing = true))
|
||||
}
|
||||
_state.update(NFTPriceUpdatingTransformer)
|
||||
modelScope.launch {
|
||||
awaitAll(
|
||||
async {
|
||||
fetchNFTCollectionAssetsUseCase(
|
||||
userWalletId = params.userWalletId,
|
||||
network = params.nftAsset.network,
|
||||
collectionId = params.nftAsset.collectionId,
|
||||
)
|
||||
},
|
||||
async {
|
||||
fetchNFTPriceUseCase(
|
||||
network = params.nftAsset.network,
|
||||
appCurrencyId = null,
|
||||
)
|
||||
},
|
||||
)
|
||||
_state.update {
|
||||
it.copy(pullToRefreshConfig = it.pullToRefreshConfig.copy(isRefreshing = false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onInfoBlockClick(title: TextReference, text: TextReference) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.features.nft.details.ui
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
|
|
@ -11,6 +12,7 @@ import androidx.compose.ui.Modifier
|
|||
import com.tangem.core.ui.components.PrimaryButton
|
||||
import com.tangem.core.ui.components.appbar.TangemTopAppBar
|
||||
import com.tangem.core.ui.components.appbar.models.TopAppBarButtonUM
|
||||
import com.tangem.core.ui.components.containers.pullToRefresh.TangemPullToRefreshContainer
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.features.nft.details.entity.NFTDetailsUM
|
||||
|
|
@ -34,14 +36,19 @@ internal fun NFTDetails(state: NFTDetailsUM, modifier: Modifier = Modifier) {
|
|||
)
|
||||
},
|
||||
content = { innerPadding ->
|
||||
NFTDetailsAsset(
|
||||
state = state.nftAsset,
|
||||
onReadMoreClick = state.onReadMoreClick,
|
||||
onSeeAllTraitsClick = state.onSeeAllTraitsClick,
|
||||
onExploreClick = state.onExploreClick,
|
||||
TangemPullToRefreshContainer(
|
||||
config = state.pullToRefreshConfig,
|
||||
modifier = Modifier
|
||||
.padding(innerPadding),
|
||||
)
|
||||
.padding(innerPadding)
|
||||
.fillMaxSize(),
|
||||
) {
|
||||
NFTDetailsAsset(
|
||||
state = state.nftAsset,
|
||||
onReadMoreClick = state.onReadMoreClick,
|
||||
onSeeAllTraitsClick = state.onSeeAllTraitsClick,
|
||||
onExploreClick = state.onExploreClick,
|
||||
)
|
||||
}
|
||||
},
|
||||
floatingActionButtonPosition = FabPosition.Center,
|
||||
floatingActionButton = {
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@ import com.tangem.core.ui.extensions.resourceReference
|
|||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.features.nft.details.entity.NFTAssetUM
|
||||
import com.tangem.features.nft.impl.R
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import java.math.BigDecimal
|
||||
|
||||
@Composable
|
||||
internal fun NFTDetailsAsset(
|
||||
|
|
@ -127,11 +125,9 @@ private class NFTAssetProvider : CollectionPreviewParameterProvider<NFTAssetUM>(
|
|||
topInfo = NFTAssetUM.TopInfo.Content(
|
||||
title = resourceReference(R.string.nft_details_last_sale_price),
|
||||
salePrice = NFTAssetUM.SalePrice.Content(
|
||||
value = BigDecimal("18.75"),
|
||||
symbol = "ETH",
|
||||
decimals = 18,
|
||||
rate = BigDecimal("1"),
|
||||
appCurrency = AppCurrency.Default,
|
||||
cryptoPrice = stringReference("ETH 18.75"),
|
||||
fiatPrice = stringReference("$ 1"),
|
||||
isFlickering = true,
|
||||
),
|
||||
description = "Base edition by Piux. An illustration of Crypto Robot #7804".repeat(3),
|
||||
rarity = NFTAssetUM.Rarity.Content(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.tangem.features.nft.details.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
|
|
@ -14,21 +17,17 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.common.ui.amountScreen.utils.getFiatString
|
||||
import com.tangem.core.ui.components.TextShimmer
|
||||
import com.tangem.core.ui.components.atoms.text.ReadMoreText
|
||||
import com.tangem.core.ui.components.block.information.InformationBlock
|
||||
import com.tangem.core.ui.components.flicker
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
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.format
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.features.nft.details.entity.NFTAssetUM
|
||||
import com.tangem.features.nft.impl.R
|
||||
import java.math.BigDecimal
|
||||
|
||||
private const val READ_MORE_MAX_LINES = 3
|
||||
|
||||
|
|
@ -68,7 +67,9 @@ internal fun NFTDetailsInfoGroup(
|
|||
@Composable
|
||||
private fun SalePrice(state: NFTAssetUM.SalePrice, modifier: Modifier = Modifier) {
|
||||
AnimatedVisibility(
|
||||
modifier = Modifier.fillMaxWidth().animateContentSize(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.animateContentSize(),
|
||||
visible = state !is NFTAssetUM.SalePrice.Empty,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut(),
|
||||
|
|
@ -108,19 +109,15 @@ private fun SalePrice(state: NFTAssetUM.SalePrice, modifier: Modifier = Modifier
|
|||
verticalArrangement = Arrangement.SpaceAround,
|
||||
) {
|
||||
Text(
|
||||
text = state.value.format {
|
||||
crypto(
|
||||
symbol = state.symbol,
|
||||
decimals = state.decimals,
|
||||
)
|
||||
},
|
||||
text = state.cryptoPrice.resolveReference(),
|
||||
style = TangemTheme.typography.head,
|
||||
color = TangemTheme.colors.text.primary1,
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.padding(top = TangemTheme.dimens.spacing4),
|
||||
text = getFiatString(state.value, state.rate, state.appCurrency),
|
||||
.padding(top = TangemTheme.dimens.spacing4)
|
||||
.flicker(state.isFlickering),
|
||||
text = state.fiatPrice.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
)
|
||||
|
|
@ -237,11 +234,9 @@ private class NFTAssetInfoProvider : CollectionPreviewParameterProvider<NFTAsset
|
|||
NFTAssetUM.TopInfo.Content(
|
||||
title = resourceReference(R.string.nft_details_last_sale_price),
|
||||
salePrice = NFTAssetUM.SalePrice.Content(
|
||||
value = BigDecimal("18.75"),
|
||||
symbol = "ETH",
|
||||
decimals = 18,
|
||||
rate = BigDecimal("1"),
|
||||
appCurrency = AppCurrency.Default,
|
||||
cryptoPrice = stringReference("ETH 18.75"),
|
||||
fiatPrice = stringReference("$ 1"),
|
||||
isFlickering = false,
|
||||
),
|
||||
description = "Base edition by Piux. An illustration of Crypto Robot #7804".repeat(3),
|
||||
rarity = NFTAssetUM.Rarity.Content(
|
||||
|
|
@ -267,11 +262,9 @@ private class NFTAssetInfoProvider : CollectionPreviewParameterProvider<NFTAsset
|
|||
NFTAssetUM.TopInfo.Content(
|
||||
title = resourceReference(R.string.nft_details_last_sale_price),
|
||||
salePrice = NFTAssetUM.SalePrice.Content(
|
||||
value = BigDecimal("18.75"),
|
||||
symbol = "ETH",
|
||||
decimals = 18,
|
||||
rate = BigDecimal("1"),
|
||||
appCurrency = AppCurrency.Default,
|
||||
cryptoPrice = stringReference("ETH 18.75"),
|
||||
fiatPrice = stringReference("$ 1"),
|
||||
isFlickering = true,
|
||||
),
|
||||
description = null,
|
||||
rarity = NFTAssetUM.Rarity.Content(
|
||||
|
|
@ -285,11 +278,9 @@ private class NFTAssetInfoProvider : CollectionPreviewParameterProvider<NFTAsset
|
|||
NFTAssetUM.TopInfo.Content(
|
||||
title = resourceReference(R.string.nft_details_last_sale_price),
|
||||
salePrice = NFTAssetUM.SalePrice.Content(
|
||||
value = BigDecimal("18.75"),
|
||||
symbol = "ETH",
|
||||
decimals = 18,
|
||||
rate = BigDecimal("1"),
|
||||
appCurrency = AppCurrency.Default,
|
||||
cryptoPrice = stringReference("ETH 18.75"),
|
||||
fiatPrice = stringReference("$ 1"),
|
||||
isFlickering = true,
|
||||
),
|
||||
description = "Base edition by Piux. An illustration of Crypto Robot #7804".repeat(3),
|
||||
rarity = NFTAssetUM.Rarity.Empty,
|
||||
|
|
@ -297,11 +288,9 @@ private class NFTAssetInfoProvider : CollectionPreviewParameterProvider<NFTAsset
|
|||
NFTAssetUM.TopInfo.Content(
|
||||
title = resourceReference(R.string.nft_details_last_sale_price),
|
||||
salePrice = NFTAssetUM.SalePrice.Content(
|
||||
value = BigDecimal("18.75"),
|
||||
symbol = "ETH",
|
||||
decimals = 18,
|
||||
rate = BigDecimal("1"),
|
||||
appCurrency = AppCurrency.Default,
|
||||
cryptoPrice = stringReference("ETH 18.75"),
|
||||
fiatPrice = stringReference("$ 1"),
|
||||
isFlickering = true,
|
||||
),
|
||||
description = null,
|
||||
rarity = NFTAssetUM.Rarity.Empty,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue