From b0ec8d2fd2e752130d8a46e2a73c736960a81388 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 23 Jun 2026 10:24:35 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../tokendetails/state/StakingBlockUM.kt | 2 ++ .../TokenDetailsStakingInfoConverter.kt | 24 ++++++++++++-- .../components/staking/StakingBalanceBlock.kt | 32 ++++++++++++++++--- .../staking/TokenStakingBlockLegacy.kt | 27 ++++++++++++---- 4 files changed, 72 insertions(+), 13 deletions(-) diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/StakingBlockUM.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/StakingBlockUM.kt index 789ddc5ec5..f7b398c873 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/StakingBlockUM.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/StakingBlockUM.kt @@ -18,6 +18,7 @@ internal sealed interface StakingBlockUM { val cryptoAmount: BigDecimal?, val fiatAmount: BigDecimal?, val onStakeClicked: () -> Unit, + val isBetaMode: Boolean = false, ) : StakingBlockUM data class StakeAvailable( @@ -26,5 +27,6 @@ internal sealed interface StakingBlockUM { val subtitleText: TextReference, val isEnabled: Boolean, val onStakeClicked: () -> Unit, + val isBetaMode: Boolean = false, ) : StakingBlockUM } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStakingInfoConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStakingInfoConverter.kt index 845d22c4e1..5c6019e55d 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStakingInfoConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStakingInfoConverter.kt @@ -15,6 +15,8 @@ import com.tangem.domain.models.staking.RewardBlockType import com.tangem.domain.models.staking.StakingBalance import com.tangem.domain.staking.model.StakingAvailability import com.tangem.domain.staking.model.StakingEntryInfo +import com.tangem.domain.staking.model.StakingIntegrationID +import com.tangem.domain.staking.model.optionOrNull import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents import com.tangem.feature.tokendetails.presentation.tokendetails.state.IconState import com.tangem.feature.tokendetails.presentation.tokendetails.state.StakingBlockUM @@ -53,12 +55,20 @@ internal class TokenDetailsStakingInfoConverter( StakingAvailability.TemporaryUnavailable -> StakingBlockUM.TemporaryUnavailable StakingAvailability.Unavailable -> null is StakingAvailability.Full -> getStakedBlockOrNull(status) - is StakingAvailability.Available -> getStakingInfoBlock(status, state) + is StakingAvailability.Available -> getStakingInfoBlock( + status = status, + state = state, + isBetaMode = stakingAvailability.optionOrNull?.integrationId == StakingIntegrationID.P2PEthPool, + ) } } @Suppress("CyclomaticComplexMethod") - private fun getStakingInfoBlock(status: CryptoCurrencyStatus, state: TokenDetailsState): StakingBlockUM? { + private fun getStakingInfoBlock( + status: CryptoCurrencyStatus, + state: TokenDetailsState, + isBetaMode: Boolean, + ): StakingBlockUM? { val stakingBalance = status.value.stakingBalance as? StakingBalance.Data val stakingCryptoAmount = stakingBalance?.getTotalStakingBalance(status.currency.network.rawId) @@ -88,7 +98,12 @@ internal class TokenDetailsStakingInfoConverter( return when { stakingCryptoAmount.isNullOrZero() && stakingEntryInfo != null -> { if (!hasPendingBalances) { - getStakeAvailableState(stakingEntryInfo, iconState, isStakingButtonEnabled(status)) + getStakeAvailableState( + stakingEntryInfo = stakingEntryInfo, + iconState = iconState, + isEnabled = isStakingButtonEnabled(status), + isBetaMode = isBetaMode, + ) } else { getStakedBlockWithFiatAmount(status, pendingAmount, null) } @@ -165,6 +180,7 @@ internal class TokenDetailsStakingInfoConverter( stakingEntryInfo: StakingEntryInfo, iconState: IconState, isEnabled: Boolean, + isBetaMode: Boolean, ): StakingBlockUM.StakeAvailable { return StakingBlockUM.StakeAvailable( titleText = resourceReference(id = R.string.token_details_staking_block_title), @@ -175,6 +191,7 @@ internal class TokenDetailsStakingInfoConverter( iconState = iconState, isEnabled = isEnabled, onStakeClicked = clickIntents::onStakeBannerClick, + isBetaMode = isBetaMode, ) } @@ -205,6 +222,7 @@ internal class TokenDetailsStakingInfoConverter( ), rewardValue = getRewardText(status, stakingRewardAmount), onStakeClicked = clickIntents::onStakeBannerClick, + isBetaMode = status.value.stakingBalance is StakingBalance.Data.P2PEthPool, ) } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/StakingBalanceBlock.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/StakingBalanceBlock.kt index d077ce9d52..4ec33c934f 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/StakingBalanceBlock.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/StakingBalanceBlock.kt @@ -40,10 +40,8 @@ internal fun StakingBalanceBlock( verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing4), modifier = Modifier.weight(1f), ) { - Text( - text = stringResourceSafe(R.string.staking_native), - style = TangemTheme.typography.subtitle2, - color = TangemTheme.colors.text.tertiary, + StakingBalanceTitleRow( + isBetaMode = state.isBetaMode, modifier = Modifier.padding(vertical = TangemTheme.dimens.spacing2), ) Row(horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8)) { @@ -84,6 +82,32 @@ internal fun StakingBalanceBlock( } } +@Composable +private fun StakingBalanceTitleRow(isBetaMode: Boolean, modifier: Modifier = Modifier) { + Row( + horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing4), + modifier = modifier, + ) { + Text( + text = stringResourceSafe(R.string.staking_native), + style = TangemTheme.typography.subtitle2, + color = TangemTheme.colors.text.tertiary, + ) + if (isBetaMode) { + Text( + text = StringsSigns.DOT, + style = TangemTheme.typography.subtitle2, + color = TangemTheme.colors.text.tertiary, + ) + Text( + text = stringResourceSafe(R.string.beta_mode_warning_title), + style = TangemTheme.typography.subtitle2, + color = TangemTheme.colors.text.tertiary, + ) + } + } +} + // region Preview @Preview(showBackground = true, widthDp = 360) @Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES) diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/TokenStakingBlockLegacy.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/TokenStakingBlockLegacy.kt index 4b78546b82..bac99ec38b 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/TokenStakingBlockLegacy.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/TokenStakingBlockLegacy.kt @@ -33,6 +33,7 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.TokenDetailsPre import com.tangem.feature.tokendetails.presentation.tokendetails.state.StakingBlockUM import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.CurrencyIcon import com.tangem.features.tokendetails.impl.R +import com.tangem.utils.StringsSigns /** * Token staking block @@ -99,12 +100,26 @@ private fun StakingAvailableContent(state: StakingBlockUM.StakeAvailable, modifi ) SpacerW8() Column { - Text( - text = state.titleText.resolveReference(), - color = TangemTheme.colors.text.primary1, - style = TangemTheme.typography.subtitle2, - modifier = Modifier.testTag(TokenDetailsScreenTestTags.STAKING_SERVICE_TITLE), - ) + Row(horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing4)) { + Text( + text = state.titleText.resolveReference(), + color = TangemTheme.colors.text.primary1, + style = TangemTheme.typography.subtitle2, + modifier = Modifier.testTag(TokenDetailsScreenTestTags.STAKING_SERVICE_TITLE), + ) + if (state.isBetaMode) { + Text( + text = StringsSigns.DOT, + color = TangemTheme.colors.text.primary1, + style = TangemTheme.typography.subtitle2, + ) + Text( + text = stringResourceSafe(R.string.beta_mode_warning_title), + color = TangemTheme.colors.text.primary1, + style = TangemTheme.typography.subtitle2, + ) + } + } Spacer(modifier = Modifier.size(TangemTheme.dimens.size4))