diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/OnrampIntents.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/OnrampIntents.kt index 5654a17174..0115a77152 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/OnrampIntents.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/OnrampIntents.kt @@ -3,7 +3,7 @@ package com.tangem.features.onramp.main.entity import com.tangem.domain.onramp.model.OnrampProviderWithQuote interface OnrampIntents { - fun onAmountValueChanged(value: String) + fun onAmountValueChanged(value: String, isValuePasted: Boolean) fun openSettings() fun openCurrenciesList() fun onBuyClick(quote: OnrampProviderWithQuote.Data) diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/OnrampStateFactory.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/OnrampStateFactory.kt index bfd3db959d..09da044da3 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/OnrampStateFactory.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/OnrampStateFactory.kt @@ -122,7 +122,7 @@ internal class OnrampStateFactory( amountFieldModel = AmountFieldModel( value = "", fiatValue = "", - onValueChange = onrampIntents::onAmountValueChanged, + onValueChange = { onrampIntents.onAmountValueChanged(value = it, isValuePasted = false) }, keyboardOptions = KeyboardOptions( imeAction = ImeAction.None, keyboardType = KeyboardType.Number, diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/amount/OnrampAmountFieldChangeConverter.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/amount/OnrampAmountFieldChangeConverter.kt index 576bbe719e..02c3f9fa33 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/amount/OnrampAmountFieldChangeConverter.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/amount/OnrampAmountFieldChangeConverter.kt @@ -15,9 +15,12 @@ import java.math.BigDecimal internal class OnrampAmountFieldChangeConverter( private val currentStateProvider: Provider, -) : Converter { +) : Converter { + + override fun convert(input: Input): OnrampMainComponentUM { + val value = input.value + val isValuePasted = input.isValuePasted - override fun convert(value: String): OnrampMainComponentUM { val state = currentStateProvider() if (state !is OnrampMainComponentUM.Content) return state @@ -34,6 +37,7 @@ internal class OnrampAmountFieldChangeConverter( imeAction = if (isDoneActionEnabled) ImeAction.Done else ImeAction.None, keyboardType = KeyboardType.Number, ), + isValuePasted = isValuePasted, ) return state.copy( @@ -66,4 +70,6 @@ internal class OnrampAmountFieldChangeConverter( providerBlockState = OnrampProviderBlockUM.Empty, ) } + + data class Input(val value: String, val isValuePasted: Boolean) } \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/amount/OnrampAmountStateFactory.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/amount/OnrampAmountStateFactory.kt index 2ad9356378..4d466907aa 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/amount/OnrampAmountStateFactory.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/entity/factory/amount/OnrampAmountStateFactory.kt @@ -33,7 +33,8 @@ internal class OnrampAmountStateFactory( currentStateProvider = currentStateProvider, ) - fun getOnAmountValueChange(value: String) = onrampAmountFieldChangeConverter.convert(value) + fun getOnAmountValueChange(value: String, isValuePasted: Boolean) = + onrampAmountFieldChangeConverter.convert(OnrampAmountFieldChangeConverter.Input(value, isValuePasted)) fun getUpdatedCurrencyState(currency: OnrampCurrency): OnrampMainComponentUM { val currentState = currentStateProvider() diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/model/OnrampMainComponentModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/model/OnrampMainComponentModel.kt index 832304f55a..1a415ee735 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/model/OnrampMainComponentModel.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/model/OnrampMainComponentModel.kt @@ -171,7 +171,7 @@ internal class OnrampMainComponentModel @Inject constructor( updatePairsAndQuotes() if (wasInitialLoading && params.launchSepa) { - onAmountValueChanged(PREDEFINED_SEPA_AMOUNT) + onAmountValueChanged(value = PREDEFINED_SEPA_AMOUNT, isValuePasted = true) } }, ) @@ -243,8 +243,8 @@ internal class OnrampMainComponentModel @Inject constructor( .launchIn(modelScope) } - override fun onAmountValueChanged(value: String) { - _state.update { amountStateFactory.getOnAmountValueChange(value) } + override fun onAmountValueChanged(value: String, isValuePasted: Boolean) { + _state.update { amountStateFactory.getOnAmountValueChange(value, isValuePasted) } modelScope.launch { amountInputManager.update(value) } }