Updated on 2026-08-14
This commit is contained in:
parent
799d797fb5
commit
50a384f13d
16 changed files with 61 additions and 78 deletions
|
|
@ -535,9 +535,9 @@ private fun AccountRow(
|
|||
AccountRowComposables(
|
||||
icon = { iconModifier ->
|
||||
val iconSize = if (isExpandedState) {
|
||||
AccountIconSize.RedesignExtraSmall
|
||||
AccountIconSize.ExtraSmall
|
||||
} else {
|
||||
AccountIconSize.RedesignedDefault
|
||||
AccountIconSize.Default
|
||||
}
|
||||
val sizedIcon = when (val icon = tokenRowUM.headIconUM) {
|
||||
is TangemIconUM.Currency -> icon.copy(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.features.feed.model.earn
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import arrow.core.Either
|
||||
import com.arkivanov.decompose.router.slot.SlotNavigation
|
||||
import com.arkivanov.decompose.router.slot.activate
|
||||
import com.arkivanov.decompose.router.slot.dismiss
|
||||
|
|
@ -68,7 +67,7 @@ internal class EarnModel @Inject constructor(
|
|||
) : Model() {
|
||||
|
||||
private val params = paramsContainer.require<DefaultEarnComponent.Params>()
|
||||
private val earnNetworks = MutableStateFlow<EarnNetworks>(Either.Right(emptyList()))
|
||||
private val earnNetworks = MutableStateFlow<EarnNetworks?>(null)
|
||||
private val earnListConfigProvider = Provider {
|
||||
createEarnTokensListConfig(
|
||||
selectedTypeFilter = stateController.value.earnFilterUM.selectedTypeFilter,
|
||||
|
|
@ -131,10 +130,10 @@ internal class EarnModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun EarnFilter.resolveAgainst(networks: EarnNetworks): EarnFilter {
|
||||
private fun EarnFilter.resolveAgainst(networks: EarnNetworks?): EarnFilter {
|
||||
val specific = earnFilterNetwork as? EarnFilterNetwork.Specific ?: return this
|
||||
if (specific.symbol.isNotEmpty()) return this
|
||||
val loaded = networks.getOrNull()?.takeIf { it.isNotEmpty() } ?: return this
|
||||
val loaded = networks?.getOrNull()?.takeIf { it.isNotEmpty() } ?: return this
|
||||
val match = loaded.firstOrNull { it.networkId.equals(specific.id, ignoreCase = true) }
|
||||
return copy(
|
||||
earnFilterNetwork = match?.let { earnNetwork ->
|
||||
|
|
@ -230,7 +229,7 @@ internal class EarnModel @Inject constructor(
|
|||
|
||||
private fun reloadEarnNetworks() {
|
||||
modelScope.launch(dispatchers.default) {
|
||||
if (earnNetworks.value.isLeft()) {
|
||||
if (earnNetworks.value?.isLeft() != false) {
|
||||
fetchEarnNetworks()
|
||||
}
|
||||
}
|
||||
|
|
@ -275,7 +274,7 @@ internal class EarnModel @Inject constructor(
|
|||
isSelected = selectedFilter is EarnFilterNetworkUM.MyNetworks,
|
||||
),
|
||||
)
|
||||
earnNetworks.value.onRight { networks ->
|
||||
earnNetworks.value?.onRight { networks ->
|
||||
networks.mapTo(this) { network ->
|
||||
EarnFilterNetwork.Specific(
|
||||
id = network.networkId,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.tangem.features.feed.ui.earn.state.EarnFilterTypeUM
|
|||
internal fun createEarnTokensListConfig(
|
||||
selectedTypeFilter: EarnFilterTypeUM,
|
||||
selectedNetworkFilter: EarnFilterNetworkUM,
|
||||
earnNetworks: EarnNetworks,
|
||||
earnNetworks: EarnNetworks?,
|
||||
isForEarn: Boolean = false,
|
||||
): EarnTokensListConfig {
|
||||
val type = when (selectedTypeFilter) {
|
||||
|
|
@ -19,8 +19,9 @@ internal fun createEarnTokensListConfig(
|
|||
}
|
||||
val networks = when (selectedNetworkFilter) {
|
||||
is EarnFilterNetworkUM.AllNetworks -> null
|
||||
is EarnFilterNetworkUM.MyNetworks -> {
|
||||
earnNetworks.fold(
|
||||
is EarnFilterNetworkUM.MyNetworks -> when (earnNetworks) {
|
||||
null -> listOf(NO_ONE_NETWORK)
|
||||
else -> earnNetworks.fold(
|
||||
ifLeft = { null },
|
||||
ifRight = { networks ->
|
||||
networks.filter(EarnNetwork::isAdded)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.tangem.features.feed.ui.earn.state.EarnFilterTypeUM
|
|||
import com.tangem.features.feed.ui.earn.state.EarnUM
|
||||
|
||||
internal class EarnFilterSelectedStateTransformer(
|
||||
private val earnNetworks: EarnNetworks,
|
||||
private val earnNetworks: EarnNetworks?,
|
||||
private val filterType: EarnFilterTypeUM,
|
||||
private val filterNetwork: EarnFilterNetworkUM,
|
||||
) : EarnUMTransformer {
|
||||
|
|
@ -16,7 +16,7 @@ internal class EarnFilterSelectedStateTransformer(
|
|||
earnFilterUM = prevState.earnFilterUM.copy(
|
||||
selectedTypeFilter = filterType,
|
||||
selectedNetworkFilter = filterNetwork,
|
||||
isNetworkFilterEnabled = earnNetworks.isRight { networks -> networks.isNotEmpty() },
|
||||
isNetworkFilterEnabled = earnNetworks?.isRight { networks -> networks.isNotEmpty() } == true,
|
||||
isTypeFilterEnabled = true,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ internal class EarnListBatchFlowManager(
|
|||
private val modelScope: CoroutineScope,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) {
|
||||
private val actionsFlow = MutableSharedFlow<BatchAction<Int, EarnTokensListConfig, Nothing>>()
|
||||
// `replay = 1` because the batch source subscribes asynchronously, so an action emitted before
|
||||
// that would be dropped silently.
|
||||
private val actionsFlow = MutableSharedFlow<BatchAction<Int, EarnTokensListConfig, Nothing>>(replay = 1)
|
||||
private val converter = EarnTokenWithCurrencyToListItemUMConverter(
|
||||
onItemClick = { onItemClick(it, EarnSource.BEST_OPPORTUNITIES_SOURCE) },
|
||||
)
|
||||
|
|
@ -38,8 +40,10 @@ internal class EarnListBatchFlowManager(
|
|||
batchSize = DEFAULT_BATCH_SIZE,
|
||||
)
|
||||
|
||||
private val batchState = batchFlow.state.filterNot { it.status is PaginationStatus.None }
|
||||
|
||||
val uiItems: StateFlow<ImmutableList<EarnListItemUM>> =
|
||||
batchFlow.state
|
||||
batchState
|
||||
.scan(persistentListOf<EarnListItemUM>() to -1) { (accItems, lastProcessedBatchIndex), newState ->
|
||||
if (newState.data.size <= lastProcessedBatchIndex) {
|
||||
val newItems = newState.data
|
||||
|
|
@ -63,7 +67,7 @@ internal class EarnListBatchFlowManager(
|
|||
initialValue = persistentListOf(),
|
||||
)
|
||||
|
||||
val initialLoadingError: StateFlow<Throwable?> = batchFlow.state
|
||||
val initialLoadingError: StateFlow<Throwable?> = batchState
|
||||
.map { state ->
|
||||
val status = state.status
|
||||
if (status is PaginationStatus.InitialLoadingError) {
|
||||
|
|
@ -79,7 +83,7 @@ internal class EarnListBatchFlowManager(
|
|||
initialValue = null,
|
||||
)
|
||||
|
||||
val paginationStatus: StateFlow<PaginationStatus<List<EarnTokenWithCurrency>>> = batchFlow.state
|
||||
val paginationStatus: StateFlow<PaginationStatus<List<EarnTokenWithCurrency>>> = batchState
|
||||
.map { it.status }
|
||||
.distinctUntilChanged()
|
||||
.stateIn(
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ internal class ForYouEarnOpportunitiesPotentialRewardsConverter(
|
|||
return TangemTokenRowUM.Content(
|
||||
id = account.accountId.value,
|
||||
headIconUM = TangemIconUM.Currency(
|
||||
currencyIconState = AccountIconItemStateConverter(size = AccountIconSize.RedesignedDefault)
|
||||
currencyIconState = AccountIconItemStateConverter(size = AccountIconSize.Default)
|
||||
.convert(account),
|
||||
),
|
||||
titleUM = TangemTokenRowUM.TitleUM.Content(
|
||||
|
|
|
|||
|
|
@ -187,9 +187,9 @@ private fun PortfolioSharedAssetIcon(
|
|||
|
||||
if (headIcon is TangemIconUM.Currency) {
|
||||
val size = if (isExpandedWrapped) {
|
||||
AccountIconSize.RedesignExtraSmall
|
||||
AccountIconSize.ExtraSmall
|
||||
} else {
|
||||
AccountIconSize.RedesignedDefault
|
||||
AccountIconSize.Default
|
||||
}
|
||||
val currencyIconState = when (val currencyIconState = headIcon.currencyIconState) {
|
||||
is CurrencyIconState.CryptoPortfolio.Icon -> currencyIconState.copy(size = size)
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ import com.tangem.core.ui.extensions.stringResourceSafe
|
|||
import com.tangem.core.ui.haptic.TangemHapticEffect
|
||||
import com.tangem.core.ui.res.LocalHapticManager
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.core.ui.res.TangemThemePreviewRedesign
|
||||
import com.tangem.core.ui.test.ManageTokensScreenTestTags
|
||||
import com.tangem.core.ui.utils.WindowInsetsZero
|
||||
import com.tangem.core.ui.utils.rememberHideKeyboardNestedScrollConnection
|
||||
|
|
@ -78,13 +78,13 @@ internal fun ManageTokensScreen(state: ManageTokensUM, modifier: Modifier = Modi
|
|||
|
||||
Scaffold(
|
||||
modifier = modifier.nestedScroll(nestedScrollConnection),
|
||||
containerColor = TangemTheme.colors.background.primary,
|
||||
containerColor = TangemTheme.colors3.bg.primary,
|
||||
contentWindowInsets = WindowInsetsZero,
|
||||
topBar = {
|
||||
ManageTokensTopBar(
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.background(TangemTheme.colors.background.primary),
|
||||
.background(TangemTheme.colors3.bg.primary),
|
||||
topBar = state.topBar,
|
||||
search = state.search,
|
||||
)
|
||||
|
|
@ -93,6 +93,7 @@ internal fun ManageTokensScreen(state: ManageTokensUM, modifier: Modifier = Modi
|
|||
Content(
|
||||
modifier = Modifier
|
||||
.padding(innerPadding)
|
||||
.padding(horizontal = 8.dp)
|
||||
.fillMaxSize(),
|
||||
state = state,
|
||||
)
|
||||
|
|
@ -245,7 +246,7 @@ fun SearchNothingFoundText(modifier: Modifier = Modifier) {
|
|||
Text(
|
||||
text = stringResourceSafe(R.string.markets_search_token_no_result_title),
|
||||
style = TangemTheme.typography.caption1,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
color = TangemTheme.colors3.text.tertiary,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -253,10 +254,10 @@ fun SearchNothingFoundText(modifier: Modifier = Modifier) {
|
|||
@Composable
|
||||
fun ProgressIndicator(modifier: Modifier = Modifier) {
|
||||
Box(
|
||||
modifier = modifier.background(color = TangemTheme.colors.background.primary),
|
||||
modifier = modifier.background(color = TangemTheme.colors3.bg.primary),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
CircularProgressIndicator(color = TangemTheme.colors.icon.informative)
|
||||
CircularProgressIndicator(color = TangemTheme.colors3.icon.tertiary)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -339,7 +340,7 @@ private fun BasicCurrencyItem(item: CurrencyItemUM.Basic, isEditable: Boolean, m
|
|||
.rotate(rotation)
|
||||
.size(TangemTheme.dimens.size24),
|
||||
painter = painterResource(id = R.drawable.ic_chevron_24),
|
||||
tint = TangemTheme.colors.icon.informative,
|
||||
tint = TangemTheme.colors3.icon.tertiary,
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
|
|
@ -434,7 +435,7 @@ private fun NetworksList(
|
|||
private fun Preview_ManageTokens(
|
||||
@PreviewParameter(PreviewManageTokensComponentProvider::class) component: ManageTokensComponent,
|
||||
) {
|
||||
TangemThemePreview {
|
||||
TangemThemePreviewRedesign {
|
||||
component.Content(Modifier.fillMaxWidth())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ private fun TokenDetailsTitle(titleState: TitleState) {
|
|||
AccountIcon(
|
||||
name = titleState.accountName,
|
||||
icon = titleState.accountIconUM,
|
||||
size = AccountIconSize.RedesignExtraSmall,
|
||||
size = AccountIconSize.ExtraSmall,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ private fun VirtualAccountMainContent(
|
|||
AccountIcon(
|
||||
name = TextReference.EMPTY,
|
||||
icon = AccountIconUM.Virtual,
|
||||
size = AccountIconSize.RedesignedDefault,
|
||||
size = AccountIconSize.Default,
|
||||
modifier = Modifier
|
||||
.layoutId(TangemRowLayoutId.HEAD)
|
||||
.padding(end = TangemTheme.dimens2.x2),
|
||||
|
|
@ -139,7 +139,7 @@ private fun VirtualAccountStateRow(
|
|||
AccountIcon(
|
||||
name = TextReference.EMPTY,
|
||||
icon = AccountIconUM.Virtual,
|
||||
size = AccountIconSize.RedesignedDefault,
|
||||
size = AccountIconSize.Default,
|
||||
modifier = Modifier
|
||||
.layoutId(TangemRowLayoutId.HEAD)
|
||||
.padding(end = TangemTheme.dimens2.x2),
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ import com.tangem.core.ui.components.bottomsheets.TangemBottomSheet
|
|||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetType
|
||||
import com.tangem.core.ui.ds.image.TangemIconUM
|
||||
import com.tangem.core.ui.ds.topbar.TangemTopBar
|
||||
import com.tangem.core.ui.ds.topbar.TangemTopBarType
|
||||
import com.tangem.core.ui.ds2.button.TangemButton
|
||||
import com.tangem.core.ui.ds2.topnavigation.TangemTopNavigation
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
|
@ -47,19 +44,13 @@ internal fun AddAndManageBottomSheetContent(
|
|||
content = TangemBottomSheetConfigContent.Empty,
|
||||
),
|
||||
type = TangemBottomSheetType.Modal,
|
||||
containerColor = TangemTheme.colors2.surface.level2,
|
||||
containerColor = TangemTheme.colors3.bg.tertiary,
|
||||
title = {
|
||||
TangemTopBar(
|
||||
TangemTopNavigation(
|
||||
title = resourceReference(R.string.main_add_and_manage_tokens),
|
||||
type = TangemTopBarType.BottomSheet,
|
||||
endContent = {
|
||||
TangemButton(
|
||||
iconStart = TangemIconUM.Icon(iconRes = R.drawable.ic_close_24),
|
||||
onClick = onDismiss,
|
||||
size = TangemButton.Size.X11,
|
||||
variant = TangemButton.Variant.Material,
|
||||
)
|
||||
},
|
||||
contentAlign = TangemTopNavigation.ContentAlign.Center,
|
||||
blurBackground = false,
|
||||
onClose = onDismiss,
|
||||
)
|
||||
},
|
||||
content = {
|
||||
|
|
@ -119,8 +110,8 @@ private fun AddAndManageRow(
|
|||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(20.dp))
|
||||
.clickable(onClick = onClick)
|
||||
.background(TangemTheme.colors2.surface.level3)
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
.background(TangemTheme.colors3.bg.tertiary)
|
||||
.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Box(
|
||||
|
|
@ -128,12 +119,12 @@ private fun AddAndManageRow(
|
|||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.clip(CircleShape)
|
||||
.background(TangemTheme.colors2.graphic.status.accent.copy(alpha = 0.1f)),
|
||||
.background(TangemTheme.colors3.icon.brand.copy(alpha = 0.1f)),
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier.size(20.dp),
|
||||
imageVector = ImageVector.vectorResource(id = iconRes),
|
||||
tint = TangemTheme.colors2.markers.iconBlue,
|
||||
tint = TangemTheme.colors3.icon.brand,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
|
|
@ -156,7 +147,7 @@ private fun AddAndManageRow(
|
|||
SpacerW(8.dp)
|
||||
Icon(
|
||||
imageVector = Icons.ic_chevron_right_24,
|
||||
tint = TangemTheme.colors2.graphic.neutral.tertiaryConstant,
|
||||
tint = TangemTheme.colors3.icon.secondary,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ internal class OrganizeAccountItemConverter(
|
|||
headerRowUM = TangemHeaderRowUM(
|
||||
id = value.accountId.value,
|
||||
startIconUM = TangemIconUM.Currency(
|
||||
currencyIconState = AccountIconItemStateConverter(size = AccountIconSize.RedesignExtraSmall)
|
||||
currencyIconState = AccountIconItemStateConverter(size = AccountIconSize.ExtraSmall)
|
||||
.convert(value.account),
|
||||
),
|
||||
title = value.account.accountName.toUM().value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue