Updated on 2026-08-14
This commit is contained in:
parent
cb1cfcf296
commit
01d83b53cf
7 changed files with 15 additions and 10 deletions
|
|
@ -271,7 +271,7 @@ internal class FeedComponentModel @Inject constructor(
|
|||
earnListUM = if (feedFeatureToggle.isEarnBlockEnabled) {
|
||||
EarnListUM.Loading
|
||||
} else {
|
||||
null
|
||||
EarnListUM.Empty
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ internal class FeedStateController @Inject constructor(
|
|||
earnListUM = if (feedFeatureToggle.isEarnBlockEnabled) {
|
||||
EarnListUM.Loading
|
||||
} else {
|
||||
null
|
||||
EarnListUM.Empty
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ internal class UpdateEarnStateTransformer(
|
|||
}
|
||||
|
||||
private fun handleEmptyState(currentState: FeedListUM): FeedListUM {
|
||||
return currentState.copy(earnListUM = null)
|
||||
return currentState.copy(earnListUM = EarnListUM.Empty)
|
||||
}
|
||||
|
||||
private fun handleErrorState(currentState: FeedListUM, result: EarnError): FeedListUM {
|
||||
|
|
@ -69,6 +69,8 @@ internal class UpdateEarnStateTransformer(
|
|||
currentState: FeedListUM,
|
||||
earnTokensWithCurrency: List<EarnTokenWithCurrency>,
|
||||
): FeedListUM {
|
||||
if (earnTokensWithCurrency.isEmpty()) return currentState.copy(earnListUM = EarnListUM.Empty)
|
||||
|
||||
val newItems = earnTokensWithCurrency
|
||||
.sortedWith(
|
||||
compareByDescending<EarnTokenWithCurrency> {
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ private fun MostlyUsedContent(state: EarnListUM, onScroll: () -> Unit) {
|
|||
AnimatedContent(
|
||||
targetState = state,
|
||||
contentKey = { it::class.java },
|
||||
) { st ->
|
||||
when (st) {
|
||||
) { animatedState ->
|
||||
when (animatedState) {
|
||||
is EarnListUM.Loading -> {
|
||||
MostlyUsedPlaceholder()
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ private fun MostlyUsedContent(state: EarnListUM, onScroll: () -> Unit) {
|
|||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
itemsIndexed(
|
||||
items = st.items,
|
||||
items = animatedState.items,
|
||||
key = { _, item -> "${item.tokenName}-${item.network}" },
|
||||
) { index, item ->
|
||||
val cardModifier = Modifier.conditional(
|
||||
|
|
@ -154,9 +154,10 @@ private fun MostlyUsedContent(state: EarnListUM, onScroll: () -> Unit) {
|
|||
.padding(vertical = 32.dp, horizontal = 12.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
UnableToLoadData(onRetryClick = st.onRetryClicked)
|
||||
UnableToLoadData(onRetryClick = animatedState.onRetryClicked)
|
||||
}
|
||||
}
|
||||
EarnListUM.Empty -> Unit // no need to handle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ internal sealed interface EarnListUM {
|
|||
data object Loading : EarnListUM
|
||||
data class Content(val items: ImmutableList<EarnListItemUM>) : EarnListUM
|
||||
data class Error(val onRetryClicked: () -> Unit) : EarnListUM
|
||||
data object Empty : EarnListUM
|
||||
}
|
||||
|
||||
@Immutable
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import com.tangem.features.feed.ui.earn.state.EarnListUM
|
|||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Composable
|
||||
internal fun EarnBlock(onSeeAllClick: () -> Unit, earnListUM: EarnListUM?, modifier: Modifier = Modifier) {
|
||||
if (earnListUM == null) return
|
||||
internal fun EarnBlock(onSeeAllClick: () -> Unit, earnListUM: EarnListUM, modifier: Modifier = Modifier) {
|
||||
if (earnListUM is EarnListUM.Empty) return
|
||||
|
||||
Column(modifier = modifier) {
|
||||
Header(
|
||||
|
|
@ -57,6 +57,7 @@ internal fun EarnBlock(onSeeAllClick: () -> Unit, earnListUM: EarnListUM?, modif
|
|||
is EarnListUM.Content -> EarnContentBlock(items = earnListUM.items)
|
||||
is EarnListUM.Error -> EarnErrorBlock(onRetryClick = earnListUM.onRetryClicked)
|
||||
EarnListUM.Loading -> EarnListPlaceholder(placeholderCount = PLACEHOLDER_ITEM_COUNT)
|
||||
EarnListUM.Empty -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ internal data class FeedListUM(
|
|||
val trendingArticle: ArticleConfigUM?,
|
||||
val marketChartConfig: MarketChartConfig,
|
||||
val globalState: GlobalFeedState = GlobalFeedState.Content,
|
||||
val earnListUM: EarnListUM?,
|
||||
val earnListUM: EarnListUM,
|
||||
)
|
||||
|
||||
internal data class FeedListCallbacks(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue