Updated on 2026-08-14
This commit is contained in:
parent
075db99e51
commit
4a7d9143c2
3 changed files with 121 additions and 8 deletions
|
|
@ -43,10 +43,10 @@ import com.tangem.datasource.local.appsflyer.AppsFlyerStore
|
|||
import com.tangem.domain.account.status.usecase.GetAccountCurrencyStatusUseCase
|
||||
import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase
|
||||
import com.tangem.domain.account.status.usecase.IsAccountsModeEnabledUseCase
|
||||
import com.tangem.domain.card.IsWalletBackupProblematicUseCase
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
|
||||
import com.tangem.domain.card.IsWalletBackupProblematicUseCase
|
||||
import com.tangem.domain.express.models.ExpressOperationType
|
||||
import com.tangem.domain.express.models.ProviderFilterType
|
||||
import com.tangem.domain.feedback.GetWalletMetaInfoUseCase
|
||||
|
|
@ -541,6 +541,10 @@ internal class SwapModel @Inject constructor(
|
|||
)
|
||||
},
|
||||
),
|
||||
isTransferMode = swapTransferInteractor.shouldTransferInsteadOfSwap(
|
||||
fromSwapCurrency = fromSwapCurrencyStatus?.currency,
|
||||
toSwapCurrency = toSwapCurrencyStatus?.currency,
|
||||
),
|
||||
),
|
||||
fromSwapCurrencyStatus = fromSwapCurrencyStatus,
|
||||
toSwapCurrencyStatus = toSwapCurrencyStatus,
|
||||
|
|
@ -623,6 +627,10 @@ internal class SwapModel @Inject constructor(
|
|||
)
|
||||
},
|
||||
),
|
||||
isTransferMode = swapTransferInteractor.shouldTransferInsteadOfSwap(
|
||||
fromSwapCurrency = newFromSwapCurrencyStatus?.currency,
|
||||
toSwapCurrency = newToSwapCurrencyStatus?.currency,
|
||||
),
|
||||
),
|
||||
fromSwapCurrencyStatus = newFromSwapCurrencyStatus,
|
||||
toSwapCurrencyStatus = newToSwapCurrencyStatus,
|
||||
|
|
@ -741,6 +749,10 @@ internal class SwapModel @Inject constructor(
|
|||
)
|
||||
},
|
||||
),
|
||||
isTransferMode = swapTransferInteractor.shouldTransferInsteadOfSwap(
|
||||
fromSwapCurrency = fromSwapCurrencyStatus.currency,
|
||||
toSwapCurrency = toSwapCurrencyStatus.currency,
|
||||
),
|
||||
),
|
||||
fromSwapCurrencyStatus = fromSwapCurrencyStatus,
|
||||
toSwapCurrencyStatus = toSwapCurrencyStatus,
|
||||
|
|
|
|||
|
|
@ -153,10 +153,15 @@ internal class StateBuilder(
|
|||
isHoldToConfirm = fromSwapCurrencyStatus?.userWallet?.isHotWallet == true,
|
||||
onClick = { },
|
||||
),
|
||||
shouldShowMaxAmount = shouldShowMaxAmount(fromSwapCurrencyStatus?.currency, toSwapCurrencyStatus?.currency),
|
||||
predefinedButtons = createPredefinedButtons(
|
||||
shouldShowMaxAmount = shouldShowMaxAmount(
|
||||
fromSwapCurrencyStatus?.currency,
|
||||
toSwapCurrencyStatus?.currency,
|
||||
emptyAmountState.isTransferMode,
|
||||
),
|
||||
predefinedButtons = createPredefinedButtons(
|
||||
fromToken = fromSwapCurrencyStatus?.currency,
|
||||
toCurrency = toSwapCurrencyStatus?.currency,
|
||||
isTransferMode = emptyAmountState.isTransferMode,
|
||||
),
|
||||
changeCardsButtonState = ChangeCardsButtonState.ENABLED,
|
||||
providerState = ProviderState.Empty(),
|
||||
|
|
@ -244,6 +249,11 @@ internal class StateBuilder(
|
|||
toSwapCurrencyStatus: SwapCurrencyStatus?,
|
||||
shouldResetAmount: Boolean,
|
||||
): SwapStateHolder {
|
||||
val shouldShowMaxAmount = shouldShowMaxAmount(
|
||||
fromSwapCurrencyStatus?.currency,
|
||||
toSwapCurrencyStatus?.currency,
|
||||
emptyAmountState.isTransferMode,
|
||||
)
|
||||
return uiStateHolder.copy(
|
||||
sendCardData = uiStateHolder.sendCardData.updateCurrencyStatus(
|
||||
swapCurrencyStatus = fromSwapCurrencyStatus,
|
||||
|
|
@ -267,10 +277,11 @@ internal class StateBuilder(
|
|||
isHoldToConfirm = fromSwapCurrencyStatus?.userWallet?.isHotWallet == true,
|
||||
onClick = { },
|
||||
),
|
||||
shouldShowMaxAmount = shouldShowMaxAmount(fromSwapCurrencyStatus?.currency, toSwapCurrencyStatus?.currency),
|
||||
shouldShowMaxAmount = shouldShowMaxAmount,
|
||||
predefinedButtons = createPredefinedButtons(
|
||||
fromSwapCurrencyStatus?.currency,
|
||||
toSwapCurrencyStatus?.currency,
|
||||
fromToken = fromSwapCurrencyStatus?.currency,
|
||||
toCurrency = toSwapCurrencyStatus?.currency,
|
||||
isTransferMode = emptyAmountState.isTransferMode,
|
||||
),
|
||||
changeCardsButtonState = ChangeCardsButtonState.ENABLED,
|
||||
providerState = ProviderState.Empty(),
|
||||
|
|
@ -683,7 +694,12 @@ internal class StateBuilder(
|
|||
)
|
||||
}
|
||||
|
||||
private fun shouldShowMaxAmount(fromToken: CryptoCurrency?, toCurrency: CryptoCurrency?): Boolean {
|
||||
private fun shouldShowMaxAmount(
|
||||
fromToken: CryptoCurrency?,
|
||||
toCurrency: CryptoCurrency?,
|
||||
isTransferMode: Boolean = false,
|
||||
): Boolean {
|
||||
if (isTransferMode) return true
|
||||
return !(fromToken is CryptoCurrency.Coin && fromToken.network.id == toCurrency?.network?.id)
|
||||
}
|
||||
|
||||
|
|
@ -696,9 +712,10 @@ internal class StateBuilder(
|
|||
private fun createPredefinedButtons(
|
||||
fromToken: CryptoCurrency?,
|
||||
toCurrency: CryptoCurrency?,
|
||||
isTransferMode: Boolean = false,
|
||||
): ImmutableList<PredefinedPercentButtonUM> {
|
||||
if (!swapFeatureToggles.isSwapPredefinedButtonsEnabled) return persistentListOf()
|
||||
val shouldShowMaxAmount = shouldShowMaxAmount(fromToken, toCurrency)
|
||||
val shouldShowMaxAmount = shouldShowMaxAmount(fromToken, toCurrency, isTransferMode)
|
||||
return PredefinedPercentAmount.entries
|
||||
.filter { it != PredefinedPercentAmount.MAX || shouldShowMaxAmount }
|
||||
.map { percent ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue