Updated on 2026-08-14
This commit is contained in:
commit
bfff994f56
7 changed files with 32 additions and 27 deletions
|
|
@ -75,7 +75,7 @@ internal class StakingStateController @Inject constructor(
|
|||
walletName = "",
|
||||
cryptoCurrencyName = "",
|
||||
cryptoCurrencySymbol = "",
|
||||
cryptoCurrencyNetworkId = "",
|
||||
cryptoCurrencyBlockchainId = "",
|
||||
currentStep = StakingStep.InitialInfo,
|
||||
initialInfoState = StakingStates.InitialInfoState.Empty(),
|
||||
amountState = AmountState.Empty(),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ internal class StakingStateRouter(
|
|||
StakingStep.InitialInfo -> when (stateController.value.actionType) {
|
||||
StakingActionCommonType.Enter -> showAmount()
|
||||
// TODO staking [REDACTED_TASK_KEY] support solana multisize hashes signing
|
||||
StakingActionCommonType.Exit -> if (isSolana(stateController.value.cryptoCurrencyNetworkId)) {
|
||||
StakingActionCommonType.Exit -> if (isSolana(stateController.value.cryptoCurrencyBlockchainId)) {
|
||||
showConfirmation()
|
||||
} else {
|
||||
showAmount()
|
||||
|
|
@ -54,10 +54,15 @@ internal class StakingStateRouter(
|
|||
StakingStep.Amount,
|
||||
-> showInitial()
|
||||
StakingStep.Confirmation -> {
|
||||
if (uiState.actionType != StakingActionCommonType.Enter) {
|
||||
showInitial()
|
||||
} else {
|
||||
val isEnter = uiState.actionType == StakingActionCommonType.Enter
|
||||
val isExit = uiState.actionType == StakingActionCommonType.Exit
|
||||
|
||||
// TODO staking [REDACTED_TASK_KEY] support solana multisize hashes signing
|
||||
val isSolana = isSolana(uiState.cryptoCurrencyBlockchainId)
|
||||
if (isEnter || isExit && !isSolana) {
|
||||
showAmount()
|
||||
} else {
|
||||
showInitial()
|
||||
}
|
||||
}
|
||||
StakingStep.Validators -> showConfirmation()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ internal data class StakingUiState(
|
|||
val walletName: String,
|
||||
val cryptoCurrencyName: String,
|
||||
val cryptoCurrencySymbol: String,
|
||||
val cryptoCurrencyNetworkId: String,
|
||||
val cryptoCurrencyBlockchainId: String,
|
||||
val currentStep: StakingStep,
|
||||
val initialInfoState: StakingStates.InitialInfoState,
|
||||
val amountState: AmountState,
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ internal class SetInitialDataStateTransformer(
|
|||
title = TextReference.EMPTY,
|
||||
cryptoCurrencyName = cryptoCurrency.name,
|
||||
cryptoCurrencySymbol = cryptoCurrency.symbol,
|
||||
cryptoCurrencyNetworkId = cryptoCurrency.network.id.value,
|
||||
cryptoCurrencyBlockchainId = cryptoCurrency.network.id.value,
|
||||
clickIntents = clickIntents,
|
||||
currentStep = StakingStep.InitialInfo,
|
||||
initialInfoState = createInitialInfoState(),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import androidx.compose.ui.text.input.ImeAction
|
|||
import com.tangem.common.extensions.isZero
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.isNullOrEmpty
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
|
|
@ -57,26 +56,22 @@ internal class AmountRequirementStateTransformer(
|
|||
R.string.staking_amount_tron_integer_error_unstaking,
|
||||
wrappedList(value),
|
||||
)
|
||||
else -> TextReference.EMPTY
|
||||
else -> null
|
||||
}
|
||||
else -> TextReference.EMPTY
|
||||
else -> null
|
||||
}
|
||||
val isError = amountState.amountTextField.isError || requirementError != null
|
||||
return if (!errorText.isNullOrEmpty()) {
|
||||
amountState.copy(
|
||||
isPrimaryButtonEnabled = !isError,
|
||||
amountTextField = amountState.amountTextField.copy(
|
||||
isError = isError,
|
||||
isWarning = isIntegerOnlyError,
|
||||
error = errorText,
|
||||
keyboardOptions = amountState.amountTextField.keyboardOptions.copy(
|
||||
imeAction = ImeAction.None,
|
||||
),
|
||||
return amountState.copy(
|
||||
isPrimaryButtonEnabled = !isError,
|
||||
amountTextField = amountState.amountTextField.copy(
|
||||
isError = isError,
|
||||
isWarning = isIntegerOnlyError,
|
||||
error = errorText ?: amountState.amountTextField.error,
|
||||
keyboardOptions = amountState.amountTextField.keyboardOptions.copy(
|
||||
imeAction = ImeAction.None,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
amountState
|
||||
}
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun getRequirementError(prevState: AmountState.Data): TextReference? {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import com.tangem.features.staking.impl.presentation.ui.block.StakingFeeBlock
|
|||
import com.tangem.features.staking.impl.presentation.ui.block.ValidatorBlock
|
||||
import com.tangem.features.staking.impl.presentation.viewmodel.StakingClickIntents
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Composable
|
||||
internal fun StakingConfirmationContent(
|
||||
amountState: AmountState,
|
||||
|
|
@ -39,9 +40,10 @@ internal fun StakingConfirmationContent(
|
|||
validatorState: StakingStates.ValidatorState,
|
||||
clickIntents: StakingClickIntents,
|
||||
type: StakingActionCommonType,
|
||||
isSolana: Boolean, // TODO staking [REDACTED_TASK_KEY] support solana multisize hashes signing
|
||||
) {
|
||||
if (state !is StakingStates.ConfirmationState.Data) return
|
||||
val isEnterAction = type == StakingActionCommonType.Enter
|
||||
val isAmountEditable = type == StakingActionCommonType.Enter || type == StakingActionCommonType.Exit && !isSolana
|
||||
val isTransactionSent = state.innerState == InnerConfirmationStakingState.COMPLETED
|
||||
val isTransactionInProgress = state.notifications.any { it is StakingNotification.Warning.TransactionInProgress }
|
||||
Column(
|
||||
|
|
@ -63,8 +65,8 @@ internal fun StakingConfirmationContent(
|
|||
}
|
||||
AmountBlock(
|
||||
amountState = amountState,
|
||||
isClickDisabled = !isEnterAction || isTransactionSent || isTransactionInProgress,
|
||||
isEditingDisabled = !isEnterAction && state.innerState != InnerConfirmationStakingState.COMPLETED,
|
||||
isClickDisabled = !isAmountEditable || isTransactionSent || isTransactionInProgress,
|
||||
isEditingDisabled = !isAmountEditable && state.innerState != InnerConfirmationStakingState.COMPLETED,
|
||||
onClick = clickIntents::onPrevClick,
|
||||
)
|
||||
ValidatorBlock(
|
||||
|
|
@ -89,6 +91,7 @@ private fun Preview_StakingConfirmationContent() {
|
|||
validatorState = ValidatorStatePreviewData.validatorState,
|
||||
clickIntents = StakingClickIntentsStub,
|
||||
type = StakingActionCommonType.Enter,
|
||||
isSolana = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.tangem.features.staking.impl.presentation.state.bottomsheet.StakingAc
|
|||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.StakingInfoBottomSheetConfig
|
||||
import com.tangem.features.staking.impl.presentation.ui.bottomsheet.StakingActionSelectorBottomSheet
|
||||
import com.tangem.features.staking.impl.presentation.ui.bottomsheet.StakingInfoBottomSheet
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isSolana
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
|
@ -170,6 +171,7 @@ private fun StakingScreenContent(uiState: StakingUiState, modifier: Modifier = M
|
|||
validatorState = uiState.validatorState,
|
||||
clickIntents = uiState.clickIntents,
|
||||
type = uiState.actionType,
|
||||
isSolana = isSolana(uiState.cryptoCurrencyBlockchainId),
|
||||
)
|
||||
StakingStep.RestakeValidator,
|
||||
StakingStep.Validators,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue