Updated on 2026-08-14
This commit is contained in:
parent
29cbad3bb5
commit
12d4917dfc
5 changed files with 153 additions and 4 deletions
|
|
@ -8,7 +8,6 @@ import com.tangem.core.analytics.api.AnalyticsEventHandler
|
|||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.ui.DesignFeatureToggles
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.combinedReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
|
|
@ -70,7 +69,6 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
private val isYieldBoostPromoEnabledForTokenUseCase: IsYieldBoostPromoEnabledForTokenUseCase,
|
||||
private val getBoostedApyUseCase: GetBoostedApyUseCase,
|
||||
private val yieldSupplyFeatureToggles: YieldSupplyFeatureToggles,
|
||||
private val designFeatureToggles: DesignFeatureToggles,
|
||||
private val boostStoryPreloader: YieldBoostStoryPreloader,
|
||||
) : Model(), YieldSupplyClickIntents {
|
||||
|
||||
|
|
@ -163,7 +161,6 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
yieldSupplyGetTokenStatusUseCase(cryptoCurrencyToken)
|
||||
.onRight { tokenStatus ->
|
||||
val isPromoEnabled = yieldSupplyFeatureToggles.isYieldPromoEnabled &&
|
||||
!designFeatureToggles.isRedesignEnabled &&
|
||||
isYieldBoostPromoEnabledForTokenUseCase(params.userWalletId, cryptoCurrencyToken)
|
||||
.getOrElse { false }
|
||||
val boostedApy = if (isPromoEnabled) getBoostedApyUseCase(tokenStatus.apy) else null
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.tangem.features.yield.supply.impl.main.model.converter
|
||||
|
||||
import com.tangem.common.ui.earn.EarnBlockUM
|
||||
import com.tangem.core.ui.extensions.combinedReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.features.yield.supply.impl.main.entity.YieldSupplyUM
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
|
@ -21,7 +23,25 @@ internal class YieldSupplyToEarnBlockConverter : Converter<YieldSupplyUM, EarnBl
|
|||
is YieldSupplyUM.Loading -> EarnBlockUM.Loading
|
||||
}
|
||||
|
||||
private fun buildAvailable(value: YieldSupplyUM.Available): EarnBlockUM.Content {
|
||||
private fun buildAvailable(value: YieldSupplyUM.Available): EarnBlockUM = if (value.isBoostAvailable) {
|
||||
buildBoostedPromo(value)
|
||||
} else {
|
||||
buildAvailableContent(value)
|
||||
}
|
||||
|
||||
private fun buildBoostedPromo(value: YieldSupplyUM.Available): EarnBlockUM.Promo {
|
||||
return EarnBlockUM.Promo(
|
||||
type = EarnBlockUM.Type.YieldSupply,
|
||||
backgroundUM = EarnBlockUM.BackgroundUM.AccentSoft,
|
||||
iconUM = EarnBlockUM.IconUM.Glowing(iconRes = CoreUiR.drawable.ic_yield_40),
|
||||
title = combinedReference(value.title, stringReference("\n"), value.apyText),
|
||||
subtitle = resourceReference(CoreResR.string.yield_apy_boost_banner_subtitle),
|
||||
onPrimaryClick = value.onClick,
|
||||
onSecondaryClick = value.onLearnMoreClick,
|
||||
)
|
||||
}
|
||||
|
||||
private fun buildAvailableContent(value: YieldSupplyUM.Available): EarnBlockUM.Content {
|
||||
return EarnBlockUM.Content(
|
||||
type = EarnBlockUM.Type.YieldSupply,
|
||||
backgroundUM = EarnBlockUM.BackgroundUM.AccentSoft,
|
||||
|
|
|
|||
|
|
@ -183,4 +183,32 @@ internal class YieldSupplyToEarnBlockConverterTest {
|
|||
content.onClick?.invoke()
|
||||
assertThat(clicked).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN Available isBoostAvailable WHEN convert THEN Promo with both button callbacks`() {
|
||||
var activateClicked = false
|
||||
var learnMoreClicked = false
|
||||
val available = YieldSupplyUM.Available(
|
||||
apy = "5.1",
|
||||
apyText = stringReference("APY 5.1% x3 → 15.3%"),
|
||||
title = stringReference("Special offer for Yield mode"),
|
||||
onClick = { activateClicked = true },
|
||||
onLearnMoreClick = { learnMoreClicked = true },
|
||||
isBoostAvailable = true,
|
||||
)
|
||||
|
||||
val result = converter.convert(available)
|
||||
|
||||
assertThat(result).isInstanceOf(EarnBlockUM.Promo::class.java)
|
||||
val promo = result as EarnBlockUM.Promo
|
||||
assertThat(promo.type).isEqualTo(EarnBlockUM.Type.YieldSupply)
|
||||
assertThat(promo.backgroundUM).isEqualTo(EarnBlockUM.BackgroundUM.AccentSoft)
|
||||
assertThat(promo.iconUM).isInstanceOf(EarnBlockUM.IconUM.Glowing::class.java)
|
||||
|
||||
promo.onSecondaryClick()
|
||||
assertThat(learnMoreClicked).isTrue()
|
||||
|
||||
promo.onPrimaryClick()
|
||||
assertThat(activateClicked).isTrue()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue