Updated on 2026-08-14

This commit is contained in:
Tangem 2025-08-25 15:26:54 +05:00
parent b7bea8357d
commit a378cb5747

View file

@ -19,27 +19,13 @@ internal class WcSendTransactionComponent(
private val feeSelectorBlockComponentFactory: FeeSelectorBlockComponent.Factory,
) : AppComponentContext by appComponentContext, ComposableBottomSheetComponent {
private val feeSelectorBlockComponent by lazy {
val state = requireNotNull(model.uiState.value) { "in this step state should be not null" }
feeSelectorBlockComponentFactory.create(
context = appComponentContext,
params = FeeSelectorParams.FeeSelectorBlockParams(
state = state.feeSelectorUM,
onLoadFee = model::loadFee,
cryptoCurrencyStatus = model.cryptoCurrencyStatus,
feeCryptoCurrencyStatus = model.cryptoCurrencyStatus,
feeStateConfiguration = model.feeStateConfiguration,
feeDisplaySource = FeeSelectorParams.FeeDisplaySource.BottomSheet,
),
onResult = model::updateFee,
)
}
private var feeSelectorBlockComponent: FeeSelectorBlockComponent? = null
init {
lifecycle.doOnResume {
val state = model.uiState.value
if (state?.transaction?.feeState is WcTransactionFeeState.Success) {
feeSelectorBlockComponent.updateState(state.feeSelectorUM)
feeSelectorBlockComponent?.updateState(state.feeSelectorUM)
}
}
}
@ -54,8 +40,12 @@ internal class WcSendTransactionComponent(
val state = content?.transaction
if (state != null) {
val feeSelectorBlock =
if (state.feeState !is WcTransactionFeeState.None) feeSelectorBlockComponent else null
val feeSelectorUM = content?.feeSelectorUM
val feeSelectorBlock = if (state.feeState !is WcTransactionFeeState.None && feeSelectorUM != null) {
getFeeSelectorBlockComponent(feeSelectorUM)
} else {
null
}
WcSendTransactionModalBottomSheet(
state = state,
feeSelectorBlockComponent = feeSelectorBlock,
@ -67,4 +57,26 @@ internal class WcSendTransactionComponent(
)
}
}
private fun getFeeSelectorBlockComponent(feeSelectorUM: FeeSelectorUM): FeeSelectorBlockComponent {
val local = feeSelectorBlockComponent
return if (local != null) {
local
} else {
val component = feeSelectorBlockComponentFactory.create(
context = appComponentContext,
params = FeeSelectorParams.FeeSelectorBlockParams(
state = feeSelectorUM,
onLoadFee = model::loadFee,
cryptoCurrencyStatus = model.cryptoCurrencyStatus,
feeCryptoCurrencyStatus = model.cryptoCurrencyStatus,
feeStateConfiguration = model.feeStateConfiguration,
feeDisplaySource = FeeSelectorParams.FeeDisplaySource.BottomSheet,
),
onResult = model::updateFee,
)
feeSelectorBlockComponent = component
component
}
}
}