Updated on 2026-08-14
This commit is contained in:
parent
bc80eed141
commit
093ee9dd0e
5 changed files with 16 additions and 30 deletions
|
|
@ -5,7 +5,6 @@ import java.math.BigDecimal
|
|||
data class OnrampOffersBlock(
|
||||
val category: OnrampOfferCategory,
|
||||
val offers: List<OnrampOffer>,
|
||||
val hasMoreOffers: Boolean,
|
||||
)
|
||||
|
||||
data class OnrampOffer(
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ class GetOnrampOffersUseCase(
|
|||
recentOffer = recentOffer,
|
||||
bestRateOffer = bestRateOffer,
|
||||
fastestOffer = fastestOffer,
|
||||
allOffers = offers,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +143,6 @@ class GetOnrampOffersUseCase(
|
|||
recentOffer: OnrampOffer?,
|
||||
bestRateOffer: OnrampOffer?,
|
||||
fastestOffer: OnrampOffer?,
|
||||
allOffers: List<OnrampOffer>,
|
||||
): List<OnrampOffersBlock> {
|
||||
val recommendedOffers = buildRecommendedOffers(
|
||||
recentOffer = recentOffer,
|
||||
|
|
@ -152,9 +150,6 @@ class GetOnrampOffersUseCase(
|
|||
fastestOffer = fastestOffer,
|
||||
)
|
||||
|
||||
val shownOffersCount = (if (recentOffer != null) 1 else 0) + recommendedOffers.size
|
||||
val hasMoreOffers = allOffers.size > shownOffersCount
|
||||
|
||||
return buildList {
|
||||
if (recentOffer != null) {
|
||||
add(
|
||||
|
|
@ -170,7 +165,6 @@ class GetOnrampOffersUseCase(
|
|||
rateDif = if (bestRateOffer != null) recentOffer.rateDif else null,
|
||||
),
|
||||
),
|
||||
hasMoreOffers = false,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -180,7 +174,6 @@ class GetOnrampOffersUseCase(
|
|||
OnrampOffersBlock(
|
||||
category = OnrampOfferCategory.Recommended,
|
||||
offers = recommendedOffers,
|
||||
hasMoreOffers = hasMoreOffers,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ internal sealed interface OnrampOffersBlockUM {
|
|||
data class Content(
|
||||
val recentOffer: OnrampOfferUM?,
|
||||
val recommended: ImmutableList<OnrampOfferUM>,
|
||||
val onrampAllOffersButtonConfig: OnrampAllOffersButtonConfig?,
|
||||
val onrampAllOffersButtonConfig: OnrampAllOffersButtonConfig,
|
||||
) : OnrampOffersBlockUM
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,14 +78,10 @@ internal class OnrampOffersStateFactory(
|
|||
return OnrampOffersBlockUM.Content(
|
||||
recentOffer = allOffersUM.firstOrNull { it.category == OnrampOfferCategoryUM.RecentlyUsed },
|
||||
recommended = allOffersUM.filter { it.category == OnrampOfferCategoryUM.Recommended }.toPersistentList(),
|
||||
onrampAllOffersButtonConfig = if (offersBlocks.any { it.hasMoreOffers }) {
|
||||
OnrampAllOffersButtonConfig(
|
||||
title = TextReference.Res(R.string.onramp_all_offers_button_title),
|
||||
onClick = { onrampIntents.openProviders() },
|
||||
)
|
||||
} else {
|
||||
null
|
||||
},
|
||||
onrampAllOffersButtonConfig = OnrampAllOffersButtonConfig(
|
||||
title = TextReference.Res(R.string.onramp_all_offers_button_title),
|
||||
onClick = { onrampIntents.openProviders() },
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,7 @@ import com.tangem.core.ui.test.OnrampOffersBlockTestTags
|
|||
import com.tangem.domain.onramp.model.OnrampPaymentMethod
|
||||
import com.tangem.domain.onramp.model.PaymentMethodType
|
||||
import com.tangem.features.onramp.impl.R
|
||||
import com.tangem.features.onramp.mainv2.entity.OnrampOfferAdvantagesUM
|
||||
import com.tangem.features.onramp.mainv2.entity.OnrampOfferCategoryUM
|
||||
import com.tangem.features.onramp.mainv2.entity.OnrampOfferUM
|
||||
import com.tangem.features.onramp.mainv2.entity.OnrampOffersBlockUM
|
||||
import com.tangem.features.onramp.mainv2.entity.*
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
@Composable
|
||||
|
|
@ -76,14 +73,12 @@ internal fun OnrampOffersContent(state: OnrampOffersBlockUM) {
|
|||
}
|
||||
}
|
||||
|
||||
state.onrampAllOffersButtonConfig?.let {
|
||||
SpacerH(12.dp)
|
||||
SecondaryButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = it.title.resolveReference(),
|
||||
onClick = it.onClick,
|
||||
)
|
||||
}
|
||||
SpacerH(12.dp)
|
||||
SecondaryButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = state.onrampAllOffersButtonConfig.title.resolveReference(),
|
||||
onClick = state.onrampAllOffersButtonConfig.onClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
OnrampOffersBlockUM.Loading -> {
|
||||
|
|
@ -413,7 +408,10 @@ private fun OnrampOffersContentPreview() {
|
|||
onBuyClicked = {},
|
||||
),
|
||||
),
|
||||
onrampAllOffersButtonConfig = null,
|
||||
onrampAllOffersButtonConfig = OnrampAllOffersButtonConfig(
|
||||
title = TextReference.Res(R.string.onramp_all_offers_button_title),
|
||||
onClick = { },
|
||||
),
|
||||
)
|
||||
TangemThemePreview {
|
||||
OnrampOffersContent(state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue