Updated on 2026-08-14
This commit is contained in:
parent
b9d30a4d55
commit
f209babd03
10 changed files with 55 additions and 6 deletions
|
|
@ -57,6 +57,7 @@ internal sealed class StakingStates {
|
|||
sealed class InitialInfoState : StakingStates() {
|
||||
data class Data(
|
||||
override val isPrimaryButtonEnabled: Boolean,
|
||||
val showBanner: Boolean,
|
||||
val infoItems: ImmutableList<RoundedListWithDividersItemData>,
|
||||
val aprRange: TextReference,
|
||||
val onInfoClick: (InfoType) -> Unit,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import kotlinx.collections.immutable.persistentListOf
|
|||
internal object InitialStakingStatePreview {
|
||||
val defaultState = StakingStates.InitialInfoState.Data(
|
||||
isPrimaryButtonEnabled = true,
|
||||
showBanner = true,
|
||||
aprRange = stringReference("2.54-5.12%"),
|
||||
infoItems = persistentListOf(
|
||||
RoundedListWithDividersItemData(
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ internal class SetInitialDataStateTransformer(
|
|||
private val clickIntents: StakingClickIntents,
|
||||
private val yield: Yield,
|
||||
private val isApprovalNeeded: Boolean,
|
||||
private val isAnyTokenStaked: Boolean,
|
||||
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
|
||||
private val userWalletProvider: Provider<UserWallet>,
|
||||
private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
|
|
@ -79,12 +80,14 @@ internal class SetInitialDataStateTransformer(
|
|||
}
|
||||
|
||||
private fun createInitialInfoState(): StakingStates.InitialInfoState.Data {
|
||||
val yieldBalance = yieldBalancesConverter.convert(Unit)
|
||||
return StakingStates.InitialInfoState.Data(
|
||||
isPrimaryButtonEnabled = !cryptoCurrencyStatusProvider().value.amount.isNullOrZero(),
|
||||
showBanner = !isAnyTokenStaked && yieldBalance == InnerYieldBalanceState.Empty,
|
||||
aprRange = getAprRange(yield.validators),
|
||||
infoItems = getInfoItems(),
|
||||
onInfoClick = clickIntents::onInfoClick,
|
||||
yieldBalance = yieldBalancesConverter.convert(Unit),
|
||||
yieldBalance = yieldBalance,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ internal fun StakingInitialInfoContent(
|
|||
.background(TangemTheme.colors.background.secondary)
|
||||
.padding(horizontal = TangemTheme.dimens.spacing16),
|
||||
) {
|
||||
if (state.yieldBalance == InnerYieldBalanceState.Empty) {
|
||||
if (state.showBanner) {
|
||||
item(key = BANNER_BLOCK_KEY) {
|
||||
Column(
|
||||
modifier = Modifier.animateItemPlacement(),
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
private val validateTransactionUseCase: ValidateTransactionUseCase,
|
||||
private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
||||
private val isAmountSubtractAvailableUseCase: IsAmountSubtractAvailableUseCase,
|
||||
private val isAnyTokenStakedUseCase: IsAnyTokenStakedUseCase,
|
||||
@DelayedWork private val coroutineScope: CoroutineScope,
|
||||
savedStateHandle: SavedStateHandle,
|
||||
) : ViewModel(), DefaultLifecycleObserver, StakingClickIntents {
|
||||
|
|
@ -713,6 +714,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
getCryptoCurrencyStatusSyncUseCase(userWalletId, cryptoCurrencyId).fold(
|
||||
ifRight = {
|
||||
feeCryptoCurrencyStatus = getFeePaidCryptoCurrencyStatusSyncUseCase(userWalletId, it).getOrNull()
|
||||
val isAnyTokenStaked = isAnyTokenStakedUseCase(userWalletId).getOrNull() ?: false
|
||||
cryptoCurrencyStatus = it
|
||||
|
||||
setupApprovalNeeded()
|
||||
|
|
@ -723,6 +725,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
clickIntents = this@StakingViewModel,
|
||||
yield = yield,
|
||||
isApprovalNeeded = stakingApproval is StakingApproval.Needed,
|
||||
isAnyTokenStaked = isAnyTokenStaked,
|
||||
cryptoCurrencyStatusProvider = Provider { cryptoCurrencyStatus },
|
||||
userWalletProvider = Provider { userWallet },
|
||||
appCurrencyProvider = Provider { appCurrency },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue