Updated on 2026-08-14
This commit is contained in:
parent
1e2ea28ff9
commit
a7a41d7526
3 changed files with 39 additions and 14 deletions
|
|
@ -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<String, String>,
|
||||
stakingApyMap: Map<String, List<Yield.Validator>>,
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue