Updated on 2026-08-14

This commit is contained in:
Tangem 2025-06-19 16:37:57 +05:00
parent 664305703e
commit 3b6629f7f4
7 changed files with 71 additions and 15 deletions

View file

@ -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 = {},

View file

@ -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