From d2d93773863b8f5d19c58042ce9f8834e336a493 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 18 Dec 2024 13:16:08 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../tokendetails/TokenDetailsPreviewData.kt | 1 + .../presentation/tokendetails/state/StakingBlockUM.kt | 1 + .../factory/TokenDetailsLoadedBalanceConverter.kt | 10 +++++++++- .../ui/components/staking/TokenStakingBlock.kt | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt index 358d295129..672da4f66c 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt @@ -152,6 +152,7 @@ internal object TokenDetailsPreviewData { formatArgs = wrappedList("Solana"), ), iconState = iconState, + isEnabled = true, onStakeClicked = {}, ) 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 0072e90707..789ddc5ec5 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 @@ -24,6 +24,7 @@ internal sealed interface StakingBlockUM { val iconState: IconState, val titleText: TextReference, val subtitleText: TextReference, + val isEnabled: Boolean, val onStakeClicked: () -> Unit, ) : StakingBlockUM } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsLoadedBalanceConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsLoadedBalanceConverter.kt index a8bf99a969..2a9be57347 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsLoadedBalanceConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsLoadedBalanceConverter.kt @@ -158,7 +158,7 @@ internal class TokenDetailsLoadedBalanceConverter( return when { stakingCryptoAmount.isNullOrZero() && stakingEntryInfo != null -> { if (pendingBalances.isEmpty()) { - getStakeAvailableState(stakingEntryInfo, iconState) + getStakeAvailableState(stakingEntryInfo, iconState, isStakingButtonEnabled(status)) } else { getStakedBlockWithFiatAmount(status, pendingBalances.sumOf { it.amount }, null) } @@ -170,6 +170,12 @@ internal class TokenDetailsLoadedBalanceConverter( } } + private fun isStakingButtonEnabled(status: CryptoCurrencyStatus): Boolean { + return status.value is CryptoCurrencyStatus.Loaded || + status.value is CryptoCurrencyStatus.NoQuote || + status.value is CryptoCurrencyStatus.Custom + } + private fun getStakedBlockWithFiatAmount( status: CryptoCurrencyStatus, stakingAmount: BigDecimal?, @@ -210,6 +216,7 @@ internal class TokenDetailsLoadedBalanceConverter( private fun getStakeAvailableState( stakingEntryInfo: StakingEntryInfo, iconState: IconState, + isEnabled: Boolean, ): StakingBlockUM.StakeAvailable { val apr = stakingEntryInfo.apr.format { percent() } return StakingBlockUM.StakeAvailable( @@ -222,6 +229,7 @@ internal class TokenDetailsLoadedBalanceConverter( formatArgs = wrappedList(stakingEntryInfo.tokenSymbol), ), iconState = iconState, + isEnabled = isEnabled, onStakeClicked = clickIntents::onStakeBannerClick, ) } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/TokenStakingBlock.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/TokenStakingBlock.kt index a8ba9f84c2..484de66cba 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/TokenStakingBlock.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/staking/TokenStakingBlock.kt @@ -112,6 +112,7 @@ private fun StakingAvailableContent(state: StakingBlockUM.StakeAvailable, modifi SecondaryButton( modifier = Modifier.fillMaxWidth(), text = stringResource(id = R.string.common_stake), + enabled = state.isEnabled, onClick = state.onStakeClicked, ) }