Updated on 2026-08-14
This commit is contained in:
parent
630682f4d4
commit
48f6151f42
4 changed files with 58 additions and 33 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.features.staking.impl.presentation.state.converters
|
||||
|
||||
import com.tangem.core.ui.extensions.combinedReference
|
||||
import com.tangem.core.ui.extensions.pluralReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
|
|
@ -13,7 +12,6 @@ import com.tangem.features.staking.impl.R
|
|||
import com.tangem.features.staking.impl.presentation.state.BalanceState
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStates
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.StringsSigns.PLUS
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
|
|
@ -74,14 +72,11 @@ internal class RewardsValidatorStateConverter(
|
|||
cryptoCurrency = cryptoCurrency,
|
||||
),
|
||||
)
|
||||
val fiatAmount = combinedReference(
|
||||
stringReference(PLUS),
|
||||
stringReference(
|
||||
BigDecimalFormatter.formatFiatAmount(
|
||||
fiatAmount = fiatValue,
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
),
|
||||
val fiatAmount = stringReference(
|
||||
BigDecimalFormatter.formatFiatAmount(
|
||||
fiatAmount = fiatValue,
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@ internal class SetInitialDataStateTransformer(
|
|||
val cryptoCurrencyName = cryptoCurrencyStatusProvider().currency.name
|
||||
|
||||
return prevState.copy(
|
||||
title = TextReference.Res(
|
||||
R.string.staking_title_stake,
|
||||
wrappedList(cryptoCurrencyName),
|
||||
),
|
||||
title = TextReference.EMPTY,
|
||||
walletName = userWalletProvider.invoke().name,
|
||||
cryptoCurrencyName = cryptoCurrencyName,
|
||||
clickIntents = clickIntents,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package com.tangem.features.staking.impl.presentation.state.transformers
|
||||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.*
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStates
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStep
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingUiState
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.getPendingActionTitle
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
internal object SetTitleTransformer : Transformer<StakingUiState> {
|
||||
|
|
@ -14,26 +18,39 @@ internal object SetTitleTransformer : Transformer<StakingUiState> {
|
|||
val actionType = prevState.actionType
|
||||
val currentStep = prevState.currentStep
|
||||
|
||||
val title = when {
|
||||
currentStep == StakingStep.Amount -> {
|
||||
resourceReference(R.string.send_amount_label)
|
||||
}
|
||||
val title = when (currentStep) {
|
||||
StakingStep.Amount -> resourceReference(R.string.send_amount_label)
|
||||
StakingStep.Validators -> resourceReference(R.string.staking_validators)
|
||||
StakingStep.RewardsValidators -> resourceReference(R.string.common_claim_rewards)
|
||||
StakingStep.InitialInfo -> resourceReference(
|
||||
R.string.staking_title_stake,
|
||||
wrappedList(prevState.cryptoCurrencyName),
|
||||
)
|
||||
|
||||
currentStep == StakingStep.Validators -> {
|
||||
resourceReference(R.string.staking_validators)
|
||||
}
|
||||
StakingStep.Confirmation -> {
|
||||
when (actionType) {
|
||||
StakingActionCommonType.ENTER -> resourceReference(
|
||||
R.string.staking_title_stake,
|
||||
wrappedList(prevState.cryptoCurrencyName),
|
||||
)
|
||||
StakingActionCommonType.EXIT -> resourceReference(
|
||||
R.string.staking_title_unstake,
|
||||
wrappedList(prevState.cryptoCurrencyName),
|
||||
)
|
||||
else -> {
|
||||
val confirmationState = prevState.confirmationState as? StakingStates.ConfirmationState.Data
|
||||
val title = confirmationState?.pendingAction?.type?.getPendingActionTitle()
|
||||
|
||||
actionType == StakingActionCommonType.EXIT && currentStep != StakingStep.InitialInfo -> {
|
||||
resourceReference(
|
||||
R.string.staking_title_unstake,
|
||||
wrappedList(prevState.cryptoCurrencyName),
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
resourceReference(
|
||||
R.string.staking_title_stake,
|
||||
wrappedList(prevState.cryptoCurrencyName),
|
||||
)
|
||||
if (title == null || title == TextReference.EMPTY) {
|
||||
resourceReference(
|
||||
R.string.staking_title_stake,
|
||||
wrappedList(prevState.cryptoCurrencyName),
|
||||
)
|
||||
} else {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,13 @@ internal class StakingViewModel @Inject constructor(
|
|||
override fun onNextClick(actionTypeToOverwrite: StakingActionCommonType?, pendingAction: PendingAction?) {
|
||||
if (actionTypeToOverwrite != null) {
|
||||
stateController.update { it.copy(actionType = actionTypeToOverwrite) }
|
||||
stateController.update {
|
||||
val confirmationState = it.confirmationState as? StakingStates.ConfirmationState.Data
|
||||
it.copy(
|
||||
confirmationState = confirmationState?.copy(pendingAction = pendingAction)
|
||||
?: StakingStates.ConfirmationState.Empty(),
|
||||
)
|
||||
}
|
||||
}
|
||||
stakingStateRouter.onNextClick()
|
||||
when {
|
||||
|
|
@ -407,6 +414,14 @@ internal class StakingViewModel @Inject constructor(
|
|||
ShowActionSelectorBottomSheetTransformer(
|
||||
pendingActions = activeStake.pendingActions,
|
||||
onActionSelect = {
|
||||
stateController.update(ValidatorSelectChangeTransformer(activeStake.validator))
|
||||
stateController.update(
|
||||
AmountChangeStateTransformer(
|
||||
cryptoCurrencyStatus,
|
||||
activeStake.cryptoValue,
|
||||
yield,
|
||||
),
|
||||
)
|
||||
onNextClick(actionTypeToOverwrite = StakingActionCommonType.PENDING_OTHER, pendingAction = it)
|
||||
stateController.update(DismissBottomSheetStateTransformer())
|
||||
},
|
||||
|
|
@ -548,6 +563,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
currencyCheck = currencyStatus,
|
||||
isSubtractAvailable = isAmountSubtractAvailable,
|
||||
feeError = feeError,
|
||||
yield = yield,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue