Updated on 2026-08-14
This commit is contained in:
parent
3767ae01b2
commit
ee0e649e6a
9 changed files with 63 additions and 33 deletions
|
|
@ -4,7 +4,9 @@ import androidx.annotation.StringRes
|
|||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
import com.tangem.core.ui.extensions.*
|
||||
import com.tangem.domain.staking.model.CooldownPeriod
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.toTextReference
|
||||
|
||||
internal object StakingNotification {
|
||||
|
||||
|
|
@ -106,19 +108,13 @@ internal object StakingNotification {
|
|||
)
|
||||
|
||||
data class Unstake(
|
||||
val cooldownPeriodDays: Int,
|
||||
val cooldownPeriod: CooldownPeriod,
|
||||
@StringRes val subtitleRes: Int,
|
||||
) : Info(
|
||||
title = resourceReference(R.string.common_unstake),
|
||||
subtitle = resourceReference(
|
||||
subtitleRes,
|
||||
wrappedList(
|
||||
pluralReference(
|
||||
id = R.plurals.common_days,
|
||||
count = cooldownPeriodDays,
|
||||
formatArgs = wrappedList(cooldownPeriodDays),
|
||||
),
|
||||
),
|
||||
wrappedList(cooldownPeriod.toTextReference()),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.tangem.domain.staking.model.StakingIntegration
|
|||
import com.tangem.domain.staking.model.StakingTarget
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.BalanceState
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.toTextReference
|
||||
import com.tangem.lib.crypto.BlockchainUtils
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTon
|
||||
import com.tangem.utils.Provider
|
||||
|
|
@ -143,13 +144,13 @@ internal class StakingBalanceEntryConverter(
|
|||
}
|
||||
|
||||
private fun getUnbondingDate(date: Instant?): TextReference? {
|
||||
val unbondingPeriod = integration.cooldownPeriodDays ?: return null
|
||||
val cooldownPeriod = integration.cooldownPeriod ?: return null
|
||||
if (date == null) {
|
||||
return TextReference.Combined(
|
||||
wrappedList(
|
||||
resourceReference(R.string.staking_details_unbonding_period),
|
||||
stringReference(" "),
|
||||
pluralReference(R.plurals.common_days, unbondingPeriod, wrappedList(unbondingPeriod)),
|
||||
cooldownPeriod.toTextReference(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ 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.state.utils.getRewardScheduleText
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.toTextReference
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.StringsSigns.DASH_SIGN
|
||||
import com.tangem.utils.isNullOrZero
|
||||
|
|
@ -156,15 +157,11 @@ internal class SetInitialDataStateTransformer(
|
|||
}
|
||||
|
||||
private fun createUnbondingPeriodItem(): RoundedListWithDividersItemData? {
|
||||
val cooldownPeriodDays = integration.cooldownPeriodDays ?: return null
|
||||
val cooldownPeriod = integration.cooldownPeriod ?: return null
|
||||
return RoundedListWithDividersItemData(
|
||||
id = R.string.staking_details_unbonding_period,
|
||||
startText = TextReference.Res(R.string.staking_details_unbonding_period),
|
||||
endText = pluralReference(
|
||||
id = R.plurals.common_days,
|
||||
count = cooldownPeriodDays,
|
||||
formatArgs = wrappedList(cooldownPeriodDays),
|
||||
),
|
||||
endText = cooldownPeriod.toTextReference(),
|
||||
iconClick = { clickIntents.onInfoClick(InfoType.UNBONDING_PERIOD) },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.tangem.features.staking.impl.presentation.state.transformers.notific
|
|||
|
||||
import com.tangem.blockchain.common.Amount
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.core.ui.extensions.pluralReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
|
|
@ -19,6 +18,7 @@ import com.tangem.features.staking.impl.presentation.state.InnerYieldBalanceStat
|
|||
import com.tangem.features.staking.impl.presentation.state.StakingNotification
|
||||
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.utils.toTextReference
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isCardano
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isCosmos
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTon
|
||||
|
|
@ -115,17 +115,11 @@ internal class StakingInfoNotificationsFactory(
|
|||
resourceReference(R.string.staking_notification_withdraw_text)
|
||||
}
|
||||
StakingActionType.UNLOCK_LOCKED -> {
|
||||
val cooldownPeriodDays = integration.cooldownPeriodDays
|
||||
if (cooldownPeriodDays != null) {
|
||||
val cooldownPeriod = integration.cooldownPeriod
|
||||
if (cooldownPeriod != null) {
|
||||
resourceReference(R.string.staking_unlocked_locked) to resourceReference(
|
||||
R.string.staking_notification_unlock_text,
|
||||
wrappedList(
|
||||
pluralReference(
|
||||
id = R.plurals.common_days,
|
||||
count = cooldownPeriodDays,
|
||||
formatArgs = wrappedList(cooldownPeriodDays),
|
||||
),
|
||||
),
|
||||
wrappedList(cooldownPeriod.toTextReference()),
|
||||
)
|
||||
} else {
|
||||
null to null
|
||||
|
|
@ -276,13 +270,13 @@ internal class StakingInfoNotificationsFactory(
|
|||
}
|
||||
|
||||
private fun MutableList<NotificationUM>.addUnstakeInfoNotification() {
|
||||
val cooldownPeriodDays = integration.cooldownPeriodDays
|
||||
val cooldownPeriod = integration.cooldownPeriod
|
||||
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.rawId
|
||||
if (cooldownPeriodDays != null) {
|
||||
if (cooldownPeriod != null) {
|
||||
add(
|
||||
StakingNotification.Info.Unstake(
|
||||
cooldownPeriodDays = cooldownPeriodDays,
|
||||
cooldownPeriod = cooldownPeriod,
|
||||
subtitleRes = if (isCosmos(cryptoCurrencyNetworkIdValue)) {
|
||||
R.string.staking_notification_unstake_cosmos_text
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package com.tangem.features.staking.impl.presentation.state.utils
|
||||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
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
|
||||
import com.tangem.domain.staking.model.CooldownPeriod
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.utils.StringsSigns.MINUS
|
||||
import com.tangem.utils.StringsSigns.NON_BREAKING_SPACE
|
||||
|
||||
internal fun CooldownPeriod.toTextReference(): TextReference {
|
||||
return when (this) {
|
||||
is CooldownPeriod.Fixed -> pluralReference(
|
||||
id = R.plurals.common_days,
|
||||
count = days,
|
||||
formatArgs = wrappedList(days),
|
||||
)
|
||||
is CooldownPeriod.Range -> combinedReference(
|
||||
stringReference("$minDays$MINUS$maxDays$NON_BREAKING_SPACE"),
|
||||
pluralReference(
|
||||
id = R.plurals.common_days_no_param,
|
||||
count = maxDays,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue