Updated on 2026-08-14
This commit is contained in:
parent
664305703e
commit
3b6629f7f4
7 changed files with 71 additions and 15 deletions
|
|
@ -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<NotificationConfig>,
|
||||
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 = {},
|
||||
|
|
|
|||
|
|
@ -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<AddressModel>,
|
||||
val showMemoDisclaimer: Boolean,
|
||||
val notifications: ImmutableList<NotificationConfig>,
|
||||
val onCopyClick: (String) -> Unit,
|
||||
val onShareClick: (String) -> Unit,
|
||||
) : TangemBottomSheetConfigContent {
|
||||
|
|
@ -25,6 +29,7 @@ data class TokenReceiveBottomSheetConfig(
|
|||
network: Network,
|
||||
networkAddress: NetworkAddress,
|
||||
showMemoDisclaimer: Boolean,
|
||||
customNotifications: ImmutableList<NotificationConfig> = 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
|
||||
|
|
|
|||
|
|
@ -572,6 +572,8 @@
|
|||
<string name="nft_receive_unavailable_asset_warning_message">You haven\'t added this network yet. To receive NFTs, add it to your portfolio.</string>
|
||||
<string name="nft_receive_unavailable_asset_warning_title">Network not added</string>
|
||||
<string name="nft_receive_unavailable_section_title">Not Added</string>
|
||||
<string name="nft_receive_unsupported_types">Unsupported NFT types</string>
|
||||
<string name="nft_receive_unsupported_types_description">cNFTs and pNFTs are not supported yet. Please don’t send them to your wallet.</string>
|
||||
<string name="nft_send">Send NFT</string>
|
||||
<string name="nft_traits_title">Traits</string>
|
||||
<string name="nft_untitled_collection">Untitled collection</string>
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue