Updated on 2026-08-14
This commit is contained in:
parent
282cc27cb4
commit
6903f532ab
20 changed files with 109 additions and 130 deletions
|
|
@ -7,12 +7,14 @@ plugins {
|
|||
dependencies {
|
||||
/** AndroidX libraries */
|
||||
implementation(deps.androidx.fragment.ktx)
|
||||
implementation(deps.androidx.paging.runtime)
|
||||
|
||||
/** Compose */
|
||||
implementation(deps.compose.constraintLayout)
|
||||
implementation(deps.compose.foundation)
|
||||
implementation(deps.compose.material)
|
||||
implementation(deps.compose.material3)
|
||||
implementation(deps.compose.paging)
|
||||
implementation(deps.compose.ui.tooling)
|
||||
|
||||
/** Other libraries */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.ui.decorations
|
||||
package com.tangem.core.ui.components
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
|
|
@ -7,10 +7,7 @@ import androidx.compose.ui.composed
|
|||
import androidx.compose.ui.draw.clip
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal fun Modifier.walletContentItemDecoration(currentIndex: Int, lastIndex: Int): Modifier = composed {
|
||||
fun Modifier.walletContentItemDecoration(currentIndex: Int, lastIndex: Int): Modifier = composed {
|
||||
val modifierWithHorizontalPadding = this.padding(horizontal = TangemTheme.dimens.spacing16)
|
||||
val isSingleItem = currentIndex == 0 && lastIndex == 0
|
||||
when {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency
|
||||
package com.tangem.core.ui.components.transactions
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
|
@ -9,42 +9,34 @@ import androidx.paging.compose.LazyPagingItems
|
|||
import androidx.paging.compose.itemsIndexed
|
||||
import com.tangem.core.ui.components.transactions.empty.EmptyTransactionBlock
|
||||
import com.tangem.core.ui.components.transactions.empty.EmptyTransactionsBlockState
|
||||
import com.tangem.core.ui.components.walletContentItemDecoration
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletContentItemDecoration
|
||||
|
||||
/**
|
||||
* LazyList extension for transactions history [WalletTxHistoryState]
|
||||
*
|
||||
* @param state state
|
||||
* @param txHistoryItems transactions
|
||||
* @param modifier modifier
|
||||
*/
|
||||
internal fun LazyListScope.txHistoryItems(
|
||||
state: WalletTxHistoryState,
|
||||
txHistoryItems: LazyPagingItems<WalletTxHistoryState.TxHistoryItemState>?,
|
||||
fun LazyListScope.txHistoryItems(
|
||||
state: TxHistoryState,
|
||||
txHistoryItems: LazyPagingItems<TxHistoryState.TxHistoryItemState>?,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
when (state) {
|
||||
is WalletTxHistoryState.ContentState -> {
|
||||
is TxHistoryState.ContentState -> {
|
||||
contentItems(
|
||||
txHistoryItems = requireNotNull(txHistoryItems),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
is WalletTxHistoryState.Empty -> {
|
||||
is TxHistoryState.Empty -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.Empty(onClick = state.onBuyClick),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
is WalletTxHistoryState.Error -> {
|
||||
is TxHistoryState.Error -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.FailedToLoad(onClick = state.onReloadClick),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
is WalletTxHistoryState.NotSupported -> {
|
||||
is TxHistoryState.NotSupported -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.NotImplemented(onClick = state.onExploreClick),
|
||||
modifier = modifier,
|
||||
|
|
@ -55,7 +47,7 @@ internal fun LazyListScope.txHistoryItems(
|
|||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
private fun LazyListScope.contentItems(
|
||||
txHistoryItems: LazyPagingItems<WalletTxHistoryState.TxHistoryItemState>,
|
||||
txHistoryItems: LazyPagingItems<TxHistoryState.TxHistoryItemState>,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
itemsIndexed(
|
||||
|
|
@ -64,7 +56,7 @@ private fun LazyListScope.contentItems(
|
|||
itemContent = { index, item ->
|
||||
if (item == null) return@itemsIndexed
|
||||
|
||||
SingleCurrencyContentItem(
|
||||
TxHistoryContentItem(
|
||||
state = item,
|
||||
modifier = modifier
|
||||
.animateItemPlacement()
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.tangem.core.ui.components.transactions
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
internal fun TxHistoryContentItem (state: TxHistoryState.TxHistoryItemState, modifier: Modifier = Modifier) {
|
||||
when (state) {
|
||||
is TxHistoryState.TxHistoryItemState.GroupTitle -> {
|
||||
TxHistoryGroupTitle(config = state, modifier = modifier)
|
||||
}
|
||||
is TxHistoryState.TxHistoryItemState.Title -> {
|
||||
TxHistoryTitle(config = state, modifier = modifier)
|
||||
}
|
||||
is TxHistoryState.TxHistoryItemState.Transaction -> {
|
||||
Transaction(state = state.state, modifier = modifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency
|
||||
package com.tangem.core.ui.components.transactions
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
|
@ -9,16 +9,9 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState.TxHistoryItemState
|
||||
|
||||
/**
|
||||
* Transactions block group title
|
||||
*
|
||||
* @param config config
|
||||
* @param modifier modifier
|
||||
*/
|
||||
@Composable
|
||||
internal fun TxHistoryGroupTitle(config: TxHistoryItemState.GroupTitle, modifier: Modifier = Modifier) {
|
||||
internal fun TxHistoryGroupTitle(config: TxHistoryState.TxHistoryItemState.GroupTitle, modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = config.title,
|
||||
modifier = modifier
|
||||
|
|
@ -38,7 +31,7 @@ internal fun TxHistoryGroupTitle(config: TxHistoryItemState.GroupTitle, modifier
|
|||
@Composable
|
||||
private fun Preview_TransactionsBlockGroupTitle_Light() {
|
||||
TangemTheme(isDark = false) {
|
||||
TxHistoryGroupTitle(config = TxHistoryItemState.GroupTitle(title = "Today"))
|
||||
TxHistoryGroupTitle(config = TxHistoryState.TxHistoryItemState.GroupTitle(title = "Today"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +39,6 @@ private fun Preview_TransactionsBlockGroupTitle_Light() {
|
|||
@Composable
|
||||
private fun Preview_TransactionsBlockGroupTitle_Dark() {
|
||||
TangemTheme(isDark = true) {
|
||||
TxHistoryGroupTitle(config = TxHistoryItemState.GroupTitle(title = "Today"))
|
||||
TxHistoryGroupTitle(config = TxHistoryState.TxHistoryItemState.GroupTitle(title = "Today"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,18 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
package com.tangem.core.ui.components.transactions
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.core.ui.components.transactions.TransactionState
|
||||
import com.tangem.core.ui.components.wallet.WalletLockedContentState
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
|
||||
/**
|
||||
* Wallet transaction history state
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal sealed interface WalletTxHistoryState {
|
||||
sealed interface TxHistoryState {
|
||||
|
||||
/**
|
||||
* Wallet transaction history state with content
|
||||
*
|
||||
* @property items content items
|
||||
*/
|
||||
sealed class ContentState(open val items: Flow<PagingData<TxHistoryItemState>>) : WalletTxHistoryState
|
||||
sealed class ContentState(open val items: Flow<PagingData<TxHistoryItemState>>) : TxHistoryState
|
||||
|
||||
/**
|
||||
* Loading state
|
||||
|
|
@ -80,21 +75,21 @@ internal sealed interface WalletTxHistoryState {
|
|||
*
|
||||
* @property onBuyClick lambda be invoke when buy button was clicked
|
||||
*/
|
||||
data class Empty(val onBuyClick: () -> Unit) : WalletTxHistoryState
|
||||
data class Empty(val onBuyClick: () -> Unit) : TxHistoryState
|
||||
|
||||
/**
|
||||
* Not supported tx history state
|
||||
*
|
||||
* @property onExploreClick lambda be invoke when explore button was clicked
|
||||
*/
|
||||
data class NotSupported(val onExploreClick: () -> Unit) : WalletTxHistoryState
|
||||
data class NotSupported(val onExploreClick: () -> Unit) : TxHistoryState
|
||||
|
||||
/**
|
||||
* Error state
|
||||
*
|
||||
* @property onReloadClick lambda be invoke when reload button was clicked
|
||||
*/
|
||||
data class Error(val onReloadClick: () -> Unit) : WalletTxHistoryState
|
||||
data class Error(val onReloadClick: () -> Unit) : TxHistoryState
|
||||
|
||||
/** Transactions history item state */
|
||||
sealed interface TxHistoryItemState {
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency
|
||||
package com.tangem.core.ui.components.transactions
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -11,17 +10,10 @@ import androidx.compose.ui.res.painterResource
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState.TxHistoryItemState
|
||||
import com.tangem.core.ui.R
|
||||
|
||||
/**
|
||||
* Transactions block title
|
||||
*
|
||||
* @param config config
|
||||
* @param modifier modifier
|
||||
*/
|
||||
@Composable
|
||||
internal fun TxHistoryTitle(config: TxHistoryItemState.Title, modifier: Modifier = Modifier) {
|
||||
internal fun TxHistoryTitle(config: TxHistoryState.TxHistoryItemState.Title, modifier: Modifier = Modifier) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.background(TangemTheme.colors.background.primary)
|
||||
|
|
@ -40,7 +32,7 @@ internal fun TxHistoryTitle(config: TxHistoryItemState.Title, modifier: Modifier
|
|||
modifier = Modifier.clickable(onClick = config.onExploreClick),
|
||||
horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing4),
|
||||
) {
|
||||
Icon(
|
||||
androidx.compose.material3.Icon(
|
||||
painter = painterResource(id = R.drawable.ic_compass_24),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(size = TangemTheme.dimens.size18),
|
||||
|
|
@ -59,7 +51,7 @@ internal fun TxHistoryTitle(config: TxHistoryItemState.Title, modifier: Modifier
|
|||
@Composable
|
||||
private fun Preview_TransactionsBlockTitle_Light() {
|
||||
TangemTheme(isDark = false) {
|
||||
TxHistoryTitle(config = TxHistoryItemState.Title(onExploreClick = {}))
|
||||
TxHistoryTitle(config = TxHistoryState.TxHistoryItemState.Title(onExploreClick = {}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +59,6 @@ private fun Preview_TransactionsBlockTitle_Light() {
|
|||
@Composable
|
||||
private fun Preview_TransactionsBlockTitle_Dark() {
|
||||
TangemTheme(isDark = true) {
|
||||
TxHistoryTitle(config = TxHistoryItemState.Title(onExploreClick = {}))
|
||||
TxHistoryTitle(config = TxHistoryState.TxHistoryItemState.Title(onExploreClick = {}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.tangem.core.ui.components.wallet
|
||||
|
||||
/**
|
||||
* Wallet locked content state.
|
||||
* It allows to divide the locked content of multi-currency and single-currency wallets.
|
||||
*/
|
||||
interface WalletLockedContentState
|
||||
|
|
@ -6,6 +6,7 @@ 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.core.ui.components.transactions.TxHistoryState
|
||||
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
|
||||
|
|
@ -347,21 +348,21 @@ internal object WalletPreviewData {
|
|||
type = PriceChangeConfig.Type.UP,
|
||||
),
|
||||
),
|
||||
txHistoryState = WalletTxHistoryState.Content(
|
||||
txHistoryState = TxHistoryState.Content(
|
||||
flowOf(
|
||||
PagingData.from(
|
||||
listOf(
|
||||
WalletTxHistoryState.TxHistoryItemState.Title(onExploreClick = {}),
|
||||
WalletTxHistoryState.TxHistoryItemState.GroupTitle("Today"),
|
||||
WalletTxHistoryState.TxHistoryItemState.Transaction(
|
||||
TxHistoryState.TxHistoryItemState.Title(onExploreClick = {}),
|
||||
TxHistoryState.TxHistoryItemState.GroupTitle("Today"),
|
||||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Sending(
|
||||
address = "33BddS...ga2B",
|
||||
amount = "-0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
),
|
||||
WalletTxHistoryState.TxHistoryItemState.GroupTitle("Yesterday"),
|
||||
WalletTxHistoryState.TxHistoryItemState.Transaction(
|
||||
TxHistoryState.TxHistoryItemState.GroupTitle("Yesterday"),
|
||||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Sending(
|
||||
address = "33BddS...ga2B",
|
||||
amount = "-0.500913 BTC",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.transactions.TxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.*
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -19,7 +20,7 @@ internal sealed class WalletSingleCurrencyState : WalletState.ContentState() {
|
|||
abstract val marketPriceBlockState: MarketPriceBlockState?
|
||||
|
||||
/** Transactions history state */
|
||||
abstract val txHistoryState: WalletTxHistoryState
|
||||
abstract val txHistoryState: TxHistoryState
|
||||
|
||||
data class Content(
|
||||
override val onBackClick: () -> Unit,
|
||||
|
|
@ -30,7 +31,7 @@ internal sealed class WalletSingleCurrencyState : WalletState.ContentState() {
|
|||
override val bottomSheetConfig: WalletBottomSheetConfig?,
|
||||
override val buttons: ImmutableList<WalletManageButton>,
|
||||
override val marketPriceBlockState: MarketPriceBlockState,
|
||||
override val txHistoryState: WalletTxHistoryState,
|
||||
override val txHistoryState: TxHistoryState,
|
||||
) : WalletSingleCurrencyState()
|
||||
|
||||
data class Locked(
|
||||
|
|
@ -62,6 +63,6 @@ internal sealed class WalletSingleCurrencyState : WalletState.ContentState() {
|
|||
|
||||
override val marketPriceBlockState = null
|
||||
|
||||
override val txHistoryState: WalletTxHistoryState = WalletTxHistoryState.Locked(onExploreClick)
|
||||
override val txHistoryState: TxHistoryState = TxHistoryState.Locked(onExploreClick)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
|
||||
/**
|
||||
* Wallet locked content state.
|
||||
* It allows to divide the locked content of multi-currency and single-currency wallets.
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal sealed interface WalletLockedContentState
|
||||
|
|
@ -2,6 +2,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.core.ui.components.wallet.WalletLockedContentState
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenItemState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.tangem.feature.wallet.presentation.wallet.state.factory
|
|||
|
||||
import com.tangem.common.Provider
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.transactions.TxHistoryState
|
||||
import com.tangem.domain.common.CardTypesResolver
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
|
|
@ -62,7 +64,7 @@ internal class WalletSkeletonStateConverter(
|
|||
bottomSheetConfig = null,
|
||||
buttons = getButtons(),
|
||||
marketPriceBlockState = MarketPriceBlockState.Loading(currencyName = currencyName),
|
||||
txHistoryState = WalletTxHistoryState.Loading(onExploreClick = clickIntents::onExploreClick),
|
||||
txHistoryState = TxHistoryState.Loading(onExploreClick = clickIntents::onExploreClick),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@ 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.TxHistoryState
|
||||
import com.tangem.domain.common.CardTypesResolver
|
||||
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
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
|
|
@ -14,7 +19,7 @@ import com.tangem.utils.converter.Converter
|
|||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/**
|
||||
* Converter from loaded tx history to [WalletTxHistoryState]
|
||||
* Converter from loaded tx history to [TxHistoryState]
|
||||
*
|
||||
* @property currentStateProvider current state provider
|
||||
* @property currentCardTypeResolverProvider current card type resolver provider
|
||||
|
|
@ -43,7 +48,7 @@ internal class WalletLoadedTxHistoryConverter(
|
|||
return requireNotNull(currentStateProvider() as? WalletSingleCurrencyState.Content).copy(
|
||||
txHistoryState = when (error) {
|
||||
is TxHistoryListError.DataError -> {
|
||||
WalletTxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@ package com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory
|
|||
|
||||
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.core.ui.components.transactions.TxHistoryState
|
||||
import com.tangem.domain.common.CardTypesResolver
|
||||
import com.tangem.domain.txhistory.error.TxHistoryStateError
|
||||
import com.tangem.domain.txhistory.models.TxHistoryStateError
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
|
|
@ -30,13 +36,13 @@ internal class WalletLoadingTxHistoryConverter(
|
|||
return requireNotNull(currentStateProvider() as? WalletSingleCurrencyState.Content).copy(
|
||||
txHistoryState = when (error) {
|
||||
is TxHistoryStateError.EmptyTxHistories -> {
|
||||
WalletTxHistoryState.Empty(onBuyClick = clickIntents::onBuyClick)
|
||||
TxHistoryState.Empty(onBuyClick = clickIntents::onBuyClick)
|
||||
}
|
||||
is TxHistoryStateError.DataError -> {
|
||||
WalletTxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick)
|
||||
}
|
||||
is TxHistoryStateError.TxHistoryNotImplemented -> {
|
||||
WalletTxHistoryState.NotSupported(onExploreClick = clickIntents::onExploreClick)
|
||||
TxHistoryState.NotSupported(onExploreClick = clickIntents::onExploreClick)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import android.text.format.DateUtils
|
|||
import androidx.paging.*
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.core.ui.components.transactions.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.TxHistoryState
|
||||
import com.tangem.core.ui.components.transactions.TxHistoryState.TxHistoryItemState
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState.TxHistoryItemState
|
||||
|
|
@ -22,7 +24,7 @@ import java.math.BigDecimal
|
|||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Convert from [Flow] of [TxHistoryItem] to [WalletTxHistoryState]
|
||||
* Convert from [Flow] of [TxHistoryItem] to [TxHistoryState]
|
||||
*
|
||||
* @property blockchain blockchain of transactions history
|
||||
* @property clickIntents screen click intents
|
||||
|
|
@ -32,7 +34,7 @@ import java.util.Locale
|
|||
internal class WalletTxHistoryItemFlowConverter(
|
||||
private val blockchain: Blockchain,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<Flow<PagingData<TxHistoryItem>>, WalletTxHistoryState> {
|
||||
) : Converter<Flow<PagingData<TxHistoryItem>>, TxHistoryState> {
|
||||
|
||||
/** Example, 2 Aug, 2023 */
|
||||
private val dateFormatter by lazy {
|
||||
|
|
@ -56,8 +58,8 @@ internal class WalletTxHistoryItemFlowConverter(
|
|||
.withLocale(Locale.getDefault())
|
||||
}
|
||||
|
||||
override fun convert(value: Flow<PagingData<TxHistoryItem>>): WalletTxHistoryState {
|
||||
return WalletTxHistoryState.Content(
|
||||
override fun convert(value: Flow<PagingData<TxHistoryItem>>): TxHistoryState {
|
||||
return TxHistoryState.Content(
|
||||
items = value
|
||||
.map { pagingData ->
|
||||
pagingData
|
||||
|
|
@ -163,9 +165,10 @@ internal class WalletTxHistoryItemFlowConverter(
|
|||
if (txHistoryItemState is TxHistoryItemState.Transaction &&
|
||||
txHistoryItemState.state is TransactionState.Content
|
||||
) {
|
||||
val txContent = txHistoryItemState.state as TransactionState.Content
|
||||
txHistoryItemState.copy(
|
||||
state = txHistoryItemState.state.copySealed(
|
||||
timestamp = txHistoryItemState.state.timestamp.toTimeFormat(),
|
||||
state = txContent.copySealed(
|
||||
timestamp = txContent.timestamp.toTimeFormat(),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
|
|
@ -184,7 +187,8 @@ internal class WalletTxHistoryItemFlowConverter(
|
|||
|
||||
private fun TxHistoryItemState?.getTimestamp(): Long? {
|
||||
return if (this is TxHistoryItemState.Transaction && this.state is TransactionState.Content) {
|
||||
requireNotNull(this.state.timestamp.toLongOrNull()) { "Timestamp must be Long type" }
|
||||
val txContent = this.state as TransactionState.Content
|
||||
requireNotNull(txContent.timestamp.toLongOrNull()) { "Timestamp must be Long type" }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import com.tangem.core.ui.components.transactions.TxHistoryState
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.presentation.common.WalletPreviewData
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.WalletsList
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.common.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency.organizeButton
|
||||
|
|
@ -68,9 +68,9 @@ private fun WalletContent(state: WalletState.ContentState) {
|
|||
.pullRefresh(pullRefreshState),
|
||||
) {
|
||||
val txHistoryItems = if (state is WalletSingleCurrencyState &&
|
||||
state.txHistoryState is WalletTxHistoryState.ContentState
|
||||
state.txHistoryState is TxHistoryState.ContentState
|
||||
) {
|
||||
(state.txHistoryState as? WalletTxHistoryState.ContentState)?.items?.collectAsLazyPagingItems()
|
||||
(state.txHistoryState as? TxHistoryState.ContentState)?.items?.collectAsLazyPagingItems()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.common
|
|||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.paging.compose.LazyPagingItems
|
||||
import com.tangem.core.ui.components.transactions.TxHistoryState
|
||||
import com.tangem.core.ui.components.transactions.txHistoryItems
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency.tokensListItems
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.txHistoryItems
|
||||
|
||||
/**
|
||||
* Wallet content
|
||||
|
|
@ -21,7 +21,7 @@ import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrenc
|
|||
*/
|
||||
internal fun LazyListScope.contentItems(
|
||||
state: WalletState.ContentState,
|
||||
txHistoryItems: LazyPagingItems<WalletTxHistoryState.TxHistoryItemState>?,
|
||||
txHistoryItems: LazyPagingItems<TxHistoryState.TxHistoryItemState>?,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
when (state) {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import androidx.compose.foundation.ExperimentalFoundationApi
|
|||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.tangem.core.ui.components.walletContentItemDecoration
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletContentItemDecoration
|
||||
|
||||
/**
|
||||
* LazyList extension for [WalletTokensListState]
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.tangem.core.ui.components.transactions.Transaction
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTxHistoryState
|
||||
|
||||
/**
|
||||
* Single currency content item
|
||||
*
|
||||
* @param state state
|
||||
* @param modifier modifier
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
@Composable
|
||||
internal fun SingleCurrencyContentItem(state: WalletTxHistoryState.TxHistoryItemState, modifier: Modifier = Modifier) {
|
||||
when (state) {
|
||||
is WalletTxHistoryState.TxHistoryItemState.GroupTitle -> {
|
||||
TxHistoryGroupTitle(config = state, modifier = modifier)
|
||||
}
|
||||
is WalletTxHistoryState.TxHistoryItemState.Title -> {
|
||||
TxHistoryTitle(config = state, modifier = modifier)
|
||||
}
|
||||
is WalletTxHistoryState.TxHistoryItemState.Transaction -> {
|
||||
Transaction(state = state.state, modifier = modifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue