From 8a840fe5f0b2cc7d30ad0ae8801b9a463a4a78bb Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 19 Dec 2023 20:24:55 +0200 Subject: [PATCH] Updated on 2026-08-14 --- core/res/src/main/res/values-ru/strings.xml | 1 + core/res/src/main/res/values/strings.xml | 1 + .../swap/models/states/FeeItemState.kt | 1 + .../feature/swap/ui/ChooseFeeBottomSheet.kt | 2 ++ .../com/tangem/feature/swap/ui/FeeItem.kt | 30 +++++++++++++++++-- .../tangem/feature/swap/ui/StateBuilder.kt | 11 +++++-- .../feature/swap/ui/SwapScreenContent.kt | 3 +- 7 files changed, 44 insertions(+), 5 deletions(-) diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index 744452a5fa..42f9f8b591 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -194,6 +194,7 @@ Мои токены У вас нет добавленных токенов. Добавьте токены для обмена Недоступен для обмена с %s + Кроме того, в курс обмена включена комиссия сети за отправку обмененных средств на ваш адрес Статус Провайдеры проводят транзакции, обеспечивая плавный и эффективный обмен токенами Выберите провайдера diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index 55f40ad98b..1150c0349b 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -193,6 +193,7 @@ My tokens You haven\'t added any tokens yet. Add tokens via Market to swap Cannot be swapped for %s + Additionally, the network fee for sending the exchanged funds back to your address is included in the rate Status Providers facilitate transactions, ensuring smooth and efficient token swaps Choose provider diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/states/FeeItemState.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/states/FeeItemState.kt index e01a8b8058..6ca10e195f 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/states/FeeItemState.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/states/FeeItemState.kt @@ -11,6 +11,7 @@ sealed class FeeItemState { val amountCrypto: String, val symbolCrypto: String, val amountFiatFormatted: String, + val explanation: TextReference?, val isClickable: Boolean, val onClick: () -> Unit, ) : FeeItemState() diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseFeeBottomSheet.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseFeeBottomSheet.kt index d0f47a62a2..3c3de0d27f 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseFeeBottomSheet.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ChooseFeeBottomSheet.kt @@ -109,6 +109,7 @@ private fun ChooseFeeBottomSheetContent_Preview() { amountCrypto = "1000", symbolCrypto = "MATIC", amountFiatFormatted = "(10$)", + explanation = null, isClickable = false, onClick = {}, ), @@ -118,6 +119,7 @@ private fun ChooseFeeBottomSheetContent_Preview() { amountCrypto = "2000", symbolCrypto = "MATIC", amountFiatFormatted = "(10$)", + explanation = null, isClickable = false, onClick = {}, ), diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/FeeItem.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/FeeItem.kt index f379ae3511..f5385bf456 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/FeeItem.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/FeeItem.kt @@ -3,6 +3,8 @@ package com.tangem.feature.swap.ui import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* +import androidx.compose.material.Text +import androidx.compose.material3.Divider import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -24,12 +26,13 @@ fun FeeItemBlock(state: FeeItemState) { @Composable fun FeeItem(state: FeeItemState.Content) { - Box( + Column( modifier = Modifier .background( color = TangemTheme.colors.background.action, shape = TangemTheme.shapes.roundedCornersXMedium, ) + .padding(start = TangemTheme.dimens.spacing12) .clip(shape = TangemTheme.shapes.roundedCornersXMedium) .clickable( onClick = state.onClick, @@ -40,13 +43,32 @@ fun FeeItem(state: FeeItemState.Content) { val description = "${state.amountCrypto} ${state.symbolCrypto} (${state.amountFiatFormatted})" SimpleActionRow( modifier = Modifier.padding( - start = TangemTheme.dimens.spacing12, top = TangemTheme.dimens.spacing12, ), title = state.title.resolveReference(), description = description, isClickable = state.isClickable, ) + state.explanation?.let { + Divider( + color = TangemTheme.colors.stroke.primary, + thickness = TangemTheme.dimens.size0_5, + modifier = Modifier.padding( + top = TangemTheme.dimens.spacing10, + bottom = TangemTheme.dimens.spacing10, + end = TangemTheme.dimens.spacing2, + ), + ) + Text( + text = it.resolveReference(), + style = TangemTheme.typography.caption2, + color = TangemTheme.colors.text.tertiary, + modifier = Modifier.padding( + bottom = TangemTheme.dimens.spacing10, + end = TangemTheme.dimens.spacing16, + ), + ) + } } } @@ -59,6 +81,10 @@ private fun FeeItemPreview() { amountCrypto = "1000", symbolCrypto = "MATIC", amountFiatFormatted = "(1000$)", + explanation = stringReference( + "Additionally, the network fee for sending the exchanged funds back to your address is " + + "included in the rate", + ), isClickable = false, onClick = {}, ) diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt index c74bd436f7..db0ab167ab 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt @@ -215,7 +215,7 @@ internal class StateBuilder( if (uiStateHolder.sendCardData !is SwapCardState.SwapCardData) return uiStateHolder if (uiStateHolder.receiveCardData !is SwapCardState.SwapCardData) return uiStateHolder val warnings = getWarningsForSuccessState(quoteModel, fromToken) - val feeState = createFeeState(quoteModel.txFee, selectedFeeType) + val feeState = createFeeState(quoteModel.txFee, selectedFeeType, swapProvider) val fromCurrencyStatus = quoteModel.fromTokenInfo.cryptoCurrencyStatus val toCurrencyStatus = quoteModel.toTokenInfo.cryptoCurrencyStatus return uiStateHolder.copy( @@ -666,7 +666,7 @@ internal class StateBuilder( ) } - private fun createFeeState(txFeeState: TxFeeState, feeType: FeeType): FeeItemState { + private fun createFeeState(txFeeState: TxFeeState, feeType: FeeType, swapProvider: SwapProvider): FeeItemState { val isClickable: Boolean val fee = when (txFeeState) { TxFeeState.Empty -> return FeeItemState.Empty @@ -692,6 +692,11 @@ internal class StateBuilder( title = resourceReference(R.string.common_fee_label), amountCrypto = fee.feeCryptoFormatted, symbolCrypto = fee.cryptoSymbol, + explanation = if (swapProvider.type == ExchangeProviderType.CEX) { + resourceReference(R.string.express_cex_fee_explanation) + } else { + null + }, amountFiatFormatted = fee.feeFiatFormatted, isClickable = isClickable, onClick = actions.onClickFee, @@ -1002,6 +1007,7 @@ internal class StateBuilder( amountCrypto = this.normalFee.feeCryptoFormatted, symbolCrypto = this.normalFee.cryptoSymbol, amountFiatFormatted = this.normalFee.feeFiatFormatted, + explanation = null, isClickable = true, onClick = {}, ), @@ -1011,6 +1017,7 @@ internal class StateBuilder( amountCrypto = this.priorityFee.feeCryptoFormatted, symbolCrypto = this.priorityFee.cryptoSymbol, amountFiatFormatted = this.priorityFee.feeFiatFormatted, + explanation = null, isClickable = true, onClick = {}, ), diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapScreenContent.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapScreenContent.kt index 54a29db438..1e0b3f5944 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapScreenContent.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapScreenContent.kt @@ -467,13 +467,14 @@ private val state = SwapStateHolder( amountCrypto = "100", symbolCrypto = "1000", amountFiatFormatted = "(100)", + explanation = null, isClickable = true, onClick = {}, ), warnings = listOf( SwapWarning.PermissionNeeded( notificationConfig = NotificationConfig( - title = stringReference("Give Premission"), + title = stringReference("Give Permission"), subtitle = stringReference("To continue swapping you need to give permission to Tangem"), iconResId = R.drawable.ic_locked_24, ),