Updated on 2026-08-14
This commit is contained in:
parent
603f522cf9
commit
ceff655d7e
3 changed files with 22 additions and 5 deletions
|
|
@ -27,12 +27,13 @@ internal class SendAmountComponent(
|
|||
override fun Content(modifier: Modifier) {
|
||||
val state by model.uiState.collectAsStateWithLifecycle()
|
||||
val isBalanceHidden by params.isBalanceHidingFlow.collectAsStateWithLifecycle()
|
||||
val isSendWithSwapAvailable by model.isSendWithSwapAvailable.collectAsStateWithLifecycle()
|
||||
|
||||
SendAmountContent(
|
||||
amountState = state,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
clickIntents = model,
|
||||
isSendWithSwapEnabled = model.isSendWithSwapEnabled,
|
||||
isSendWithSwapAvailable = isSendWithSwapAvailable,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,12 @@ import com.tangem.core.ui.extensions.WrappedList
|
|||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.exchange.RampStateManager
|
||||
import com.tangem.domain.tokens.GetMinimumTransactionAmountSyncUseCase
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.ScenarioUnavailabilityReason
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.isMultiCurrency
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.features.send.v2.api.SendFeatureToggles
|
||||
import com.tangem.features.send.v2.api.entity.PredefinedValues
|
||||
|
|
@ -58,6 +61,7 @@ internal class SendAmountModel @Inject constructor(
|
|||
private val sendFeatureToggles: SendFeatureToggles,
|
||||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
private val getUserWalletUseCase: GetUserWalletUseCase,
|
||||
private val rampStateManager: RampStateManager,
|
||||
) : Model(), SendAmountClickIntents {
|
||||
|
||||
private val params: SendAmountComponentParams = paramsContainer.require()
|
||||
|
|
@ -67,7 +71,9 @@ internal class SendAmountModel @Inject constructor(
|
|||
private val _uiState = MutableStateFlow(params.state)
|
||||
val uiState = _uiState.asStateFlow()
|
||||
|
||||
val isSendWithSwapEnabled = sendFeatureToggles.isSendWithSwapEnabled
|
||||
private var isAvailableForSwap: Boolean = false
|
||||
val isSendWithSwapAvailable: StateFlow<Boolean>
|
||||
field = MutableStateFlow(false)
|
||||
|
||||
private val analyticsCategoryName = params.analyticsCategoryName
|
||||
private var cryptoCurrencyStatus: CryptoCurrencyStatus = CryptoCurrencyStatus(
|
||||
|
|
@ -79,6 +85,12 @@ internal class SendAmountModel @Inject constructor(
|
|||
private var maxAmountBoundary: EnterAmountBoundary by Delegates.notNull()
|
||||
|
||||
init {
|
||||
modelScope.launch {
|
||||
isAvailableForSwap = rampStateManager.availableForSwap(
|
||||
userWalletId = params.userWalletId,
|
||||
cryptoCurrency = params.cryptoCurrency,
|
||||
) == ScenarioUnavailabilityReason.None
|
||||
}
|
||||
configAmountNavigation()
|
||||
initAppCurrency()
|
||||
subscribeOnCryptoCurrencyStatusFlow()
|
||||
|
|
@ -301,6 +313,10 @@ internal class SendAmountModel @Inject constructor(
|
|||
flow2 = params.currentRoute,
|
||||
transform = { state, route -> state to route },
|
||||
).onEach { (state, route) ->
|
||||
isSendWithSwapAvailable.update {
|
||||
val isMultiCurrency = userWallet?.isMultiCurrency == true
|
||||
isAvailableForSwap && isMultiCurrency && sendFeatureToggles.isSendWithSwapEnabled
|
||||
}
|
||||
params.callback.onNavigationResult(
|
||||
NavigationUM.Content(
|
||||
title = resourceReference(R.string.send_amount_label),
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ fun SendAmountContent(
|
|||
amountState: AmountState,
|
||||
isBalanceHidden: Boolean,
|
||||
clickIntents: SendAmountClickIntents,
|
||||
isSendWithSwapEnabled: Boolean,
|
||||
isSendWithSwapAvailable: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(modifier = modifier.background(TangemTheme.colors.background.tertiary)) {
|
||||
|
|
@ -40,7 +40,7 @@ fun SendAmountContent(
|
|||
isBalanceHidden = isBalanceHidden,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
if (isSendWithSwapEnabled) {
|
||||
if (isSendWithSwapAvailable) {
|
||||
SendConvertTokenButton(
|
||||
onConvertToAnother = clickIntents::onConvertToAnotherToken,
|
||||
)
|
||||
|
|
@ -95,7 +95,7 @@ private fun SendAmountContent_Preview(@PreviewParameter(SendAmountContentPreview
|
|||
amountState = params,
|
||||
isBalanceHidden = true,
|
||||
clickIntents = SendAmountClickIntentsStub,
|
||||
isSendWithSwapEnabled = true,
|
||||
isSendWithSwapAvailable = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue