diff --git a/common/ui/src/main/java/com/tangem/common/ui/tokens/TokenItemStateConverter.kt b/common/ui/src/main/java/com/tangem/common/ui/tokens/TokenItemStateConverter.kt index 9817a2f88a..639e9a9910 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/tokens/TokenItemStateConverter.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/tokens/TokenItemStateConverter.kt @@ -48,7 +48,7 @@ class TokenItemStateConverter( private val iconStateProvider: (CryptoCurrencyStatus) -> CurrencyIconState = { CryptoCurrencyToIconStateConverter().convert(it) }, - private val onApyLabelClick: ((CryptoCurrencyStatus, String) -> Unit)? = null, + private val onApyLabelClick: ((CryptoCurrencyStatus, ApySource, String) -> Unit)? = null, private val titleStateProvider: (CryptoCurrencyStatus) -> TokenItemState.TitleState = { currencyStatus -> createTitleState( currencyStatus = currencyStatus, @@ -166,7 +166,7 @@ class TokenItemStateConverter( currencyStatus: CryptoCurrencyStatus, yieldModuleApyMap: Map, stakingApyMap: Map>, - onApyLabelClick: ((CryptoCurrencyStatus, String) -> Unit)?, + onApyLabelClick: ((CryptoCurrencyStatus, ApySource, String) -> Unit)?, ): TokenItemState.TitleState { return when (val value = currencyStatus.value) { is CryptoCurrencyStatus.Loading, @@ -192,7 +192,7 @@ class TokenItemStateConverter( earnApy = apyInfo?.text, earnApyIsActive = apyInfo?.isActive == true, onApyLabelClick = if (apyInfo?.apy != null && onApyLabelClick != null) { - { onApyLabelClick.invoke(currencyStatus, apyInfo.apy) } + { onApyLabelClick.invoke(currencyStatus, apyInfo.source, apyInfo.apy) } } else { null }, @@ -224,6 +224,7 @@ class TokenItemStateConverter( ), isActive = isActive, apy = yieldSupplyApy, + source = ApySource.YIELD_SUPPLY, ) } } @@ -249,6 +250,7 @@ class TokenItemStateConverter( ), isActive = stakingInfo.isActive, apy = apyString, + source = ApySource.STAKING, ) } } @@ -430,5 +432,11 @@ class TokenItemStateConverter( val text: TextReference?, val isActive: Boolean, val apy: String?, + val source: ApySource, ) + + enum class ApySource { + STAKING, + YIELD_SUPPLY, + } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletContentClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletContentClickIntents.kt index 8c1278e5b6..b6d7d15a65 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletContentClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletContentClickIntents.kt @@ -2,11 +2,11 @@ package com.tangem.feature.wallet.child.wallet.model.intents import arrow.core.getOrElse import com.tangem.common.ui.expressStatus.ExpressStatusBottomSheetConfig +import com.tangem.common.ui.tokens.TokenItemStateConverter.ApySource import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.analytics.models.event.MainScreenAnalyticsEvent import com.tangem.core.decompose.di.ModelScoped import com.tangem.domain.models.account.Account -import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.staking.YieldBalance import com.tangem.domain.models.wallet.UserWallet @@ -50,7 +50,12 @@ internal interface WalletContentClickIntents { fun onTokenItemLongClick(userWalletId: UserWalletId, cryptoCurrencyStatus: CryptoCurrencyStatus) - fun onApyLabelClick(userWalletId: UserWalletId, currencyStatus: CryptoCurrencyStatus, apy: String) + fun onApyLabelClick( + userWalletId: UserWalletId, + currencyStatus: CryptoCurrencyStatus, + apySource: ApySource, + apy: String, + ) fun onAccountExpandClick(account: Account) @@ -162,11 +167,17 @@ internal class WalletContentClickIntentsImplementor @Inject constructor( } } - override fun onApyLabelClick(userWalletId: UserWalletId, currencyStatus: CryptoCurrencyStatus, apy: String) { - val navigationAction = if (currencyStatus.currency is CryptoCurrency.Token) { - NavigationAction.YieldSupply(currencyStatus.value.yieldSupplyStatus?.isActive == true) - } else { - NavigationAction.Staking + override fun onApyLabelClick( + userWalletId: UserWalletId, + currencyStatus: CryptoCurrencyStatus, + apySource: ApySource, + apy: String, + ) { + val navigationAction = when (apySource) { + ApySource.STAKING -> NavigationAction.Staking + ApySource.YIELD_SUPPLY -> { + NavigationAction.YieldSupply(currencyStatus.value.yieldSupplyStatus?.isActive == true) + } } sendApyLabelClickAnalytics(navigationAction, currencyStatus) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/TokenListStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/TokenListStateConverter.kt index f9eefeccd6..6dd7d7de6c 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/TokenListStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/TokenListStateConverter.kt @@ -49,9 +49,15 @@ internal class TokenListStateConverter( clickIntents.onTokenItemLongClick(selectedWallet.walletId, currencyStatus) } - private val onApyLabelClick: (currencyStatus: CryptoCurrencyStatus, apy: String) -> Unit = - { currencyStatus, apy -> - clickIntents.onApyLabelClick(selectedWallet.walletId, currencyStatus, apy) + private val onApyLabelClick: + (currencyStatus: CryptoCurrencyStatus, apySource: TokenItemStateConverter.ApySource, apy: String) -> Unit = + { currencyStatus, apySource, apy -> + clickIntents.onApyLabelClick( + userWalletId = selectedWallet.walletId, + currencyStatus = currencyStatus, + apySource = apySource, + apy = apy, + ) } private fun tokenStatusConverter(accountId: AccountId? = null) = TokenItemStateConverter( @@ -60,7 +66,7 @@ internal class TokenListStateConverter( stakingApyMap = stakingApyMap, onItemClick = { _, status -> onTokenClick(accountId, status) }, onItemLongClick = { _, status -> onTokenLongClick(accountId, status) }, - onApyLabelClick = { status, apy -> onApyLabelClick(status, apy) }, + onApyLabelClick = { status, apySource, apy -> onApyLabelClick(status, apySource, apy) }, ) override fun convert(value: WalletTokensListState): WalletTokensListState {