diff --git a/features/swap/impl/src/main/java/com/tangem/feature/swap/DefaultSwapComponent.kt b/features/swap/impl/src/main/java/com/tangem/feature/swap/DefaultSwapComponent.kt index cb01f7cde4..55e17a1292 100644 --- a/features/swap/impl/src/main/java/com/tangem/feature/swap/DefaultSwapComponent.kt +++ b/features/swap/impl/src/main/java/com/tangem/feature/swap/DefaultSwapComponent.kt @@ -24,7 +24,6 @@ import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.feature.swap.component.SwapFeeSelectorBlockComponent import com.tangem.feature.swap.model.SwapModel import com.tangem.feature.swap.models.AddToPortfolioRoute -import com.tangem.feature.swap.models.SwapCardState.SwapCardData import com.tangem.feature.swap.router.SwapNavScreen import com.tangem.feature.swap.ui.SwapScreen import com.tangem.feature.swap.ui.SwapSelectTokenScreen @@ -100,14 +99,25 @@ internal class DefaultSwapComponent @AssistedInject constructor( val feeCurrencyStatus: CryptoCurrencyStatus, ) - @Suppress("LongMethod") + @Suppress("LongMethod", "CyclomaticComplexMethod") @Composable override fun Content(modifier: Modifier) { if (sendFeatureToggles.isGaslessTransactionsEnabled) { - val sendCardData = model.uiState.sendCardData as? SwapCardData + val fromCryptoCurrency = if (model.isOrderReversed) { + model.dataState.toCryptoCurrency + } else { + model.dataState.fromCryptoCurrency + } val feePaidCryptoCurrency = model.dataState.feePaidCryptoCurrency - LaunchedEffect(sendCardData?.token?.currency, feePaidCryptoCurrency?.currency) { - val sendingCryptoCurrencyStatus = sendCardData?.token ?: run { + val amount = model.dataState.amount + + LaunchedEffect(fromCryptoCurrency, feePaidCryptoCurrency, amount.isNullOrBlank()) { + if (amount.isNullOrBlank()) { + slotNavigation.dismiss() + return@LaunchedEffect + } + + val sendingCryptoCurrencyStatus = fromCryptoCurrency ?: run { slotNavigation.dismiss() return@LaunchedEffect } diff --git a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt index 78baa4057b..24e0159328 100644 --- a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt +++ b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt @@ -213,7 +213,7 @@ internal class SwapModel @Inject constructor( val feeSelectorRepository = FeeSelectorRepository() // shows currency order (direct - swap initial to selected, reversed = selected to initial) - private var isOrderReversed = false + var isOrderReversed by mutableStateOf(false) private val lastAmount = mutableStateOf(INITIAL_AMOUNT) private val lastReducedBalanceBy = mutableStateOf(BigDecimal.ZERO) private val swapRouter: SwapRouter = SwapRouter(router = router)