From 8a81175461a419a1c33db845f9861fed3398f2cc Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 3 Apr 2025 03:02:58 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../collections/model/NFTCollectionsModel.kt | 8 +++- .../features/nft/details/entity/NFTAssetUM.kt | 40 +++++++++++++++++++ .../nft/details/entity/NFTDetailsUM.kt | 8 ++++ .../nft/details/model/NFTDetailsModel.kt | 36 ++++++++++++++++- 4 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/entity/NFTAssetUM.kt diff --git a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/collections/model/NFTCollectionsModel.kt b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/collections/model/NFTCollectionsModel.kt index aa8431196e..21618350db 100644 --- a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/collections/model/NFTCollectionsModel.kt +++ b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/collections/model/NFTCollectionsModel.kt @@ -115,9 +115,13 @@ internal class NFTCollectionsModel @Inject constructor( // TODO refresh all } - @Suppress("UnusedPrivateMember") private fun onAssetClick(asset: NFTAsset) { - // TODO move to details + router.push( + AppRoute.NFTDetails( + userWalletId = params.userWalletId, + nftAsset = asset, + ), + ) } private fun onReceiveClick() { diff --git a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/entity/NFTAssetUM.kt b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/entity/NFTAssetUM.kt new file mode 100644 index 0000000000..e5bea7ed65 --- /dev/null +++ b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/entity/NFTAssetUM.kt @@ -0,0 +1,40 @@ +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 kotlinx.collections.immutable.ImmutableList + +data class NFTAssetUM( + val name: String, + val salePrice: SalePrice, + val description: String?, + val rarity: Rarity?, + val media: Media?, + val traits: ImmutableList, + val baseInfoItems: ImmutableList, +) { + data class Media( + val mimetype: String?, + val url: String, + ) + + data class Rarity( + val rank: String, + val label: String, + ) + + data class BlockItem( + val title: TextReference, + val titleTextEllipsis: TextEllipsis = TextEllipsis.End, + val value: String, + val valueTextEllipsis: TextEllipsis = TextEllipsis.End, + ) + + @Immutable + sealed class SalePrice { + data object Loading : SalePrice() + data object Empty : SalePrice() + data class Content(val value: String, val fiatValue: String) : SalePrice() + } +} \ No newline at end of file diff --git a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/entity/NFTDetailsUM.kt b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/entity/NFTDetailsUM.kt index d024abdcff..55df42f2df 100644 --- a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/entity/NFTDetailsUM.kt +++ b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/entity/NFTDetailsUM.kt @@ -1,5 +1,13 @@ package com.tangem.features.nft.details.entity +import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig + internal data class NFTDetailsUM( + val nftAsset: NFTAssetUM, val onBackClick: () -> Unit, + val onReadMoreClick: () -> Unit, + val onSeeAllClick: () -> Unit, + val onExploreClick: () -> Unit, + val onSendClick: () -> Unit, + val bottomSheetConfig: TangemBottomSheetConfig?, ) \ No newline at end of file diff --git a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/model/NFTDetailsModel.kt b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/model/NFTDetailsModel.kt index 5c7e9d20e4..19448754bf 100644 --- a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/model/NFTDetailsModel.kt +++ b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/details/model/NFTDetailsModel.kt @@ -5,8 +5,10 @@ import com.tangem.core.decompose.model.Model import com.tangem.core.decompose.model.ParamsContainer import com.tangem.core.decompose.navigation.Router import com.tangem.features.nft.component.NFTDetailsComponent +import com.tangem.features.nft.details.entity.NFTAssetUM import com.tangem.features.nft.details.entity.NFTDetailsUM import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.flow.* import javax.inject.Inject @@ -17,16 +19,46 @@ internal class NFTDetailsModel @Inject constructor( paramsContainer: ParamsContainer, ) : Model() { + @Suppress("UnusedPrivateMember") + private val params: NFTDetailsComponent.Params = paramsContainer.require() + val state: StateFlow get() = _state private val _state = MutableStateFlow( value = NFTDetailsUM( + nftAsset = NFTAssetUM( + name = "", + salePrice = NFTAssetUM.SalePrice.Empty, + description = null, + rarity = null, + media = null, + traits = persistentListOf(), + baseInfoItems = persistentListOf(), + ), onBackClick = ::navigateBack, + onReadMoreClick = ::onReadMoreClick, + onSeeAllClick = ::onSeeAllClick, + onExploreClick = ::onExploreClick, + onSendClick = ::onSendClick, + bottomSheetConfig = null, ), ) - @Suppress("UnusedPrivateMember") - private val params: NFTDetailsComponent.Params = paramsContainer.require() + private fun onReadMoreClick() { + // TODO implement + } + + private fun onSeeAllClick() { + // TODO implement + } + + private fun onExploreClick() { + // TODO implement + } + + private fun onSendClick() { + // TODO implement + } private fun navigateBack() { router.pop()