Updated on 2026-08-14
This commit is contained in:
parent
98c01df618
commit
6997dd476a
5 changed files with 15 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -15,9 +15,12 @@ import java.math.BigDecimal
|
|||
|
||||
internal class OnrampAmountFieldChangeConverter(
|
||||
private val currentStateProvider: Provider<OnrampMainComponentUM>,
|
||||
) : Converter<String, OnrampMainComponentUM> {
|
||||
) : Converter<OnrampAmountFieldChangeConverter.Input, OnrampMainComponentUM> {
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue