diff --git a/common/ui/src/main/java/com/tangem/common/ui/bottomsheet/receive/TokenReceiveBottomSheet.kt b/common/ui/src/main/java/com/tangem/common/ui/bottomsheet/receive/TokenReceiveBottomSheet.kt index f6024e6f93..35cbf7f906 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/bottomsheet/receive/TokenReceiveBottomSheet.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/bottomsheet/receive/TokenReceiveBottomSheet.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.unit.dp +import androidx.compose.ui.util.fastForEach import com.tangem.core.res.getStringSafe import com.tangem.core.ui.R import com.tangem.core.ui.components.SecondaryButtonIconStart @@ -39,6 +40,7 @@ import com.tangem.core.ui.components.snackbar.CopiedTextSnackbarHost import com.tangem.core.ui.extensions.* import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview +import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.launch @@ -67,9 +69,8 @@ private fun TokenReceiveBottomSheetContent(content: TokenReceiveBottomSheetConfi QrCodeContent(content = content, onAddressChange = { selectedAddress = it }) Info( - symbol = content.asset.displaySymbol, - network = content.network, showMemoDisclaimer = content.showMemoDisclaimer, + notifications = content.notifications, ) Buttons( @@ -82,7 +83,11 @@ private fun TokenReceiveBottomSheetContent(content: TokenReceiveBottomSheetConfi } @Composable -private fun Info(symbol: TextReference, network: String, showMemoDisclaimer: Boolean, modifier: Modifier = Modifier) { +private fun Info( + showMemoDisclaimer: Boolean, + notifications: ImmutableList, + modifier: Modifier = Modifier, +) { Column( modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally, @@ -100,17 +105,11 @@ private fun Info(symbol: TextReference, network: String, showMemoDisclaimer: Boo ) } - Notification( - config = NotificationConfig( - title = resourceReference( - R.string.receive_bottom_sheet_warning_title, - wrappedList(symbol.resolveReference(), network), - ), - subtitle = resourceReference(R.string.receive_bottom_sheet_warning_message_description), - iconResId = R.drawable.ic_alert_circle_24, - ), - iconTint = TangemTheme.colors.icon.accent, - ) + notifications.fastForEach { + key(it.hashCode()) { + Notification(config = it) + } + } } } @@ -294,6 +293,13 @@ private class TokenReceiveBottomSheetConfigPreviewProvider : PreviewParameterPro symbol = "XLM", ), network = "Ethereum", + notifications = persistentListOf( + NotificationConfig( + title = stringReference("Send only XLM on the Ethereum network"), + subtitle = resourceReference(R.string.receive_bottom_sheet_warning_message_description), + iconResId = R.drawable.ic_alert_circle_24, + ), + ), addresses = persistentListOf(address), showMemoDisclaimer = false, onCopyClick = {}, diff --git a/common/ui/src/main/java/com/tangem/common/ui/bottomsheet/receive/TokenReceiveBottomSheetConfig.kt b/common/ui/src/main/java/com/tangem/common/ui/bottomsheet/receive/TokenReceiveBottomSheetConfig.kt index 1fad13b9a0..5d29be17ec 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/bottomsheet/receive/TokenReceiveBottomSheetConfig.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/bottomsheet/receive/TokenReceiveBottomSheetConfig.kt @@ -3,12 +3,15 @@ package com.tangem.common.ui.bottomsheet.receive import androidx.compose.runtime.Immutable import com.tangem.core.ui.R import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent +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.wrappedList import com.tangem.domain.models.network.Network import com.tangem.domain.models.network.NetworkAddress import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList data class TokenReceiveBottomSheetConfig( @@ -16,6 +19,7 @@ data class TokenReceiveBottomSheetConfig( val network: String, val addresses: ImmutableList, val showMemoDisclaimer: Boolean, + val notifications: ImmutableList, val onCopyClick: (String) -> Unit, val onShareClick: (String) -> Unit, ) : TangemBottomSheetConfigContent { @@ -25,6 +29,7 @@ data class TokenReceiveBottomSheetConfig( network: Network, networkAddress: NetworkAddress, showMemoDisclaimer: Boolean, + customNotifications: ImmutableList = persistentListOf(), onCopyClick: (String) -> Unit, onShareClick: (String) -> Unit, ) : this( @@ -34,10 +39,24 @@ data class TokenReceiveBottomSheetConfig( .mapToAddressModels(asset, network) .toImmutableList(), showMemoDisclaimer = showMemoDisclaimer, + notifications = persistentListOf(defaultAssetNotificationConfig(asset, network)).addAll(0, customNotifications), onCopyClick = onCopyClick, onShareClick = onShareClick, ) + companion object { + private fun defaultAssetNotificationConfig(asset: Asset, network: Network): NotificationConfig = + NotificationConfig( + title = resourceReference( + R.string.receive_bottom_sheet_warning_title, + wrappedList(asset.displaySymbol, network.name), + ), + subtitle = resourceReference(R.string.receive_bottom_sheet_warning_message_description), + iconResId = R.drawable.ic_alert_circle_24, + iconTint = NotificationConfig.IconTint.Accent, + ) + } + @Immutable sealed class Asset { abstract val displaySymbol: TextReference diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index 27c5144b7f..11d55684c1 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -572,6 +572,8 @@ You haven\'t added this network yet. To receive NFTs, add it to your portfolio. Network not added Not Added + Unsupported NFT types + cNFTs and pNFTs are not supported yet. Please don’t send them to your wallet. Send NFT Traits Untitled collection diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/Notification.kt b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/Notification.kt index eec41bdb9a..10bfdbba1d 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/Notification.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/Notification.kt @@ -57,7 +57,11 @@ fun Notification( titleColor: Color = TangemTheme.colors.text.primary1, subtitleColor: Color = TangemTheme.colors.text.tertiary, containerColor: Color? = null, - iconTint: Color? = null, + iconTint: Color? = when (config.iconTint) { + NotificationConfig.IconTint.Unspecified -> null + NotificationConfig.IconTint.Accent -> TangemTheme.colors.icon.accent + NotificationConfig.IconTint.Attention -> TangemTheme.colors.icon.attention + }, iconSize: Dp = 20.dp, isEnabled: Boolean = true, ) { diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationConfig.kt b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationConfig.kt index ef2b60c55e..4afe96144e 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationConfig.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationConfig.kt @@ -25,6 +25,7 @@ data class NotificationConfig( val onClick: (() -> Unit)? = null, val onCloseClick: (() -> Unit)? = null, val showArrowIcon: Boolean = onClick != null, + val iconTint: IconTint = IconTint.Unspecified, ) { sealed class ButtonsState { @@ -56,4 +57,10 @@ data class NotificationConfig( val onRightClick: () -> Unit, ) : ButtonsState() } + + enum class IconTint { + Unspecified, + Accent, + Attention, + } } \ No newline at end of file diff --git a/features/nft/impl/build.gradle.kts b/features/nft/impl/build.gradle.kts index 7ac4ae8799..83bba9f0b5 100644 --- a/features/nft/impl/build.gradle.kts +++ b/features/nft/impl/build.gradle.kts @@ -41,6 +41,7 @@ dependencies { /** Tangem libraries */ implementation(projects.libs.tangemSdkApi) + implementation(projects.libs.crypto) implementation(tangemDeps.card.core) implementation(tangemDeps.card.android) { exclude(module = "joda-time") diff --git a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/receive/entity/transformer/ShowReceiveBottomSheetTransformer.kt b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/receive/entity/transformer/ShowReceiveBottomSheetTransformer.kt index a267f6156d..65e142aaf6 100644 --- a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/receive/entity/transformer/ShowReceiveBottomSheetTransformer.kt +++ b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/receive/entity/transformer/ShowReceiveBottomSheetTransformer.kt @@ -2,10 +2,15 @@ package com.tangem.features.nft.receive.entity.transformer import com.tangem.common.ui.bottomsheet.receive.TokenReceiveBottomSheetConfig import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig +import com.tangem.core.ui.components.notifications.NotificationConfig import com.tangem.domain.models.network.Network import com.tangem.domain.models.network.NetworkAddress import com.tangem.features.nft.receive.entity.NFTReceiveUM import com.tangem.utils.transformer.Transformer +import com.tangem.core.ui.R +import com.tangem.core.ui.extensions.resourceReference +import com.tangem.lib.crypto.BlockchainUtils +import kotlinx.collections.immutable.toPersistentList internal class ShowReceiveBottomSheetTransformer( private val network: Network, @@ -24,6 +29,18 @@ internal class ShowReceiveBottomSheetTransformer( network = network, networkAddress = networkAddress, showMemoDisclaimer = network.transactionExtrasType != Network.TransactionExtrasType.NONE, + customNotifications = buildList { + if (BlockchainUtils.isSolana(network.rawId)) { + add( + NotificationConfig( + title = resourceReference(R.string.nft_receive_unsupported_types), + subtitle = resourceReference(R.string.nft_receive_unsupported_types_description), + iconResId = R.drawable.ic_alert_circle_24, + iconTint = NotificationConfig.IconTint.Attention, + ), + ) + } + }.toPersistentList(), onCopyClick = onCopyClick, onShareClick = onShareClick, ),