diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt index bce4d536e1..56a3cec48c 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt @@ -5,6 +5,7 @@ import com.tangem.core.ui.R import com.tangem.core.ui.components.marketprice.MarketPriceBlockState import com.tangem.core.ui.components.marketprice.PriceChangeConfig import com.tangem.core.ui.components.transactions.TransactionState +import com.tangem.core.ui.extensions.TextReference import com.tangem.domain.wallets.models.UserWalletId import com.tangem.feature.wallet.presentation.common.state.TokenItemState import com.tangem.feature.wallet.presentation.common.state.TokenItemState.TokenOptionsState @@ -13,6 +14,7 @@ import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensListS import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensStateHolder import com.tangem.feature.wallet.presentation.wallet.state.* import com.tangem.feature.wallet.presentation.wallet.state.components.* +import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTokensListState.TokensListItemState import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toPersistentList import kotlinx.coroutines.flow.flowOf @@ -260,8 +262,8 @@ internal object WalletPreviewData { walletsListConfig = walletListConfig, tokensListState = WalletTokensListState.Content( persistentListOf( - WalletTokensListState.TokensListItemState.NetworkGroupTitle("Bitcoin"), - WalletTokensListState.TokensListItemState.Token( + TokensListItemState.NetworkGroupTitle(TextReference.Str("Bitcoin")), + TokensListItemState.Token( tokenItemVisibleState.copy( id = "token_1", name = "Ethereum", @@ -270,7 +272,7 @@ internal object WalletPreviewData { amount = "1,89340821 ETH", ), ), - WalletTokensListState.TokensListItemState.Token( + TokensListItemState.Token( tokenItemVisibleState.copy( id = "token_2", name = "Ethereum", @@ -279,7 +281,7 @@ internal object WalletPreviewData { amount = "1,89340821 ETH", ), ), - WalletTokensListState.TokensListItemState.Token( + TokensListItemState.Token( tokenItemVisibleState.copy( id = "token_3", name = "Ethereum", @@ -288,7 +290,7 @@ internal object WalletPreviewData { amount = "1,89340821 ETH", ), ), - WalletTokensListState.TokensListItemState.Token( + TokensListItemState.Token( tokenItemVisibleState.copy( id = "token_4", name = "Ethereum", @@ -297,8 +299,8 @@ internal object WalletPreviewData { amount = "1,89340821 ETH", ), ), - WalletTokensListState.TokensListItemState.NetworkGroupTitle("Ethereum"), - WalletTokensListState.TokensListItemState.Token( + TokensListItemState.NetworkGroupTitle(TextReference.Str("Ethereum")), + TokensListItemState.Token( tokenItemVisibleState.copy( id = "token_5", name = "Ethereum", @@ -334,7 +336,7 @@ internal object WalletPreviewData { onRefresh = {}, ), notifications = persistentListOf(WalletNotification.LikeTangemApp(onClick = {})), - buttons = manageButtons.map(WalletManageButton::config).toPersistentList(), + buttons = manageButtons, bottomSheetConfig = bottomSheet, marketPriceBlockState = MarketPriceBlockState.Content( currencyName = "BTC", diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletSingleCurrencyState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletSingleCurrencyState.kt index 2a01cb5668..f29b229afd 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletSingleCurrencyState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletSingleCurrencyState.kt @@ -1,6 +1,5 @@ package com.tangem.feature.wallet.presentation.wallet.state -import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.core.ui.components.marketprice.MarketPriceBlockState import com.tangem.feature.wallet.presentation.wallet.state.components.* import kotlinx.collections.immutable.ImmutableList @@ -14,7 +13,7 @@ import kotlinx.collections.immutable.persistentListOf internal sealed class WalletSingleCurrencyState : WalletStateHolder() { /** Manage buttons */ - abstract val buttons: ImmutableList + abstract val buttons: ImmutableList /** Market price block state */ abstract val marketPriceBlockState: MarketPriceBlockState? @@ -29,7 +28,7 @@ internal sealed class WalletSingleCurrencyState : WalletStateHolder() { override val pullToRefreshConfig: WalletPullToRefreshConfig, override val notifications: ImmutableList, override val bottomSheetConfig: WalletBottomSheetConfig?, - override val buttons: ImmutableList, + override val buttons: ImmutableList, override val marketPriceBlockState: MarketPriceBlockState, override val txHistoryState: WalletTxHistoryState, ) : WalletSingleCurrencyState() @@ -39,7 +38,7 @@ internal sealed class WalletSingleCurrencyState : WalletStateHolder() { override val topBarConfig: WalletTopBarConfig, override val walletsListConfig: WalletsListConfig, override val pullToRefreshConfig: WalletPullToRefreshConfig, - override val buttons: ImmutableList, + override val buttons: ImmutableList, override val onUnlockWalletsNotificationClick: () -> Unit, override val onUnlockClick: () -> Unit, override val onScanClick: () -> Unit, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletManageButton.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletManageButton.kt index 61441600c3..6d6055c045 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletManageButton.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletManageButton.kt @@ -13,16 +13,34 @@ import com.tangem.feature.wallet.impl.R */ sealed class WalletManageButton(val config: ActionButtonConfig) { + /** Lambda be invoked when manage button is clicked */ + abstract val onClick: (() -> Unit)? + /** * Buy * * @param onClick lambda be invoked when manage button is clicked */ - data class Buy(val onClick: () -> Unit) : WalletManageButton( + data class Buy(override val onClick: (() -> Unit)? = null) : WalletManageButton( config = ActionButtonConfig( text = TextReference.Res(id = R.string.common_buy), iconResId = R.drawable.ic_plus_24, - onClick = onClick, + onClick = onClick ?: {}, + enabled = onClick != null, + ), + ) + + /** + * Sell + * + * @param onClick lambda be invoked when manage button is clicked + */ + data class Sell(override val onClick: (() -> Unit)? = null) : WalletManageButton( + config = ActionButtonConfig( + text = TextReference.Res(id = R.string.common_sell), + iconResId = R.drawable.ic_currency_24, + onClick = onClick ?: {}, + enabled = onClick != null, ), ) @@ -31,11 +49,12 @@ sealed class WalletManageButton(val config: ActionButtonConfig) { * * @param onClick lambda be invoked when manage button is clicked */ - data class Send(val onClick: () -> Unit) : WalletManageButton( + data class Send(override val onClick: (() -> Unit)? = null) : WalletManageButton( config = ActionButtonConfig( text = TextReference.Res(id = R.string.common_send), iconResId = R.drawable.ic_arrow_up_24, - onClick = onClick, + onClick = onClick ?: {}, + enabled = onClick != null, ), ) @@ -44,7 +63,7 @@ sealed class WalletManageButton(val config: ActionButtonConfig) { * * @param onClick lambda be invoked when manage button is clicked */ - data class Receive(val onClick: () -> Unit) : WalletManageButton( + data class Receive(override val onClick: () -> Unit) : WalletManageButton( config = ActionButtonConfig( text = TextReference.Res(id = R.string.common_receive), iconResId = R.drawable.ic_arrow_down_24, @@ -57,11 +76,12 @@ sealed class WalletManageButton(val config: ActionButtonConfig) { * * @param onClick lambda be invoked when manage button is clicked */ - data class Exchange(val onClick: () -> Unit) : WalletManageButton( + data class Exchange(override val onClick: (() -> Unit)? = null) : WalletManageButton( config = ActionButtonConfig( text = TextReference.Res(id = R.string.common_exchange), iconResId = R.drawable.ic_exchange_vertical_24, - onClick = onClick, + onClick = onClick ?: {}, + enabled = onClick != null, ), ) @@ -70,7 +90,7 @@ sealed class WalletManageButton(val config: ActionButtonConfig) { * * @param onClick lambda be invoked when manage button is clicked */ - data class CopyAddress(val onClick: () -> Unit) : WalletManageButton( + data class CopyAddress(override val onClick: () -> Unit) : WalletManageButton( config = ActionButtonConfig( text = TextReference.Res(id = R.string.common_copy_address), iconResId = R.drawable.ic_copy_24, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletTokensListState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletTokensListState.kt index 9fa10a5446..b9505c2802 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletTokensListState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletTokensListState.kt @@ -1,5 +1,7 @@ package com.tangem.feature.wallet.presentation.wallet.state.components +import com.tangem.core.ui.extensions.TextReference +import com.tangem.feature.wallet.impl.R import com.tangem.feature.wallet.presentation.common.state.TokenItemState import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf @@ -12,17 +14,26 @@ import kotlinx.collections.immutable.persistentListOf * [REDACTED_AUTHOR] */ -// TODO: Finalize strings [REDACTED_JIRA] internal sealed class WalletTokensListState( open val items: ImmutableList, open val onOrganizeTokensClick: (() -> Unit)?, ) { + /** Loading content state */ + object Loading : WalletTokensListState( + items = persistentListOf( + TokensListItemState.NetworkGroupTitle(value = TextReference.Res(id = R.string.main_tokens)), + TokensListItemState.Token(state = TokenItemState.Loading), + TokensListItemState.Token(state = TokenItemState.Loading), + ), + onOrganizeTokensClick = null, + ) + /** * Content state * - * @property items content items - * @property onOrganizeTokensClick lambda be invoked when organize tokens button is clicked + * @property items content items + * @property onOrganizeTokensClick lambda be invoked when organize tokens button is clicked */ data class Content( override val items: ImmutableList, @@ -33,7 +44,7 @@ internal sealed class WalletTokensListState( object Locked : WalletTokensListState( items = persistentListOf( - TokensListItemState.NetworkGroupTitle(networkName = "Tokens"), + TokensListItemState.NetworkGroupTitle(value = TextReference.Res(id = R.string.main_tokens)), TokensListItemState.Token(state = TokenItemState.Loading), ), onOrganizeTokensClick = null, @@ -46,9 +57,9 @@ internal sealed class WalletTokensListState( /** * Network group title item * - * @property networkName network name + * @property value network name */ - data class NetworkGroupTitle(val networkName: String) : TokensListItemState + data class NetworkGroupTitle(val value: TextReference) : TokensListItemState /** * Token item diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletTxHistoryState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletTxHistoryState.kt index b09a0410c8..66448a4f71 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletTxHistoryState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletTxHistoryState.kt @@ -20,7 +20,38 @@ internal sealed interface WalletTxHistoryState { sealed class ContentState(open val items: Flow>) : WalletTxHistoryState /** - * Content state + * Loading state + * + * @property onExploreClick lambda be invoke when explore button was clicked + */ + data class Loading(val onExploreClick: () -> Unit) : ContentState( + items = flowOf( + PagingData.from( + listOf( + TxHistoryItemState.Title(onExploreClick = onExploreClick), + TxHistoryItemState.Transaction(state = TransactionState.Loading), + ), + ), + ), + ) + + /** + * Wallet transaction history state with loading transactions + * + * @property itemsCount count of loading transactions + */ + data class ContentWithLoadingItems(val itemsCount: Int) : ContentState( + items = flowOf( + value = PagingData.from( + data = buildList(capacity = itemsCount) { + add(TxHistoryItemState.Transaction(state = TransactionState.Loading)) + }, + ), + ), + ) + + /** + * Wallet transaction history state with content * * @property items content items */ diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt index cd97249197..9289845a10 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt @@ -1,7 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.state.factory import androidx.paging.PagingData -import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.core.ui.components.marketprice.MarketPriceBlockState import com.tangem.domain.common.CardTypesResolver import com.tangem.domain.common.util.cardTypesResolver @@ -122,7 +121,7 @@ internal class WalletSkeletonStateConverter( } // TODO: [REDACTED_JIRA] - private fun getButtons(): ImmutableList { + private fun getButtons(): ImmutableList { return persistentListOf( WalletManageButton.Buy(onClick = {}), WalletManageButton.Send(onClick = {}), @@ -130,8 +129,6 @@ internal class WalletSkeletonStateConverter( WalletManageButton.Exchange(onClick = {}), WalletManageButton.CopyAddress(onClick = {}), ) - .map(WalletManageButton::config) - .toImmutableList() } data class SkeletonModel( diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt index 69a67bea5e..4d31745689 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt @@ -3,13 +3,12 @@ package com.tangem.feature.wallet.presentation.wallet.state.factory import androidx.paging.PagingData import arrow.core.Either import com.tangem.common.Provider -import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.domain.common.CardTypesResolver import com.tangem.domain.tokens.error.TokenListError import com.tangem.domain.tokens.model.TokenList +import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.domain.txhistory.models.TxHistoryStateError -import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.wallets.models.UserWallet import com.tangem.feature.wallet.presentation.wallet.state.WalletLoading import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState @@ -24,7 +23,6 @@ import com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory.Wal import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf -import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.Flow /** @@ -155,7 +153,7 @@ internal class WalletStateFactory( } // TODO: [REDACTED_JIRA] - private fun getButtons(): ImmutableList { + private fun getButtons(): ImmutableList { return persistentListOf( WalletManageButton.Buy(onClick = {}), WalletManageButton.Send(onClick = {}), @@ -163,7 +161,5 @@ internal class WalletStateFactory( WalletManageButton.Exchange(onClick = {}), WalletManageButton.CopyAddress(onClick = {}), ) - .map(WalletManageButton::config) - .toImmutableList() } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadedTxHistoryConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadedTxHistoryConverter.kt index 1364a89682..801c6556a2 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadedTxHistoryConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadedTxHistoryConverter.kt @@ -3,11 +3,10 @@ package com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory import androidx.paging.PagingData import arrow.core.Either import com.tangem.common.Provider -import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.core.ui.components.marketprice.MarketPriceBlockState import com.tangem.domain.common.CardTypesResolver -import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.domain.txhistory.models.TxHistoryItem +import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState import com.tangem.feature.wallet.presentation.wallet.state.WalletStateHolder import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton @@ -16,7 +15,6 @@ import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickInten import com.tangem.utils.converter.Converter import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf -import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.Flow /** @@ -78,7 +76,7 @@ internal class WalletLoadedTxHistoryConverter( } // TODO: [REDACTED_JIRA] - private fun getButtons(): ImmutableList { + private fun getButtons(): ImmutableList { return persistentListOf( WalletManageButton.Buy(onClick = {}), WalletManageButton.Send(onClick = {}), @@ -86,8 +84,6 @@ internal class WalletLoadedTxHistoryConverter( WalletManageButton.Exchange(onClick = {}), WalletManageButton.CopyAddress(onClick = {}), ) - .map(WalletManageButton::config) - .toImmutableList() } private fun getLoadingMarketPriceBlockState(): MarketPriceBlockState { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadingTxHistoryConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadingTxHistoryConverter.kt index 8ea55731fd..a43a3f8355 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadingTxHistoryConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletLoadingTxHistoryConverter.kt @@ -3,7 +3,6 @@ package com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory import androidx.paging.PagingData import arrow.core.Either import com.tangem.common.Provider -import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.core.ui.components.marketprice.MarketPriceBlockState import com.tangem.core.ui.components.transactions.TransactionState import com.tangem.domain.common.CardTypesResolver @@ -16,7 +15,6 @@ import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickInten import com.tangem.utils.converter.Converter import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf -import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.flowOf /** @@ -85,7 +83,7 @@ internal class WalletLoadingTxHistoryConverter( } // TODO: [REDACTED_JIRA] - private fun getButtons(): ImmutableList { + private fun getButtons(): ImmutableList { return persistentListOf( WalletManageButton.Buy(onClick = {}), WalletManageButton.Send(onClick = {}), @@ -93,8 +91,6 @@ internal class WalletLoadingTxHistoryConverter( WalletManageButton.Exchange(onClick = {}), WalletManageButton.CopyAddress(onClick = {}), ) - .map(WalletManageButton::config) - .toImmutableList() } private fun getLoadingMarketPriceBlockState(): MarketPriceBlockState { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/WalletsList.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/WalletsList.kt index b2505603a2..dcae40e426 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/WalletsList.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/WalletsList.kt @@ -46,7 +46,12 @@ internal fun WalletsList(config: WalletsListConfig, lazyListState: LazyListState flingBehavior = rememberSnapFlingBehavior(lazyListState = lazyListState), ) { items(items = config.wallets, key = { it.id.stringValue }) { state -> - WalletCard(state = state, modifier = Modifier.width(itemWidth)) + WalletCard( + state = state, + modifier = Modifier + .animateItemPlacement() + .width(itemWidth), + ) } } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyContent.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyContent.kt index 331d8de5dd..88112d5865 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyContent.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyContent.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.ui.Modifier @@ -14,6 +15,7 @@ import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletConten * [REDACTED_AUTHOR] */ +@OptIn(ExperimentalFoundationApi::class) internal fun LazyListScope.tokensListItems(state: WalletTokensListState, modifier: Modifier = Modifier) { itemsIndexed( items = state.items, @@ -21,10 +23,12 @@ internal fun LazyListScope.tokensListItems(state: WalletTokensListState, modifie itemContent = { index, item -> MultiCurrencyContentItem( state = item, - modifier = modifier.walletContentItemDecoration( - currentIndex = index, - lastIndex = state.items.lastIndex, - ), + modifier = modifier + .animateItemPlacement() + .walletContentItemDecoration( + currentIndex = index, + lastIndex = state.items.lastIndex, + ), ) }, ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyContentItem.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyContentItem.kt index 3cdfd7517d..a9ac43d4ab 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyContentItem.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyContentItem.kt @@ -2,6 +2,7 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrenc import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.tangem.core.ui.extensions.resolveReference import com.tangem.feature.wallet.presentation.common.component.NetworkGroupItem import com.tangem.feature.wallet.presentation.common.component.TokenItem import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTokensListState @@ -18,7 +19,7 @@ import com.tangem.feature.wallet.presentation.wallet.state.components.WalletToke internal fun MultiCurrencyContentItem(state: WalletTokensListState.TokensListItemState, modifier: Modifier = Modifier) { when (state) { is WalletTokensListState.TokensListItemState.NetworkGroupTitle -> { - NetworkGroupItem(networkName = state.networkName, modifier = modifier) + NetworkGroupItem(networkName = state.value.resolveReference(), modifier = modifier) } is WalletTokensListState.TokensListItemState.Token -> { TokenItem(state = state.state, modifier = modifier) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyOrganizeButton.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyOrganizeButton.kt index a8fb1add43..a995ca2715 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyOrganizeButton.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/multicurrency/MultiCurrencyOrganizeButton.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.ui.Modifier @@ -11,6 +12,7 @@ import androidx.compose.ui.Modifier * [REDACTED_AUTHOR] */ +@OptIn(ExperimentalFoundationApi::class) internal fun LazyListScope.organizeButton(onClick: (() -> Unit)?, modifier: Modifier = Modifier) { - item { OrganizeTokensButton(onClick = onClick, modifier = modifier) } + item { OrganizeTokensButton(onClick = onClick, modifier = modifier.animateItemPlacement()) } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyContent.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyContent.kt index d70b42ab44..3d7d9de32a 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyContent.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyContent.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyListScope @@ -52,6 +53,7 @@ internal fun LazyListScope.txHistoryItems( } } +@OptIn(ExperimentalFoundationApi::class) private fun LazyListScope.contentItems( txHistoryItems: LazyPagingItems, modifier: Modifier = Modifier, @@ -64,20 +66,24 @@ private fun LazyListScope.contentItems( SingleCurrencyContentItem( state = item, - modifier = modifier.walletContentItemDecoration( - currentIndex = index, - lastIndex = txHistoryItems.itemSnapshotList.lastIndex, - ), + modifier = modifier + .animateItemPlacement() + .walletContentItemDecoration( + currentIndex = index, + lastIndex = txHistoryItems.itemSnapshotList.lastIndex, + ), ) }, ) } +@OptIn(ExperimentalFoundationApi::class) private fun LazyListScope.nonContentItem(state: EmptyTransactionsBlockState, modifier: Modifier = Modifier) { item { EmptyTransactionBlock( state = state, modifier = modifier + .animateItemPlacement() .padding(horizontal = TangemTheme.dimens.spacing16, vertical = TangemTheme.dimens.spacing12) .fillMaxWidth(), ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyControlButtons.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyControlButtons.kt index d118b99fbc..f88ea6d07f 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyControlButtons.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyControlButtons.kt @@ -1,12 +1,14 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.ui.Modifier import com.tangem.core.ui.components.buttons.HorizontalActionChips -import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.core.ui.res.TangemTheme +import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.toImmutableList /** * Single currency control buttons. Like, "Buy", "Sell", etc @@ -16,11 +18,12 @@ import kotlinx.collections.immutable.ImmutableList * [REDACTED_AUTHOR] */ -internal fun LazyListScope.controlButtons(configs: ImmutableList, modifier: Modifier = Modifier) { +@OptIn(ExperimentalFoundationApi::class) +internal fun LazyListScope.controlButtons(configs: ImmutableList, modifier: Modifier = Modifier) { item { HorizontalActionChips( - buttons = configs, - modifier = modifier, + buttons = configs.map(WalletManageButton::config).toImmutableList(), + modifier = modifier.animateItemPlacement(), contentPadding = PaddingValues(horizontal = TangemTheme.dimens.spacing16), ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyMarketPriceBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyMarketPriceBlock.kt index 5e8d88c954..b839d42baf 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyMarketPriceBlock.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/SingleCurrencyMarketPriceBlock.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.ui.Modifier import com.tangem.core.ui.components.marketprice.MarketPriceBlock @@ -13,6 +14,7 @@ import com.tangem.core.ui.components.marketprice.MarketPriceBlockState * [REDACTED_AUTHOR] */ +@OptIn(ExperimentalFoundationApi::class) internal fun LazyListScope.marketPriceBlock(state: MarketPriceBlockState, modifier: Modifier = Modifier) { - item { MarketPriceBlock(state = state, modifier = modifier) } + item { MarketPriceBlock(state = state, modifier = modifier.animateItemPlacement()) } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/utils/TokenListToContentItemsConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/utils/TokenListToContentItemsConverter.kt index e76e7535f6..d20d628c57 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/utils/TokenListToContentItemsConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/utils/TokenListToContentItemsConverter.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.utils +import com.tangem.core.ui.extensions.TextReference import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.NetworkGroup import com.tangem.domain.tokens.model.TokenList @@ -53,7 +54,7 @@ internal class TokenListToContentItemsConverter( } private fun MutableList.addGroup(group: NetworkGroup): List { - this.add(TokensListItemState.NetworkGroupTitle(group.network.name)) + this.add(TokensListItemState.NetworkGroupTitle(TextReference.Str(group.network.name))) group.currencies.forEach { token -> this.addToken(token)