Updated on 2026-08-14
This commit is contained in:
parent
e356f020f3
commit
71dfa1c99f
31 changed files with 146 additions and 81 deletions
|
|
@ -6,7 +6,7 @@ import com.tangem.domain.appcurrency.model.AppCurrency
|
|||
import java.math.BigDecimal
|
||||
|
||||
@Immutable
|
||||
sealed class FeeState {
|
||||
internal sealed class FeeState {
|
||||
|
||||
data class Content(
|
||||
val fee: Fee?,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.features.staking.impl.presentation.state
|
||||
|
||||
enum class InnerConfirmationStakingState {
|
||||
internal enum class InnerConfirmationStakingState {
|
||||
ASSENT,
|
||||
IN_PROGRESS,
|
||||
COMPLETED,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.tangem.features.staking.impl.presentation.state
|
||||
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
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.core.ui.extensions.*
|
||||
import com.tangem.features.staking.impl.R
|
||||
|
||||
internal sealed class StakingNotification(val config: NotificationConfig) {
|
||||
|
|
@ -50,14 +47,10 @@ internal sealed class StakingNotification(val config: NotificationConfig) {
|
|||
),
|
||||
) {
|
||||
data class EarnRewards(
|
||||
val subtitleResourceId: Int,
|
||||
val currencyName: String,
|
||||
val subtitleText: TextReference,
|
||||
) : Warning(
|
||||
title = resourceReference(R.string.staking_notification_earn_rewards_title),
|
||||
subtitle = resourceReference(
|
||||
subtitleResourceId,
|
||||
wrappedList(currencyName),
|
||||
),
|
||||
subtitle = subtitleText,
|
||||
)
|
||||
|
||||
data class Unstake(
|
||||
|
|
@ -66,7 +59,13 @@ internal sealed class StakingNotification(val config: NotificationConfig) {
|
|||
title = resourceReference(R.string.common_unstake),
|
||||
subtitle = resourceReference(
|
||||
R.string.staking_notification_unstake_text,
|
||||
wrappedList(cooldownPeriodDays, cooldownPeriodDays),
|
||||
wrappedList(
|
||||
pluralReference(
|
||||
id = R.plurals.common_days,
|
||||
count = cooldownPeriodDays,
|
||||
formatArgs = wrappedList(cooldownPeriodDays),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import com.tangem.core.ui.event.StateEvent
|
|||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.domain.staking.model.stakekit.PendingAction
|
||||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
|
||||
import com.tangem.features.staking.impl.presentation.state.events.StakingEvent
|
||||
import com.tangem.features.staking.impl.presentation.state.transformers.InfoType
|
||||
import com.tangem.features.staking.impl.presentation.viewmodel.StakingClickIntents
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.features.staking.impl.presentation.state.bottomsheet
|
||||
|
||||
internal enum class InfoType {
|
||||
ANNUAL_PERCENTAGE_RATE,
|
||||
UNBONDING_PERIOD,
|
||||
REWARD_CLAIMING,
|
||||
WARMUP_PERIOD,
|
||||
REWARD_SCHEDULE,
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.tangem.features.staking.impl.presentation.state.bottomsheet
|
|||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
||||
data class StakingInfoBottomSheetConfig(
|
||||
internal data class StakingInfoBottomSheetConfig(
|
||||
val title: TextReference,
|
||||
val text: TextReference,
|
||||
) : TangemBottomSheetConfigContent
|
||||
|
|
@ -3,6 +3,8 @@ package com.tangem.features.staking.impl.presentation.state.previewdata
|
|||
import com.tangem.blockchain.common.Amount
|
||||
import com.tangem.blockchain.common.AmountType.Coin
|
||||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.staking.model.stakekit.Yield
|
||||
import com.tangem.features.staking.impl.R
|
||||
|
|
@ -81,8 +83,10 @@ internal object ConfirmationStatePreviewData {
|
|||
footerText = "You stake \$715.11 and will be receiving ~\$35 monthly",
|
||||
notifications = persistentListOf(
|
||||
StakingNotification.Warning.EarnRewards(
|
||||
currencyName = "Solana",
|
||||
subtitleResourceId = R.string.staking_notification_earn_rewards_text_period_day,
|
||||
subtitleText = resourceReference(
|
||||
id = R.string.staking_notification_earn_rewards_text_period_day,
|
||||
formatArgs = wrappedList("Solana"),
|
||||
),
|
||||
),
|
||||
),
|
||||
transactionDoneState = TransactionDoneState.Empty,
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ import com.tangem.domain.staking.model.stakekit.PendingAction
|
|||
import com.tangem.domain.staking.model.stakekit.Yield
|
||||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.features.staking.impl.presentation.state.BalanceState
|
||||
import com.tangem.features.staking.impl.presentation.state.transformers.InfoType
|
||||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
|
||||
import com.tangem.features.staking.impl.presentation.viewmodel.StakingClickIntents
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
object StakingClickIntentsStub : StakingClickIntents {
|
||||
internal object StakingClickIntentsStub : StakingClickIntents {
|
||||
|
||||
override fun onBackClick() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.features.staking.impl.presentation.state.transformers
|
||||
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.domain.staking.model.stakekit.Yield
|
||||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.features.staking.impl.R
|
||||
|
|
@ -45,8 +47,10 @@ internal class SetConfirmationStateLoadingTransformer(
|
|||
)
|
||||
} else {
|
||||
StakingNotification.Warning.EarnRewards(
|
||||
currencyName = yield.token.name,
|
||||
subtitleResourceId = getEarnRewardsPeriod(yield.metadata.rewardSchedule),
|
||||
subtitleText = resourceReference(
|
||||
id = getEarnRewardsPeriod(yield.metadata.rewardSchedule),
|
||||
formatArgs = wrappedList(yield.token.name),
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ 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.TransactionDoneState
|
||||
import com.tangem.features.staking.impl.presentation.state.ValidatorState
|
||||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
|
||||
import com.tangem.features.staking.impl.presentation.state.converters.RewardsValidatorStateConverter
|
||||
import com.tangem.features.staking.impl.presentation.state.converters.YieldBalancesConverter
|
||||
import com.tangem.features.staking.impl.presentation.viewmodel.StakingClickIntents
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
|||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingUiState
|
||||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
|
||||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.StakingInfoBottomSheetConfig
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
|
|
@ -42,12 +43,4 @@ internal class ShowInfoBottomSheetStateTransformer(
|
|||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
enum class InfoType {
|
||||
ANNUAL_PERCENTAGE_RATE,
|
||||
UNBONDING_PERIOD,
|
||||
REWARD_CLAIMING,
|
||||
WARMUP_PERIOD,
|
||||
REWARD_SCHEDULE,
|
||||
}
|
||||
|
|
@ -8,8 +8,8 @@ import com.tangem.utils.transformer.Transformer
|
|||
|
||||
internal class AmountChangeStateTransformer(
|
||||
private val cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
private val yield: Yield,
|
||||
private val value: String,
|
||||
yield: Yield,
|
||||
) : Transformer<StakingUiState> {
|
||||
|
||||
private val amountRequirementStateTransformer = AmountRequirementStateTransformer(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.tangem.utils.transformer.Transformer
|
|||
|
||||
internal class AmountMaxValueStateTransformer(
|
||||
private val cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
private val yield: Yield,
|
||||
yield: Yield,
|
||||
) : Transformer<StakingUiState> {
|
||||
|
||||
private val amountRequirementStateTransformer = AmountRequirementStateTransformer(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import com.tangem.domain.staking.model.stakekit.PendingAction
|
|||
import com.tangem.domain.staking.model.stakekit.Yield
|
||||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.features.staking.impl.presentation.state.BalanceState
|
||||
import com.tangem.features.staking.impl.presentation.state.transformers.InfoType
|
||||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.InfoType
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import com.tangem.domain.wallets.models.UserWalletId
|
|||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
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.StakingEventFactory
|
||||
import com.tangem.features.staking.impl.presentation.state.transformers.*
|
||||
import com.tangem.features.staking.impl.presentation.state.transformers.amount.AmountChangeStateTransformer
|
||||
|
|
@ -327,7 +328,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onInitialInfoBannerClick() {
|
||||
// innerRouter.openUrl(WHAT_IS_STAKING_ARTICLE_URL)
|
||||
innerRouter.openUrl(WHAT_IS_STAKING_ARTICLE_URL)
|
||||
}
|
||||
|
||||
override fun onInfoClick(infoType: InfoType) {
|
||||
|
|
@ -339,7 +340,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onAmountValueChange(value: String) {
|
||||
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, yield, value))
|
||||
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, value, yield))
|
||||
}
|
||||
|
||||
override fun onAmountPasteTriggerDismiss() {
|
||||
|
|
@ -369,7 +370,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
StakingActionCommonType.PENDING_OTHER
|
||||
}
|
||||
stateController.update(ValidatorSelectChangeTransformer(activeStake.validator))
|
||||
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, yield, activeStake.cryptoValue))
|
||||
stateController.update(AmountChangeStateTransformer(cryptoCurrencyStatus, activeStake.cryptoValue, yield))
|
||||
onNextClick(actionType, activeStake.pendingActions)
|
||||
}
|
||||
|
||||
|
|
@ -696,7 +697,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private companion object {
|
||||
const val WHAT_IS_STAKING_ARTICLE_URL = "TODO staking"
|
||||
const val WHAT_IS_STAKING_ARTICLE_URL = "https://tangem.com/en/blog/post/how-to-stake-cryptocurrency/"
|
||||
const val ALLOWANCE_UPDATE_DELAY = 10_000L
|
||||
const val BALANCE_UPDATE_DELAY = 11_000L
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue