diff --git a/core/res/src/main/res/values-de/strings.xml b/core/res/src/main/res/values-de/strings.xml index 12d2744c43..8b478ee2f8 100644 --- a/core/res/src/main/res/values-de/strings.xml +++ b/core/res/src/main/res/values-de/strings.xml @@ -195,6 +195,7 @@ Der Server ist nicht verfügbar. Bitte versuche es später erneut. Teilen Link teilen + Mehr anzeigen Signieren Signieren und senden Staken @@ -450,7 +451,6 @@ Top-Verlierer Beliebt Staking ist der einfachste Weg, um Belohnungen für Deine Kryptowährung zu erhalten. %s - Mehr anzeigen Verdiene bis zu %s APY Über %s diff --git a/core/res/src/main/res/values-ja/strings.xml b/core/res/src/main/res/values-ja/strings.xml index 7979f3a2f3..26dd14488e 100644 --- a/core/res/src/main/res/values-ja/strings.xml +++ b/core/res/src/main/res/values-ja/strings.xml @@ -192,6 +192,8 @@ サーバーが利用できません。しばらくしてからもう一度お試しください。 共有 リンクを共有 + 詳細を非表示 + もっと見る 署名 署名して送信 ステーキング @@ -447,7 +449,6 @@ 下落率上位 トレンド ステーキングは暗号資産で報酬を受け取る最も簡単な方法です。 %s - もっと見る 最大%s APYを獲得 %sについて @@ -552,6 +553,7 @@ 未追加 NFTを送信する 特徴 + 無題のコレクション %1$dコレクションの%2$dNFT ここをタップして最初のNFTを受け取ります NFTコレクション @@ -1265,6 +1267,8 @@ すべての接続を解除する すべてのdAppsの接続解除に関するテキスト すべてのdAppを接続解除する + ウォレットの変更の予測 + 悪意のある取引 このウォレットのプロフィールに%sネットワークを追加する ウォレットに必要なネットワークはありません 新しい接続 diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index 8689c2d7ff..4d8d60b701 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -199,6 +199,7 @@ Сервер недоступен, повторите попытку позднее Поделиться Поделиться ссылкой + Показать больше Подписать Подписать и отправить Застейкать @@ -454,7 +455,6 @@ Лидеры падения В тренде Стейкинг — простой способ получать доход с вашей криптовалюты. %s - Показать больше Получайте до %s APY О %s diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index aefa4e7626..51d8a3384e 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -195,6 +195,8 @@ The server is not available, please try again later Share Share Link + Show less + Show more Sign Sign and send Stake @@ -452,7 +454,6 @@ Top Losers Trending Staking is the easiest way to receive rewards on your crypto. %s - Show more Earn up to %s APY About %s @@ -560,6 +561,7 @@ Not Added Send NFT Traits + Untitled collection %1$d NFTs in %2$d collection Tap here to receive first NFT NFT collections @@ -1204,6 +1206,8 @@ Get now with 10% off Access 13,000+ cryptocurrencies. Buy, sell, swap, and stake with a single tap.\nLink up to three cards for a backup. Discover Tangem Wallet + Stay notified on wallet incoming transactions and Tangem updates. + Push Notifications Wallet settings Tangem Use %s or scan a card/ring to unlock access to your wallet @@ -1326,6 +1330,8 @@ Disconnect all Text about discnected all dApps Disconect All dApps + Estimated wallet changes + Malicious transaction Add the %s network to your profile for this wallet The wallet has no required networks New connection diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/divider/DividerWithPadding.kt b/core/ui/src/main/java/com/tangem/core/ui/components/divider/DividerWithPadding.kt new file mode 100644 index 0000000000..8b1181ef25 --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/components/divider/DividerWithPadding.kt @@ -0,0 +1,23 @@ +package com.tangem.core.ui.components.divider + +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.HorizontalDivider +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import com.tangem.core.ui.res.TangemTheme + +@Composable +fun DividerWithPadding(start: Dp = 0.dp, end: Dp = 0.dp, top: Dp = 0.dp, bottom: Dp = 0.dp) { + HorizontalDivider( + modifier = Modifier.padding( + start = start, + end = end, + top = top, + bottom = bottom, + ), + thickness = TangemTheme.dimens.size1, + color = TangemTheme.colors.stroke.primary, + ) +} \ No newline at end of file diff --git a/core/ui/src/main/res/drawable/ic_nft_placeholder_20.xml b/core/ui/src/main/res/drawable/ic_nft_placeholder_20.xml new file mode 100644 index 0000000000..66b350b330 --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_nft_placeholder_20.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/core/ui/src/main/res/drawable/ic_recieve_new_24.xml b/core/ui/src/main/res/drawable/ic_recieve_new_24.xml new file mode 100644 index 0000000000..f5465cd20c --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_recieve_new_24.xml @@ -0,0 +1,15 @@ + + + + diff --git a/core/ui/src/main/res/drawable/ic_send_new_24.xml b/core/ui/src/main/res/drawable/ic_send_new_24.xml new file mode 100644 index 0000000000..e938cd57cd --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_send_new_24.xml @@ -0,0 +1,15 @@ + + + + diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/blockaid/WcEstimatedWalletChangesUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/blockaid/WcEstimatedWalletChangesUM.kt new file mode 100644 index 0000000000..59551a7bd9 --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/blockaid/WcEstimatedWalletChangesUM.kt @@ -0,0 +1,16 @@ +package com.tangem.features.walletconnect.transaction.entity.blockaid + +import androidx.annotation.DrawableRes +import com.tangem.core.ui.extensions.TextReference +import kotlinx.collections.immutable.ImmutableList + +internal data class WcEstimatedWalletChangesUM( + val items: ImmutableList, +) + +internal data class WcEstimatedWalletChangeUM( + @DrawableRes val iconRes: Int, + val title: TextReference, + val description: String, + val tokenIconUrl: String, +) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcApproveTransactionModalBottomSheet.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcApproveTransactionModalBottomSheet.kt index a64be58984..3df8a72cf5 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcApproveTransactionModalBottomSheet.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcApproveTransactionModalBottomSheet.kt @@ -6,7 +6,6 @@ import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -14,11 +13,11 @@ import androidx.compose.ui.tooling.preview.Devices 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 androidx.compose.ui.unit.dp import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheet import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheetTitle +import com.tangem.core.ui.components.divider.DividerWithPadding import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview @@ -112,18 +111,6 @@ private fun WcApproveTransactionItems(state: WcApproveTransactionItemUM) { } } -@Composable -internal fun DividerWithPadding(start: Dp, end: Dp) { - HorizontalDivider( - modifier = Modifier.padding( - start = start, - end = end, - ), - thickness = TangemTheme.dimens.size1, - color = TangemTheme.colors.stroke.primary, - ) -} - @Composable @Preview(showBackground = true, device = Devices.PIXEL_7_PRO) @Preview(showBackground = true, device = Devices.PIXEL_7_PRO, uiMode = Configuration.UI_MODE_NIGHT_YES) diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/blockaid/WcEstimatedWalletChangeRow.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/blockaid/WcEstimatedWalletChangeRow.kt new file mode 100644 index 0000000000..e4dcdea2ea --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/blockaid/WcEstimatedWalletChangeRow.kt @@ -0,0 +1,78 @@ +package com.tangem.features.walletconnect.transaction.ui.blockaid + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import com.tangem.core.ui.extensions.resolveReference +import com.tangem.core.ui.res.TangemTheme +import com.tangem.features.walletconnect.impl.R +import com.tangem.features.walletconnect.transaction.entity.blockaid.WcEstimatedWalletChangeUM + +@Composable +internal fun WcEstimatedWalletChangeRow(item: WcEstimatedWalletChangeUM, modifier: Modifier = Modifier) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = modifier + .fillMaxWidth(), + ) { + Image( + painter = painterResource(id = item.iconRes), + contentDescription = null, + modifier = Modifier.size(24.dp), + ) + + Spacer(modifier = Modifier.width(12.dp)) + + Box( + modifier = Modifier.weight(1f), + contentAlignment = Alignment.CenterStart, + ) { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = item.title.resolveReference(), + style = TangemTheme.typography.body1, + color = TangemTheme.colors.text.primary1, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + + Spacer(modifier = Modifier.width(8.dp)) + + Text( + text = item.description, + style = TangemTheme.typography.body1, + color = TangemTheme.colors.text.tertiary, + textAlign = TextAlign.End, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + modifier = Modifier.weight(1f), + ) + } + } + + Spacer(modifier = Modifier.width(12.dp)) + + AsyncImage( + model = item.tokenIconUrl, + contentDescription = null, + modifier = Modifier + .size(24.dp) + .clip(RoundedCornerShape(4.dp)), + placeholder = painterResource(R.drawable.ic_nft_placeholder_20), + error = painterResource(R.drawable.ic_nft_placeholder_20), + ) + } +} \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/blockaid/WcEstimatedWalletChangesItem.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/blockaid/WcEstimatedWalletChangesItem.kt new file mode 100644 index 0000000000..b0b37f31ac --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/blockaid/WcEstimatedWalletChangesItem.kt @@ -0,0 +1,165 @@ +package com.tangem.features.walletconnect.transaction.ui.blockaid + +import android.content.res.Configuration +import androidx.compose.animation.animateContentSize +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Devices +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 com.tangem.core.ui.extensions.resourceReference +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.graphics.vector.rememberVectorPainter +import androidx.compose.ui.res.vectorResource +import com.tangem.core.ui.components.divider.DividerWithPadding +import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview +import com.tangem.features.walletconnect.impl.R +import com.tangem.features.walletconnect.transaction.entity.blockaid.WcEstimatedWalletChangeUM +import com.tangem.features.walletconnect.transaction.entity.blockaid.WcEstimatedWalletChangesUM +import com.tangem.features.walletconnect.transaction.ui.common.WcSmallTitleItem +import kotlinx.collections.immutable.persistentListOf +import kotlinx.collections.immutable.toPersistentList + +private const val MAX_CHANGES_SIZE = 4 + +@Composable +internal fun WcEstimatedWalletChangesItem(item: WcEstimatedWalletChangesUM, modifier: Modifier = Modifier) { + var isExpanded by remember { mutableStateOf(false) } + + Column( + modifier = modifier + .clip(RoundedCornerShape(14.dp)) + .background(color = TangemTheme.colors.background.action) + .fillMaxWidth() + .animateContentSize(), + ) { + WcSmallTitleItem( + textRex = R.string.wc_estimated_wallet_changes, + modifier = Modifier + .padding(bottom = 16.dp), + ) + + val itemsToDisplay = if (isExpanded) item.items else item.items.take(MAX_CHANGES_SIZE) + + itemsToDisplay.forEachIndexed { idx, row -> + key(row.hashCode()) { + WcEstimatedWalletChangeRow( + item = row, + modifier = Modifier.padding(horizontal = 12.dp), + ) + if (idx == item.items.lastIndex) { + Spacer(modifier = Modifier.height(12.dp)) + } else { + DividerWithPadding(start = 48.dp, end = 12.dp, top = 8.dp, bottom = 8.dp) + } + } + } + + if (item.items.size > MAX_CHANGES_SIZE) { + Row( + modifier = Modifier + .clickable { isExpanded = !isExpanded } + .padding(bottom = 12.dp, start = 12.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = stringResource(if (isExpanded) R.string.common_show_less else R.string.common_show_more), + style = TangemTheme.typography.body1, + color = TangemTheme.colors.text.tertiary, + ) + Icon( + painter = rememberVectorPainter( + image = ImageVector.vectorResource(id = R.drawable.ic_chevron_24), + ), + tint = TangemTheme.colors.icon.informative, + modifier = Modifier + .size(20.dp) + .padding(start = 2.dp), + contentDescription = null, + ) + } + } + } +} + +@Composable +@Preview(showBackground = true, device = Devices.PIXEL_7_PRO) +@Preview(showBackground = true, device = Devices.PIXEL_7_PRO, uiMode = Configuration.UI_MODE_NIGHT_YES) +private fun EstimatedWalletChangesPreviewTwoItems( + @PreviewParameter(EstimatedWalletChangesPreviewProviderTwoItems::class) item: WcEstimatedWalletChangesUM, +) { + TangemThemePreview { + Box( + modifier = Modifier + .background(TangemTheme.colors.background.tertiary), + ) { + WcEstimatedWalletChangesItem(item = item) + } + } +} + +@Composable +@Preview(showBackground = true, device = Devices.PIXEL_7_PRO) +@Preview(showBackground = true, device = Devices.PIXEL_7_PRO, uiMode = Configuration.UI_MODE_NIGHT_YES) +private fun EstimatedWalletChangesPreviewMoreThanFour( + @PreviewParameter(EstimatedWalletChangesPreviewProviderManyItems::class) item: WcEstimatedWalletChangesUM, +) { + TangemThemePreview { + Box( + modifier = Modifier + .background(TangemTheme.colors.background.tertiary), + ) { + WcEstimatedWalletChangesItem(item = item) + } + } +} + +private class EstimatedWalletChangesPreviewProviderTwoItems : + PreviewParameterProvider { + override val values = sequenceOf( + WcEstimatedWalletChangesUM( + items = persistentListOf( + WcEstimatedWalletChangeUM( + iconRes = R.drawable.ic_send_new_24, + title = resourceReference(R.string.common_send), + description = "- 42 USDT", + tokenIconUrl = "https://tangem.com", + ), + WcEstimatedWalletChangeUM( + iconRes = R.drawable.ic_recieve_new_24, + title = resourceReference(R.string.common_receive), + description = "+ 1,131.46 MATIC", + tokenIconUrl = "https://tangem.com", + ), + ), + ), + ) +} + +private class EstimatedWalletChangesPreviewProviderManyItems : + PreviewParameterProvider { + override val values = sequenceOf( + WcEstimatedWalletChangesUM( + items = (1..6).map { + WcEstimatedWalletChangeUM( + iconRes = R.drawable.ic_send_new_24, + title = resourceReference(R.string.common_send), + description = "Nethers #1111", + tokenIconUrl = "https://tangem.com", + ) + }.toPersistentList(), + ), + ) +} \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/sign/WcSignTransactionModalBottomSheetContent.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/sign/WcSignTransactionModalBottomSheetContent.kt index 4596bcc2b6..395b577374 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/sign/WcSignTransactionModalBottomSheetContent.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/sign/WcSignTransactionModalBottomSheetContent.kt @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -16,11 +15,11 @@ import androidx.compose.ui.tooling.preview.Devices 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 androidx.compose.ui.unit.dp import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheet import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheetTitle +import com.tangem.core.ui.components.divider.DividerWithPadding import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview @@ -109,18 +108,6 @@ private fun WcSignTransactionItems(state: WcSignTransactionItemUM) { } } -@Composable -internal fun DividerWithPadding(start: Dp, end: Dp) { - HorizontalDivider( - modifier = Modifier.padding( - start = start, - end = end, - ), - thickness = 1.dp, - color = TangemTheme.colors.stroke.primary, - ) -} - @Composable @Preview(showBackground = true, device = Devices.PIXEL_7_PRO) @Preview(showBackground = true, device = Devices.PIXEL_7_PRO, uiMode = Configuration.UI_MODE_NIGHT_YES)