Updated on 2026-08-14
This commit is contained in:
parent
110ff5c745
commit
e7b7c086bb
27 changed files with 373 additions and 102 deletions
|
|
@ -0,0 +1,8 @@
|
|||
package com.tangem.features.send.api.subcomponents.amount
|
||||
|
||||
/**
|
||||
* Common route for amount
|
||||
*/
|
||||
interface AmountRoute {
|
||||
val isEditMode: Boolean
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.tangem.features.send.api.subcomponents.amount
|
||||
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
|
||||
interface SendAmountBlockComponent : ComposableContentComponent {
|
||||
|
||||
fun updateState(amountUM: AmountState)
|
||||
|
||||
interface Factory {
|
||||
fun create(
|
||||
context: AppComponentContext,
|
||||
params: SendAmountComponentParams.AmountBlockParams,
|
||||
onClick: () -> Unit,
|
||||
onResult: (AmountState) -> Unit,
|
||||
): SendAmountBlockComponent
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.tangem.features.send.api.subcomponents.amount
|
||||
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.navigationButtons.NavigationModelCallback
|
||||
import com.tangem.core.decompose.factory.ComponentFactory
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
import com.tangem.domain.wallets.models.errors.GetUserWalletError
|
||||
|
||||
interface SendAmountComponent : ComposableContentComponent {
|
||||
|
||||
fun updateState(amountUM: AmountState)
|
||||
|
||||
interface ModelCallback : NavigationModelCallback {
|
||||
fun onAmountResult(amountUM: AmountState, isResetPredefined: Boolean)
|
||||
fun onConvertToAnotherToken(lastAmount: String, isEnterInFiatSelected: Boolean)
|
||||
fun resetSendNavigation()
|
||||
fun onError(error: GetUserWalletError)
|
||||
}
|
||||
|
||||
interface Factory : ComponentFactory<SendAmountComponentParams.AmountParams, SendAmountComponent>
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.tangem.features.send.api.subcomponents.amount
|
||||
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.models.account.Account
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.features.send.api.analytics.CommonSendAnalyticEvents
|
||||
import com.tangem.features.send.api.entity.PredefinedValues
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
sealed class SendAmountComponentParams {
|
||||
|
||||
abstract val state: AmountState
|
||||
abstract val analyticsCategoryName: String
|
||||
abstract val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource
|
||||
abstract val userWalletId: UserWalletId
|
||||
abstract val appCurrency: AppCurrency
|
||||
abstract val predefinedValues: PredefinedValues
|
||||
abstract val cryptoCurrency: CryptoCurrency
|
||||
abstract val cryptoCurrencyStatusFlow: StateFlow<CryptoCurrencyStatus>
|
||||
abstract val isBalanceHidingFlow: StateFlow<Boolean>
|
||||
abstract val accountFlow: StateFlow<Account?>
|
||||
abstract val isAccountModeFlow: StateFlow<Boolean>
|
||||
|
||||
data class AmountParams(
|
||||
override val state: AmountState,
|
||||
override val analyticsCategoryName: String,
|
||||
override val userWalletId: UserWalletId,
|
||||
override val appCurrency: AppCurrency,
|
||||
override val predefinedValues: PredefinedValues,
|
||||
override val cryptoCurrency: CryptoCurrency,
|
||||
override val cryptoCurrencyStatusFlow: StateFlow<CryptoCurrencyStatus>,
|
||||
override val isBalanceHidingFlow: StateFlow<Boolean>,
|
||||
override val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource,
|
||||
override val accountFlow: StateFlow<Account?>,
|
||||
override val isAccountModeFlow: StateFlow<Boolean>,
|
||||
val callback: SendAmountComponent.ModelCallback,
|
||||
val currentRoute: Flow<AmountRoute>,
|
||||
) : SendAmountComponentParams()
|
||||
|
||||
data class AmountBlockParams(
|
||||
override val state: AmountState,
|
||||
override val analyticsCategoryName: String,
|
||||
override val appCurrency: AppCurrency,
|
||||
override val userWalletId: UserWalletId,
|
||||
override val predefinedValues: PredefinedValues,
|
||||
override val cryptoCurrency: CryptoCurrency,
|
||||
override val cryptoCurrencyStatusFlow: StateFlow<CryptoCurrencyStatus>,
|
||||
override val isBalanceHidingFlow: StateFlow<Boolean>,
|
||||
override val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource,
|
||||
override val accountFlow: StateFlow<Account?>,
|
||||
override val isAccountModeFlow: StateFlow<Boolean>,
|
||||
val userWallet: UserWallet,
|
||||
val blockClickEnableFlow: StateFlow<Boolean>,
|
||||
) : SendAmountComponentParams()
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.tangem.features.send.api.subcomponents.amount
|
||||
|
||||
import com.tangem.common.ui.amountScreen.converters.AmountReduceByTransformer
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* Trigger for reducing amount from another component
|
||||
*/
|
||||
interface SendAmountReduceTrigger {
|
||||
suspend fun triggerReduceBy(reduceBy: AmountReduceByTransformer.ReduceByData)
|
||||
suspend fun triggerReduceTo(reduceTo: BigDecimal)
|
||||
suspend fun triggerIgnoreReduce()
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger for reducing amount from another component
|
||||
*/
|
||||
interface SendAmountReduceListener {
|
||||
val reduceToTriggerFlow: Flow<BigDecimal>
|
||||
val reduceByTriggerFlow: Flow<AmountReduceByTransformer.ReduceByData>
|
||||
val ignoreReduceTriggerFlow: Flow<Unit>
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger amount change from another component.
|
||||
* Different from another triggers because it takes raw string instead of BigDecimal
|
||||
*/
|
||||
interface SendAmountUpdateTrigger {
|
||||
suspend fun triggerUpdateAmount(amountValue: String, isEnterInFiatSelected: Boolean?)
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger amount change from another component.
|
||||
* Different from another triggers because it takes raw string instead of BigDecimal
|
||||
*/
|
||||
interface SendAmountUpdateListener {
|
||||
val updateAmountTriggerFlow: Flow<Pair<String, Boolean?>>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue