From 3d73befd95a16f2c2bfb955437f6f57561144c69 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 19 Jan 2024 13:26:04 +0100 Subject: [PATCH] Updated on 2026-08-14 --- app/src/main/res/layout/layout_send_fee.xml | 2 +- core/res/src/main/res/values-de/strings.xml | 2 +- core/res/src/main/res/values-fr/strings.xml | 2 +- core/res/src/main/res/values-it/strings.xml | 2 +- core/res/src/main/res/values-ru/strings.xml | 4 +- .../src/main/res/values-zh-rTW/strings.xml | 3 +- core/res/src/main/res/values/strings.xml | 4 +- .../impl/presentation/ui/send/SendContent.kt | 2 +- .../swap/domain/models/ui/SwapState.kt | 1 - .../feature/swap/domain/SwapInteractorImpl.kt | 10 +--- .../feature/swap/models/SwapStateHolder.kt | 10 +--- .../tangem/feature/swap/models/UiActions.kt | 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/ProviderItem.kt | 6 ++ .../tangem/feature/swap/ui/StateBuilder.kt | 57 +++++++++---------- .../swap/ui/SwapPermissionBottomSheet.kt | 2 +- .../feature/swap/ui/SwapScreenContent.kt | 13 +---- .../feature/swap/ui/SwapSuccessScreen.kt | 2 +- .../tangem/feature/swap/ui/TransactionCard.kt | 40 ++++++++++--- .../feature/swap/viewmodels/SwapViewModel.kt | 9 +++ 22 files changed, 94 insertions(+), 111 deletions(-) diff --git a/app/src/main/res/layout/layout_send_fee.xml b/app/src/main/res/layout/layout_send_fee.xml index bba30587f9..66c3b128f1 100644 --- a/app/src/main/res/layout/layout_send_fee.xml +++ b/app/src/main/res/layout/layout_send_fee.xml @@ -12,7 +12,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" - android:text="@string/send_network_fee_title" + android:text="@string/common_network_fee_title" android:textSize="14sp" app:layout_constraintBottom_toBottomOf="@+id/flExpandCollapse" app:layout_constraintStart_toStartOf="parent" diff --git a/core/res/src/main/res/values-de/strings.xml b/core/res/src/main/res/values-de/strings.xml index ddbf073872..aaccaf5396 100644 --- a/core/res/src/main/res/values-de/strings.xml +++ b/core/res/src/main/res/values-de/strings.xml @@ -45,7 +45,7 @@ Normal Priorität Höchstbetrag - Netzgebühr + Netzgebühr Gesamt %1$s und %2$s werden gesendet ≈ %1$s (inkl. Gebühr: %2$s) diff --git a/core/res/src/main/res/values-fr/strings.xml b/core/res/src/main/res/values-fr/strings.xml index 9ac49cb6d8..680543d79c 100644 --- a/core/res/src/main/res/values-fr/strings.xml +++ b/core/res/src/main/res/values-fr/strings.xml @@ -45,7 +45,7 @@ Normal Priorité Somme maximale - Commissions du réseau + Commissions du réseau Total Sera envoyé %1$s et %2$s ≈ %1$s (incl. les commissions : %2$s) diff --git a/core/res/src/main/res/values-it/strings.xml b/core/res/src/main/res/values-it/strings.xml index f673e3bf38..6ff58173b7 100644 --- a/core/res/src/main/res/values-it/strings.xml +++ b/core/res/src/main/res/values-it/strings.xml @@ -45,7 +45,7 @@ Normale Prioritario Importo totale - Costi della rete + Costi della rete Totale Sarà inviato %1$s e %2$s ≈ %1$s (inc. commissione: %2$s) diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index e29baf80c0..3bb9f148e0 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -234,6 +234,7 @@ Недоступно для этой пары Требуется разрешение Условиями использования + Предоставлено Информация ниже не является обязательной. Вы можете стереть её, если хотите. Расскажите, каких функций вам не хватает, и мы постараемся вам помочь. Скажите, пожалуйста, какая у вас карта? @@ -469,7 +470,7 @@ Максимальная сумма Комиссия не превысит Максимальная cумма комиссии - Сетевая комиссия + Сетевая комиссия Сумма отправки будет уменьшена для покрытия выбранного уровня комиссии Покрытие сетевой комиссии Недостаточно средств для перевода, так как сумма комиссии и сумма перевода в совокупности больше имеющегося баланса @@ -529,7 +530,6 @@ Вы отправляете Произошла ошибка. Пожалуйста, попробуйте еще раз. Дать разрешение - Сильные колебания цены! Обмен этой суммы выбранных токенов может вызвать значительные колебания цены и уменьшить получаемую сумму. Недостаточно средств Недостаточно средств для оплаты комиссии на вашем %1$s кошельке для создания транзакции. Сначала пополните свой %2$s кошелек. diff --git a/core/res/src/main/res/values-zh-rTW/strings.xml b/core/res/src/main/res/values-zh-rTW/strings.xml index adb5903417..c7ef19cf31 100644 --- a/core/res/src/main/res/values-zh-rTW/strings.xml +++ b/core/res/src/main/res/values-zh-rTW/strings.xml @@ -297,7 +297,7 @@ 正常 優先 最大值 - 網路費 + 網路費 發送 %s 總計 %1$s 和 %2$s 將被發送 @@ -329,7 +329,6 @@ 錯誤: %s 有錯誤。請再試一遍 賦予權限 - 價格影響高! 在此代幣交換的數量將對價格產生重大影響,並降低您收到的數量 餘額不足 您的 %1$s 錢包中沒有足夠的資金來創建交易。首先為您的 %2$s 錢包充值 diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index 0186ecb9ff..c5ba957fac 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -200,6 +200,7 @@ More providers are coming soon.\nStay tuned! Estimated amount Exchange by %s + Provided by Visit provider’s website to refund your money Operation failed by provider Visit provider’s website for verification @@ -474,7 +475,7 @@ Max fee Maximum fee amount Numbers only for Destination Tag - Network fee + Network fee Sending amount will be reduced to cover the selected fee level Network fee coverage Insufficient funds for the transfer, as the total of the fee and transfer amount exceeds the existing balance @@ -546,7 +547,6 @@ You swap There was an error. Please try again. Give Permission - High price impact! Swapping this amount of selected tokens will cause a significant price impact and reduce your outcome. Insufficient funds Insufficient funds in your %1$s wallet to cover fees. Top up your %2$s wallet first. diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/SendContent.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/SendContent.kt index 8bb21e14d3..b9f84d7264 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/SendContent.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/send/SendContent.kt @@ -178,7 +178,7 @@ private fun FeeBlock(feeState: SendStates.FeeState, isSuccess: Boolean, onClick: decimals = fee.amount.decimals, ) InputRowDefault( - title = TextReference.Res(R.string.send_network_fee_title), + title = TextReference.Res(R.string.common_network_fee_title), text = TextReference.Str(feeValue), modifier = Modifier .clip(TangemTheme.shapes.roundedCornersXMedium) diff --git a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ui/SwapState.kt b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ui/SwapState.kt index db6aa5a595..264f39582b 100644 --- a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ui/SwapState.kt +++ b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ui/SwapState.kt @@ -44,7 +44,6 @@ sealed class PriceImpact { fun getIntPercentValue() = (value * HUNDRED_PERCENTS).toInt() data class Empty(override val value: Float = 0f) : PriceImpact() - data class ValueWithNotify(override val value: Float) : PriceImpact() data class Value(override val value: Float) : PriceImpact() companion object { diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt index 929ea8ae82..f16a1d93f2 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt @@ -834,7 +834,6 @@ internal class SwapInteractorImpl @Inject constructor( toTokenAmount = quoteModel.toTokenAmount, swapData = null, txFeeState = txFee, - exchangeProviderType = exchangeProviderType, ).copy( warnings = manageWarnings(fromToken, amount, txFee), ) @@ -997,7 +996,6 @@ internal class SwapInteractorImpl @Inject constructor( toTokenAmount = swapData.toTokenAmount, swapData = swapData, txFeeState = txFeeState, - exchangeProviderType = ExchangeProviderType.DEX, ) swapState.copy( permissionState = PermissionDataState.Empty, @@ -1037,7 +1035,6 @@ internal class SwapInteractorImpl @Inject constructor( toTokenAmount: SwapAmount, swapData: SwapDataModel?, txFeeState: TxFeeState, - exchangeProviderType: ExchangeProviderType, ): SwapState.QuotesLoadedState { val fromToken = fromTokenStatus.currency val toToken = toTokenStatus.currency @@ -1062,7 +1059,6 @@ internal class SwapInteractorImpl @Inject constructor( fromRate = rates[fromToken.id]?.fiatRate?.toDouble() ?: 0.0, toTokenAmount = toTokenAmount.value, toRate = rates[toToken.id]?.fiatRate?.toDouble() ?: 0.0, - exchangeProviderType = exchangeProviderType, ), networkCurrency = userWalletManager.getNetworkCurrency(networkId), swapDataModel = swapData, @@ -1411,15 +1407,11 @@ internal class SwapInteractorImpl @Inject constructor( fromRate: Double, toTokenAmount: BigDecimal, toRate: Double, - exchangeProviderType: ExchangeProviderType, ): PriceImpact { val fromTokenFiatValue = fromTokenAmount.multiply(fromRate.toBigDecimal()) val toTokenFiatValue = toTokenAmount.multiply(toRate.toBigDecimal()) val value = (BigDecimal.ONE - toTokenFiatValue.divide(fromTokenFiatValue, 2, RoundingMode.HALF_UP)).toFloat() - if (exchangeProviderType == ExchangeProviderType.CEX) { - return PriceImpact.Value(value) - } - return PriceImpact.ValueWithNotify(value) + return PriceImpact.Value(value) } private suspend fun getApproveData( diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/SwapStateHolder.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/SwapStateHolder.kt index 6d9915fa88..bbe757b01b 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/SwapStateHolder.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/SwapStateHolder.kt @@ -83,7 +83,7 @@ sealed interface TransactionCardType { ) : TransactionCardType data class ReadOnly( - val highPriceImpact: String? = null, + val onWarningClick: (() -> Unit)? = null, @StringRes override val headerResId: Int = R.string.swapping_to_title, ) : TransactionCardType } @@ -104,18 +104,12 @@ sealed interface SwapWarning { object InsufficientFunds : SwapWarning data class NoAvailableTokensToSwap(val notificationConfig: NotificationConfig) : SwapWarning data class GenericWarning( - val message: String? = null, + val message: TextReference? = null, val type: GenericWarningType = GenericWarningType.OTHER, val shouldWrapMessage: Boolean = false, val onClick: () -> Unit, ) : SwapWarning // data class RateExpired(val onClick: () -> Unit) : SwapWarning - /** - * High price impact warning - * - * @property priceImpact in format = 10 (means 10%) - */ - data class HighPriceImpact(val priceImpact: Int, val notificationConfig: NotificationConfig) : SwapWarning data class GeneralError(val notificationConfig: NotificationConfig) : SwapWarning data class UnableToCoverFeeWarning(val notificationConfig: NotificationConfig) : SwapWarning data class GeneralWarning(val notificationConfig: NotificationConfig) : SwapWarning diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/UiActions.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/UiActions.kt index 258039517e..52fffa4053 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/UiActions.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/models/UiActions.kt @@ -23,4 +23,5 @@ data class UiActions( val onBuyClick: () -> Unit, val onPolicyClick: (String) -> Unit, val onTosClick: (String) -> Unit, + val onReceiveCardWarningClick: () -> Unit, ) \ No newline at end of file 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 6ca10e195f..e01a8b8058 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,7 +11,6 @@ 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 3c3de0d27f..d0f47a62a2 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,7 +109,6 @@ private fun ChooseFeeBottomSheetContent_Preview() { amountCrypto = "1000", symbolCrypto = "MATIC", amountFiatFormatted = "(10$)", - explanation = null, isClickable = false, onClick = {}, ), @@ -119,7 +118,6 @@ 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 f5385bf456..f379ae3511 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,8 +3,6 @@ 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 @@ -26,13 +24,12 @@ fun FeeItemBlock(state: FeeItemState) { @Composable fun FeeItem(state: FeeItemState.Content) { - Column( + Box( 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, @@ -43,32 +40,13 @@ 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, - ), - ) - } } } @@ -81,10 +59,6 @@ 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/ProviderItem.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ProviderItem.kt index c1a94da8f7..931563da97 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ProviderItem.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/ProviderItem.kt @@ -113,6 +113,12 @@ private fun ProviderContentState( modifier = Modifier.padding(start = TangemTheme.dimens.spacing12), ) { Row { + Text( + text = stringResource(id = R.string.express_by_provider), + style = TangemTheme.typography.caption2, + color = TangemTheme.colors.text.tertiary, + modifier = Modifier.padding(end = TangemTheme.dimens.spacing4), + ) AnimatedContent(targetState = state.name, label = "") { Text( text = it, 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 6572e025e2..d0d611881d 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 @@ -212,7 +212,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, swapProvider) + val feeState = createFeeState(quoteModel.txFee, selectedFeeType) val fromCurrencyStatus = quoteModel.fromTokenInfo.cryptoCurrencyStatus val toCurrencyStatus = quoteModel.toTokenInfo.cryptoCurrencyStatus return uiStateHolder.copy( @@ -231,7 +231,7 @@ internal class StateBuilder( isBalanceHidden = isBalanceHiddenProvider(), ), receiveCardData = SwapCardState.SwapCardData( - type = TransactionCardType.ReadOnly(), + type = TransactionCardType.ReadOnly(actions.onReceiveCardWarningClick), amountTextFieldValue = TextFieldValue(quoteModel.toTokenInfo.tokenAmount.formatToUIRepresentation()), amountEquivalent = getFormattedFiatAmount(quoteModel.toTokenInfo.amountFiat), token = toCurrencyStatus, @@ -332,15 +332,6 @@ internal class StateBuilder( warnings.add(SwapWarning.InsufficientFunds) } - val priceImpact = quoteModel.priceImpact - if (priceImpact is PriceImpact.ValueWithNotify && priceImpact.value > PRICE_IMPACT_THRESHOLD) { - warnings.add( - SwapWarning.HighPriceImpact( - priceImpact = priceImpact.getIntPercentValue(), - notificationConfig = highPriceImpactNotificationConfig(), - ), - ) - } if (quoteModel.permissionState is PermissionDataState.PermissionLoading) { warnings.add( SwapWarning.TransactionInProgressWarning( @@ -735,7 +726,7 @@ internal class StateBuilder( ) } - private fun createFeeState(txFeeState: TxFeeState, feeType: FeeType, swapProvider: SwapProvider): FeeItemState { + private fun createFeeState(txFeeState: TxFeeState, feeType: FeeType): FeeItemState { val isClickable: Boolean val fee = when (txFeeState) { TxFeeState.Empty -> return FeeItemState.Empty @@ -758,14 +749,9 @@ internal class StateBuilder( return FeeItemState.Content( feeType = feeType, - title = resourceReference(R.string.common_fee_label), + title = resourceReference(R.string.common_network_fee_title), 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, @@ -839,6 +825,25 @@ internal class StateBuilder( ) } + fun createImpactAlert( + uiState: SwapStateHolder, + providerType: ExchangeProviderType, + onAlertClick: () -> Unit, + ): SwapStateHolder { + val message = when (providerType) { + ExchangeProviderType.CEX -> resourceReference(R.string.express_cex_fee_explanation) + ExchangeProviderType.DEX -> resourceReference(R.string.swapping_high_price_impact_description) + } + return uiState.copy( + alert = SwapWarning.GenericWarning( + message = message, + onClick = onAlertClick, + type = GenericWarningType.OTHER, + ), + changeCardsButtonState = ChangeCardsButtonState.ENABLED, + ) + } + fun addAlert(uiState: SwapStateHolder, onClick: () -> Unit): SwapStateHolder { return uiState.copy( alert = SwapWarning.GenericWarning( @@ -852,7 +857,7 @@ internal class StateBuilder( fun addWarning( uiState: SwapStateHolder, - message: String?, + message: TextReference?, shouldWrapMessage: Boolean = false, onClick: () -> Unit, ): SwapStateHolder { @@ -1072,21 +1077,19 @@ internal class StateBuilder( return listOf( FeeItemState.Content( feeType = this.normalFee.feeType, - title = resourceReference(R.string.common_fee_label), + title = resourceReference(R.string.common_network_fee_title), amountCrypto = this.normalFee.feeCryptoFormatted, symbolCrypto = this.normalFee.cryptoSymbol, amountFiatFormatted = this.normalFee.feeFiatFormatted, - explanation = null, isClickable = true, onClick = {}, ), FeeItemState.Content( feeType = this.priorityFee.feeType, - title = resourceReference(R.string.common_fee_label), + title = resourceReference(R.string.common_network_fee_title), amountCrypto = this.priorityFee.feeCryptoFormatted, symbolCrypto = this.priorityFee.cryptoSymbol, amountFiatFormatted = this.priorityFee.feeFiatFormatted, - explanation = null, isClickable = true, onClick = {}, ), @@ -1129,14 +1132,6 @@ internal class StateBuilder( ) } - private fun highPriceImpactNotificationConfig(): NotificationConfig { - return NotificationConfig( - title = resourceReference(R.string.swapping_high_price_impact), - subtitle = resourceReference(R.string.swapping_high_price_impact_description), - iconResId = R.drawable.ic_alert_circle_24, - ) - } - private fun createUnableToCoverFeeNotificationConfig( fromToken: CryptoCurrency, onBuyClick: () -> Unit, diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapPermissionBottomSheet.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapPermissionBottomSheet.kt index fdf6c22c6d..b915b4c0a5 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapPermissionBottomSheet.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapPermissionBottomSheet.kt @@ -267,7 +267,7 @@ private fun DropdownSelector( @Composable private fun FeeItem(fee: String) { InformationItem( - subtitle = stringResource(id = R.string.common_fee_label), + subtitle = stringResource(id = R.string.common_network_fee_title), value = fee, ) } 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 0badf967fd..bb85650ace 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 @@ -109,7 +109,7 @@ internal fun SwapScreenContent(state: SwapStateHolder, modifier: Modifier = Modi val message = if (state.alert.type == GenericWarningType.NETWORK) { stringResource(id = R.string.disclaimer_error_loading) } else { - state.alert.message ?: stringResource(id = R.string.swapping_generic_error) + state.alert.message?.resolveReference() ?: stringResource(id = R.string.swapping_generic_error) } SimpleOkDialog( message = message, @@ -326,12 +326,6 @@ private fun SwapWarnings(warnings: List) { ) { warnings.forEach { warning -> when (warning) { - is SwapWarning.HighPriceImpact -> { - Notification( - config = warning.notificationConfig, - iconTint = TangemTheme.colors.icon.warning, - ) - } is SwapWarning.PermissionNeeded -> { Notification( config = warning.notificationConfig, @@ -340,9 +334,9 @@ private fun SwapWarnings(warnings: List) { is SwapWarning.GenericWarning -> { val message = warning.message?.let { if (warning.shouldWrapMessage) { - String.format(stringResource(id = R.string.swapping_error_wrapper), it) + String.format(stringResource(id = R.string.swapping_error_wrapper), it.resolveReference()) } else { - it + it.resolveReference() } } ?: stringResource(id = R.string.swapping_generic_error) RefreshableWaringCard( @@ -472,7 +466,6 @@ private val state = SwapStateHolder( amountCrypto = "100", symbolCrypto = "1000", amountFiatFormatted = "(100)", - explanation = null, isClickable = true, onClick = {}, ), diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSuccessScreen.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSuccessScreen.kt index 902a000aef..a562a22435 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSuccessScreen.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/SwapSuccessScreen.kt @@ -92,7 +92,7 @@ private fun SwapSuccessScreenContent(state: SwapSuccessStateHolder, padding: Pad ) SpacerH16() InputRowDefault( - title = TextReference.Res(R.string.common_fee_label), + title = TextReference.Res(R.string.common_network_fee_title), text = state.fee, modifier = Modifier .clip(TangemTheme.shapes.roundedCornersXMedium) diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/TransactionCard.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/TransactionCard.kt index 45d37e07de..038465b6d3 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/TransactionCard.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/TransactionCard.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Icon +import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.material.ripple.rememberRipple @@ -284,14 +285,19 @@ private fun Content( .align(Alignment.CenterVertically), ) SpacerW4() - Icon( - painter = painterResource(id = R.drawable.ic_alert_24), - contentDescription = null, - tint = TangemTheme.colors.icon.attention, - modifier = Modifier - .size(size = TangemTheme.dimens.size20) - .align(Alignment.CenterVertically), - ) + IconButton( + onClick = { + type.onWarningClick?.invoke() + }, + modifier = Modifier.size(size = TangemTheme.dimens.size20), + ) { + Icon( + painter = painterResource(id = R.drawable.ic_alert_24), + contentDescription = null, + tint = TangemTheme.colors.icon.attention, + modifier = Modifier.align(Alignment.CenterVertically), + ) + } } } else { AnimatedContent(targetState = amountEquivalent, label = "") { @@ -468,6 +474,7 @@ private fun makePriceImpactBalanceWarning(value: String, priceImpactPercents: In private fun Preview_SwapMainCard_InLightTheme() { TangemTheme(isDark = false) { TransactionCardPreview() + TransactionCardPreviewWithPriceImpact() } } @@ -476,6 +483,7 @@ private fun Preview_SwapMainCard_InLightTheme() { private fun Preview_SwapMainCard_InDarkTheme() { TangemTheme(isDark = true) { TransactionCardPreview() + TransactionCardPreviewWithPriceImpact() } } @@ -494,4 +502,20 @@ private fun TransactionCardPreview() { ) } +@Composable +@Suppress("MagicNumber") +private fun TransactionCardPreviewWithPriceImpact() { + TransactionCard( + type = TransactionCardType.ReadOnly(), + amountEquivalent = "1 000 000", + tokenIconUrl = "", + tokenCurrency = "DAI", + networkIconRes = R.drawable.img_polygon_22, + onChangeTokenClick = {}, + balance = "123", + textFieldValue = TextFieldValue(), + priceImpact = PriceImpact.Value(0.15F), + ) +} + // endregion preview \ No newline at end of file diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt index 54e7a40802..c95f3ed693 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt @@ -876,6 +876,15 @@ internal class SwapViewModel @Inject constructor( onTosClick = { swapRouter.openUrl(it) }, + onReceiveCardWarningClick = { + val selectedProvider = dataState.selectedProvider ?: return@UiActions + uiState = stateBuilder.createImpactAlert( + uiState = uiState, + providerType = selectedProvider.type, + ) { + uiState = stateBuilder.clearAlert(uiState) + } + }, ) }