Updated on 2026-08-14
This commit is contained in:
parent
fa4f73fcaa
commit
15faddd218
6 changed files with 30 additions and 10 deletions
|
|
@ -29,8 +29,9 @@ class YieldConverter(
|
|||
validators = value.validators
|
||||
.asSequence()
|
||||
.filter { it.status == ValidatorStatusDTO.ACTIVE }
|
||||
.sortedByDescending { it.apr }
|
||||
.map { convertValidator(it) }
|
||||
.sortedByDescending { it.isStrategicPartner }
|
||||
.sortedByDescending { it.apr }
|
||||
.toImmutableList(),
|
||||
isAvailable = value.isAvailable,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ internal object StakingClickIntentsStub : StakingClickIntents {
|
|||
|
||||
override fun onInfoClick(infoType: InfoType) {}
|
||||
|
||||
override fun onEnterClick() {}
|
||||
|
||||
override fun onAmountValueChange(value: String) {}
|
||||
|
||||
override fun onAmountPasteTriggerDismiss() {}
|
||||
|
|
|
|||
|
|
@ -140,10 +140,7 @@ internal class SetButtonsStateTransformer(
|
|||
|
||||
private fun StakingUiState.onPrimaryClick() {
|
||||
when (currentStep) {
|
||||
StakingStep.InitialInfo -> {
|
||||
clickIntents.onAmountValueChange("") // reset amount state
|
||||
clickIntents.onNextClick(StakingActionCommonType.ENTER)
|
||||
}
|
||||
StakingStep.InitialInfo -> clickIntents.onEnterClick()
|
||||
StakingStep.Validators -> {
|
||||
if (confirmationState is StakingStates.ConfirmationState.Data) {
|
||||
clickIntents.onNextClick(
|
||||
|
|
@ -154,9 +151,7 @@ internal class SetButtonsStateTransformer(
|
|||
clickIntents.onNextClick()
|
||||
}
|
||||
}
|
||||
StakingStep.Amount -> {
|
||||
clickIntents.onNextClick()
|
||||
}
|
||||
StakingStep.Amount -> clickIntents.onNextClick()
|
||||
StakingStep.Confirmation -> onConfirmationClick()
|
||||
StakingStep.RewardsValidators -> Unit
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.tangem.features.staking.impl.presentation.state.transformers
|
|||
import com.tangem.features.staking.impl.presentation.state.InnerConfirmationStakingState
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStates
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingUiState
|
||||
import com.tangem.features.staking.impl.presentation.state.ValidatorState
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
internal object SetConfirmationStateResetAssentTransformer : Transformer<StakingUiState> {
|
||||
|
|
@ -14,7 +13,7 @@ internal object SetConfirmationStateResetAssentTransformer : Transformer<Staking
|
|||
confirmationState.copy(
|
||||
isPrimaryButtonEnabled = true,
|
||||
innerState = InnerConfirmationStakingState.ASSENT,
|
||||
validatorState = ValidatorState.Loading,
|
||||
validatorState = confirmationState.validatorState.copySealed(isClickable = true),
|
||||
)
|
||||
} else {
|
||||
confirmationState
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ internal interface StakingClickIntents : AmountScreenClickIntents {
|
|||
|
||||
fun onInfoClick(infoType: InfoType)
|
||||
|
||||
fun onEnterClick()
|
||||
|
||||
fun getFee(pendingAction: PendingAction?, pendingActions: ImmutableList<PendingAction>?)
|
||||
|
||||
override fun onAmountNext() = onNextClick(actionTypeToOverwrite = null)
|
||||
|
|
|
|||
|
|
@ -388,6 +388,27 @@ internal class StakingViewModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
override fun onEnterClick() {
|
||||
onAmountValueChange("") // reset amount state
|
||||
|
||||
// TODO refactor in [REDACTED_JIRA]
|
||||
val confirmationState = value.confirmationState as? StakingStates.ConfirmationState.Data
|
||||
val filteredValidator = yield.validators.filter { it.preferred }
|
||||
stateController.update {
|
||||
value.copy(
|
||||
confirmationState = confirmationState?.copy(
|
||||
validatorState = ValidatorState.Content(
|
||||
isClickable = true,
|
||||
chosenValidator = filteredValidator[0],
|
||||
availableValidators = filteredValidator,
|
||||
),
|
||||
) as StakingStates.ConfirmationState,
|
||||
)
|
||||
}
|
||||
|
||||
onNextClick(StakingActionCommonType.ENTER)
|
||||
}
|
||||
|
||||
override fun onAmountValueChange(value: String) {
|
||||
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, value, yield))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue