Updated on 2026-08-14

This commit is contained in:
Tangem 2024-05-03 21:07:07 +05:00
parent ef83fdd921
commit 2884fe802b
3 changed files with 37 additions and 6 deletions

View file

@ -153,9 +153,12 @@ internal sealed class SendNotification(val config: NotificationConfig) {
),
)
data object FeeCoverageNotification : Warning(
data class FeeCoverageNotification(val cryptoAmount: String, val fiatAmount: String) : Warning(
title = resourceReference(R.string.send_network_fee_warning_title),
subtitle = resourceReference(R.string.swapping_network_fee_warning_content),
subtitle = resourceReference(
R.string.send_network_fee_warning_content,
wrappedList(cryptoAmount, fiatAmount),
),
)
}
}

View file

@ -42,6 +42,7 @@ internal class SendNotificationFactory(
private val currencyChecksRepository: CurrencyChecksRepository,
private val stateRouterProvider: Provider<StateRouter>,
private val isSubtractAvailableProvider: Provider<Boolean>,
private val appCurrencyProvider: Provider<AppCurrency>,
private val clickIntents: SendClickIntents,
private val analyticsEventHandler: AnalyticsEventHandler,
private val getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
@ -80,7 +81,11 @@ internal class SendNotificationFactory(
addTransactionLimitErrorNotification(feeValue, sendingAmount)
// warnings
addExistentialWarningNotification(feeValue, amountValue)
addFeeCoverageNotification(isFeeCoverage)
addFeeCoverageNotification(
isFeeCoverage = isFeeCoverage,
amountField = amountState.amountTextField,
sendingValue = sendingAmount,
)
addHighFeeWarningNotification(amountValue, sendState.ignoreAmountReduce)
addTooHighNotification(feeState.feeSelectorState)
addTooLowNotification(feeState)
@ -214,10 +219,32 @@ internal class SendNotificationFactory(
}
}
private fun MutableList<SendNotification>.addFeeCoverageNotification(sendingAmount: Boolean) {
if (sendingAmount) {
private fun MutableList<SendNotification>.addFeeCoverageNotification(
isFeeCoverage: Boolean,
amountField: SendTextField.AmountField,
sendingValue: BigDecimal,
) {
if (isFeeCoverage) {
analyticsEventHandler.send(SendAnalyticEvents.NoticeFeeCoverage)
add(SendNotification.Warning.FeeCoverageNotification)
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
val cryptoCurrency = cryptoCurrencyStatus.currency
val fiatRate = cryptoCurrencyStatus.value.fiatRate
val amountValue = amountField.cryptoAmount.value ?: return
val cryptoDiff = amountValue.minus(sendingValue)
add(
SendNotification.Warning.FeeCoverageNotification(
cryptoAmount = BigDecimalFormatter.formatCryptoAmountUncapped(
cryptoAmount = cryptoDiff,
cryptoCurrency = cryptoCurrency,
),
fiatAmount = getFiatString(
value = cryptoDiff,
rate = fiatRate,
appCurrency = appCurrencyProvider(),
),
),
)
}
}

View file

@ -168,6 +168,7 @@ internal class SendViewModel @Inject constructor(
userWalletProvider = Provider { userWallet },
stateRouterProvider = Provider { stateRouter },
isSubtractAvailableProvider = Provider { isAmountSubtractAvailable },
appCurrencyProvider = Provider(selectedAppCurrencyFlow::value),
currencyChecksRepository = currencyChecksRepository,
clickIntents = this,
analyticsEventHandler = analyticsEventHandler,