Updated on 2026-08-14
This commit is contained in:
parent
badcca6fb9
commit
1264ada90d
3 changed files with 17 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import com.tangem.blockchain.common.transaction.TransactionFee
|
|||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.core.ui.event.triggeredEvent
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.transaction.error.SendTransactionError
|
||||
import com.tangem.features.send.impl.presentation.state.fee.FeeSelectorState
|
||||
import com.tangem.features.send.impl.presentation.state.fee.FeeStateFactory
|
||||
|
|
@ -21,11 +22,15 @@ import java.math.BigDecimal
|
|||
*/
|
||||
internal class SendEventStateFactory(
|
||||
private val currentStateProvider: Provider<SendUiState>,
|
||||
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
|
||||
private val clickIntents: SendClickIntents,
|
||||
private val feeStateFactory: FeeStateFactory,
|
||||
) {
|
||||
private val sendTransactionErrorConverter by lazy(LazyThreadSafetyMode.NONE) {
|
||||
SendTransactionAlertConverter(clickIntents)
|
||||
SendTransactionAlertConverter(
|
||||
cryptoCurrencyStatusProvider = cryptoCurrencyStatusProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
fun onConsumeEventState(): SendUiState {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
package com.tangem.features.send.impl.presentation.state
|
||||
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.transaction.error.SendTransactionError
|
||||
import com.tangem.features.send.impl.presentation.viewmodel.SendClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
internal class SendTransactionAlertConverter(
|
||||
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
|
||||
private val clickIntents: SendClickIntents,
|
||||
) : Converter<SendTransactionError, SendAlertState?> {
|
||||
override fun convert(value: SendTransactionError): SendAlertState? {
|
||||
|
|
@ -38,7 +42,12 @@ internal class SendTransactionAlertConverter(
|
|||
cause = value.ex?.localizedMessage,
|
||||
onConfirmClick = { clickIntents.onFailedTxEmailClick(value.ex?.localizedMessage.orEmpty()) },
|
||||
)
|
||||
is SendTransactionError.CreateAccountUnderfunded -> SendAlertState.ReserveAmount(value.amount)
|
||||
is SendTransactionError.CreateAccountUnderfunded -> SendAlertState.ReserveAmount(
|
||||
BigDecimalFormatter.formatWithSymbol(
|
||||
amount = value.amount,
|
||||
symbol = cryptoCurrencyStatusProvider().currency.symbol,
|
||||
),
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ internal class SendViewModel @Inject constructor(
|
|||
private val eventStateFactory = SendEventStateFactory(
|
||||
clickIntents = this,
|
||||
currentStateProvider = Provider { uiState },
|
||||
cryptoCurrencyStatusProvider = Provider { cryptoCurrencyStatus },
|
||||
feeStateFactory = feeStateFactory,
|
||||
)
|
||||
|
||||
|
|
@ -784,7 +785,6 @@ internal class SendViewModel @Inject constructor(
|
|||
override fun onAmountReduceClick(reducedAmount: String, clazz: Class<out SendNotification>) {
|
||||
uiState = amountStateFactory.getOnAmountValueChange(reducedAmount)
|
||||
uiState = sendNotificationFactory.dismissNotificationState(clazz)
|
||||
onCheckFeeUpdate()
|
||||
}
|
||||
|
||||
override fun onNotificationCancel(clazz: Class<out SendNotification>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue