Updated on 2026-08-14
This commit is contained in:
parent
d5a188ac3a
commit
b3e9802a62
12 changed files with 266 additions and 170 deletions
|
|
@ -26,4 +26,11 @@ internal sealed class StakingAlertUM : AlertUM {
|
|||
override val message: TextReference = resourceReference(R.string.generic_error_code, wrappedList(code))
|
||||
override val confirmButtonText: TextReference = resourceReference(id = R.string.common_support)
|
||||
}
|
||||
|
||||
data object NoAvailableValidators : StakingAlertUM() {
|
||||
override val title = resourceReference(R.string.common_error)
|
||||
override val message = resourceReference(R.string.staking_no_validators_error_message)
|
||||
override val confirmButtonText = resourceReference(R.string.common_ok)
|
||||
override val onConfirmClick = null
|
||||
}
|
||||
}
|
||||
|
|
@ -50,17 +50,30 @@ internal fun StakingEventEffect(event: StateEvent<StakingEvent>, snackbarHostSta
|
|||
|
||||
@Composable
|
||||
internal fun StakingAlert(state: AlertUM, onDismiss: () -> Unit) {
|
||||
val confirmButton = DialogButtonUM(
|
||||
title = state.confirmButtonText.resolveReference(),
|
||||
onClick = {
|
||||
state.onConfirmClick()
|
||||
onDismiss()
|
||||
},
|
||||
)
|
||||
val dismissButton = DialogButtonUM(
|
||||
title = stringResource(id = R.string.common_cancel),
|
||||
onClick = onDismiss,
|
||||
)
|
||||
val confirmButton: DialogButtonUM
|
||||
val dismissButton: DialogButtonUM?
|
||||
|
||||
val onActionClick = state.onConfirmClick
|
||||
if (onActionClick != null) {
|
||||
confirmButton = DialogButtonUM(
|
||||
title = state.confirmButtonText.resolveReference(),
|
||||
onClick = {
|
||||
onActionClick()
|
||||
onDismiss()
|
||||
},
|
||||
)
|
||||
|
||||
dismissButton = DialogButtonUM(
|
||||
title = stringResource(id = R.string.common_cancel),
|
||||
onClick = onDismiss,
|
||||
)
|
||||
} else {
|
||||
confirmButton = DialogButtonUM(
|
||||
title = state.confirmButtonText.resolveReference(),
|
||||
onClick = onDismiss,
|
||||
)
|
||||
dismissButton = null
|
||||
}
|
||||
|
||||
BasicDialog(
|
||||
message = state.message.resolveReference(),
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ import com.tangem.features.staking.impl.analytics.utils.StakingAnalyticSender
|
|||
import com.tangem.features.staking.impl.navigation.InnerStakingRouter
|
||||
import com.tangem.features.staking.impl.presentation.state.*
|
||||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
|
||||
import com.tangem.features.staking.impl.presentation.state.events.StakingAlertUM
|
||||
import com.tangem.features.staking.impl.presentation.state.events.StakingEvent
|
||||
import com.tangem.features.staking.impl.presentation.state.events.StakingEventFactory
|
||||
import com.tangem.features.staking.impl.presentation.state.helpers.StakingBalanceUpdater
|
||||
import com.tangem.features.staking.impl.presentation.state.helpers.StakingFeeTransactionLoader
|
||||
|
|
@ -406,19 +408,24 @@ internal class StakingViewModel @Inject constructor(
|
|||
// 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,
|
||||
if (filteredValidator.isEmpty()) {
|
||||
stateController.updateEvent(
|
||||
StakingEvent.ShowAlert(StakingAlertUM.NoAvailableValidators),
|
||||
)
|
||||
} else {
|
||||
stateController.update {
|
||||
value.copy(
|
||||
confirmationState = confirmationState?.copy(
|
||||
validatorState = ValidatorState.Content(
|
||||
isClickable = true,
|
||||
chosenValidator = filteredValidator[0],
|
||||
availableValidators = filteredValidator,
|
||||
),
|
||||
) as StakingStates.ConfirmationState,
|
||||
)
|
||||
}
|
||||
onNextClick(StakingActionCommonType.ENTER)
|
||||
}
|
||||
|
||||
onNextClick(StakingActionCommonType.ENTER)
|
||||
}
|
||||
|
||||
override fun onAmountValueChange(value: String) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue