Updated on 2026-08-14
This commit is contained in:
parent
6a15cfd2e4
commit
294c7139ee
31 changed files with 169 additions and 96 deletions
|
|
@ -397,6 +397,7 @@ internal object WalletPreviewData {
|
|||
tokenActionsBottomSheet = actionsBottomSheet,
|
||||
onManageTokensClick = {},
|
||||
event = consumedEvent(),
|
||||
isBalanceHidden = false,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -451,6 +452,7 @@ internal object WalletPreviewData {
|
|||
),
|
||||
),
|
||||
event = consumedEvent(),
|
||||
isBalanceHidden = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ internal sealed class WalletMultiCurrencyState : WalletState.ContentState() {
|
|||
override val bottomSheetConfig: TangemBottomSheetConfig?,
|
||||
override val tokensListState: WalletTokensListState,
|
||||
override val event: StateEvent<WalletEvent> = consumedEvent(),
|
||||
override val isBalanceHidden: Boolean,
|
||||
val tokenActionsBottomSheet: ActionsBottomSheetConfig?,
|
||||
val onManageTokensClick: () -> Unit,
|
||||
) : WalletMultiCurrencyState()
|
||||
|
|
@ -41,6 +42,7 @@ internal sealed class WalletMultiCurrencyState : WalletState.ContentState() {
|
|||
override val isBottomSheetShow: Boolean = false,
|
||||
override val onBottomSheetDismiss: () -> Unit = {},
|
||||
override val event: StateEvent<WalletEvent> = consumedEvent(),
|
||||
override val isBalanceHidden: Boolean,
|
||||
) : WalletMultiCurrencyState(), WalletLockedState {
|
||||
|
||||
override val notifications = persistentListOf(
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ internal sealed class WalletSingleCurrencyState : WalletState.ContentState() {
|
|||
override val buttons: PersistentList<WalletManageButton>,
|
||||
override val txHistoryState: TxHistoryState,
|
||||
override val event: StateEvent<WalletEvent> = consumedEvent(),
|
||||
override val isBalanceHidden: Boolean,
|
||||
val marketPriceBlockState: MarketPriceBlockState,
|
||||
) : WalletSingleCurrencyState()
|
||||
|
||||
|
|
@ -53,6 +54,7 @@ internal sealed class WalletSingleCurrencyState : WalletState.ContentState() {
|
|||
override val isBottomSheetShow: Boolean = false,
|
||||
override val onBottomSheetDismiss: () -> Unit = {},
|
||||
override val event: StateEvent<WalletEvent> = consumedEvent(),
|
||||
override val isBalanceHidden: Boolean,
|
||||
val onExploreClick: () -> Unit,
|
||||
) : WalletSingleCurrencyState(), WalletLockedState {
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ internal sealed class WalletState {
|
|||
/** State event */
|
||||
abstract val event: StateEvent<WalletEvent>
|
||||
|
||||
/** Whether balance should be hidden */
|
||||
abstract val isBalanceHidden: Boolean
|
||||
|
||||
/**
|
||||
* Util function that allow to make a copy
|
||||
*
|
||||
|
|
@ -50,6 +53,7 @@ internal sealed class WalletState {
|
|||
walletsListConfig: WalletsListConfig = this.walletsListConfig,
|
||||
pullToRefreshConfig: WalletPullToRefreshConfig = this.pullToRefreshConfig,
|
||||
event: StateEvent<WalletEvent> = this.event,
|
||||
isBalanceHidden: Boolean = this.isBalanceHidden,
|
||||
): ContentState {
|
||||
return when (this) {
|
||||
is WalletMultiCurrencyState.Content -> {
|
||||
|
|
@ -57,6 +61,7 @@ internal sealed class WalletState {
|
|||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig,
|
||||
event = event,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
is WalletMultiCurrencyState.Locked -> {
|
||||
|
|
@ -64,6 +69,7 @@ internal sealed class WalletState {
|
|||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig,
|
||||
event = event,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
is WalletSingleCurrencyState.Content -> {
|
||||
|
|
@ -71,6 +77,7 @@ internal sealed class WalletState {
|
|||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig,
|
||||
event = event,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
is WalletSingleCurrencyState.Locked -> {
|
||||
|
|
@ -78,6 +85,7 @@ internal sealed class WalletState {
|
|||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig,
|
||||
event = event,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ internal class WalletLockedConverter(
|
|||
onUnlockWalletsNotificationClick = clickIntents::onUnlockWalletNotificationClick,
|
||||
onUnlockClick = clickIntents::onUnlockWalletClick,
|
||||
onScanClick = clickIntents::onScanToUnlockWalletClick,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +52,7 @@ internal class WalletLockedConverter(
|
|||
onUnlockClick = clickIntents::onUnlockWalletClick,
|
||||
onScanClick = clickIntents::onScanToUnlockWalletClick,
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ internal class WalletSkeletonStateConverter(
|
|||
bottomSheetConfig = null,
|
||||
tokenActionsBottomSheet = null,
|
||||
onManageTokensClick = clickIntents::onManageTokensClick,
|
||||
isBalanceHidden = true,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -73,6 +74,7 @@ internal class WalletSkeletonStateConverter(
|
|||
value = TxHistoryState.getDefaultLoadingTransactions(clickIntents::onExploreClick),
|
||||
),
|
||||
),
|
||||
isBalanceHidden = true,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ internal class WalletStateFactory(
|
|||
private val loadedTxHistoryConverter by lazy {
|
||||
WalletLoadedTxHistoryConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
isBalanceHiddenProvider = isBalanceHiddenProvider,
|
||||
currentCardTypeResolverProvider = currentCardTypeResolverProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ internal class WalletsUnlockStateConverter(
|
|||
bottomSheetConfig = null,
|
||||
tokenActionsBottomSheet = null,
|
||||
onManageTokensClick = clickIntents::onManageTokensClick,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +75,7 @@ internal class WalletsUnlockStateConverter(
|
|||
value = TxHistoryState.getDefaultLoadingTransactions(clickIntents::onExploreClick),
|
||||
),
|
||||
),
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ internal class WalletLoadedTxHistoryConverter(
|
|||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val currentCardTypeResolverProvider: Provider<CardTypesResolver>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val isBalanceHiddenProvider: Provider<Boolean>,
|
||||
) : Converter<Either<TxHistoryListError, Flow<PagingData<TxHistoryItem>>>, WalletState> {
|
||||
|
||||
private val walletTxHistoryItemFlowConverter by lazy {
|
||||
|
|
@ -34,6 +35,7 @@ internal class WalletLoadedTxHistoryConverter(
|
|||
currentStateProvider = currentStateProvider,
|
||||
blockchain = currentCardTypeResolverProvider().getBlockchain(),
|
||||
clickIntents = clickIntents,
|
||||
isBalanceHiddenProvider = isBalanceHiddenProvider,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,12 +35,17 @@ import org.joda.time.DateTimeZone
|
|||
*/
|
||||
internal class WalletTxHistoryItemFlowConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val isBalanceHiddenProvider: Provider<Boolean>,
|
||||
private val blockchain: Blockchain,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<Flow<PagingData<TxHistoryItem>>, TxHistoryState?> {
|
||||
|
||||
private val txHistoryItemConverter by lazy {
|
||||
WalletTxHistoryTransactionStateConverter(symbol = blockchain.currency, decimals = blockchain.decimals())
|
||||
WalletTxHistoryTransactionStateConverter(
|
||||
symbol = blockchain.currency,
|
||||
decimals = blockchain.decimals(),
|
||||
isBalanceHiddenProvider = isBalanceHiddenProvider,
|
||||
)
|
||||
}
|
||||
|
||||
override fun convert(value: Flow<PagingData<TxHistoryItem>>): TxHistoryState? {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory
|
||||
|
||||
import com.tangem.common.Provider
|
||||
import com.tangem.common.Strings
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
|
|
@ -11,6 +13,7 @@ import com.tangem.utils.toFormattedCurrencyString
|
|||
class WalletTxHistoryTransactionStateConverter(
|
||||
private val symbol: String,
|
||||
private val decimals: Int,
|
||||
private val isBalanceHiddenProvider: Provider<Boolean>,
|
||||
) : Converter<TxHistoryItem, TransactionState> {
|
||||
|
||||
override fun convert(value: TxHistoryItem): TransactionState {
|
||||
|
|
@ -26,7 +29,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
TxHistoryItem.TransactionType.Deposit -> TransactionState.Custom(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -36,7 +39,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
TxHistoryItem.TransactionType.Submit -> TransactionState.Custom(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -46,7 +49,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
TxHistoryItem.TransactionType.Supply -> TransactionState.Custom(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -56,7 +59,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
TxHistoryItem.TransactionType.Unoswap -> TransactionState.Custom(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -66,7 +69,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
TxHistoryItem.TransactionType.Withdraw -> TransactionState.Custom(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -76,7 +79,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
is TxHistoryItem.TransactionType.Custom -> TransactionState.Custom(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -90,7 +93,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
return TransactionState.Transfer(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -101,7 +104,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
return TransactionState.Approve(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -111,7 +114,7 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
return TransactionState.Swap(
|
||||
txHash = item.txHash,
|
||||
address = item.direction.extractAddress(),
|
||||
amount = item.extractFormattedCryptoBalance(),
|
||||
amount = item.getAmount(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.direction.toUiDirection(),
|
||||
|
|
@ -142,7 +145,9 @@ class WalletTxHistoryTransactionStateConverter(
|
|||
is TxHistoryItem.TransactionDirection.Outgoing -> TransactionState.Content.Direction.OUTGOING
|
||||
}
|
||||
|
||||
private fun TxHistoryItem.extractFormattedCryptoBalance(): String {
|
||||
private fun TxHistoryItem.getAmount(): String {
|
||||
if (isBalanceHiddenProvider()) return Strings.STARS
|
||||
|
||||
val prefix = when (direction) {
|
||||
is TxHistoryItem.TransactionDirection.Incoming -> "+"
|
||||
is TxHistoryItem.TransactionDirection.Outgoing -> "-"
|
||||
|
|
|
|||
|
|
@ -142,7 +142,12 @@ private fun WalletContent(
|
|||
marketPriceBlock(state = state.marketPriceBlockState, modifier = itemModifier)
|
||||
}
|
||||
|
||||
contentItems(state = state, txHistoryItems = txHistoryItems, modifier = movableItemModifier)
|
||||
contentItems(
|
||||
state = state,
|
||||
txHistoryItems = txHistoryItems,
|
||||
isBalanceHidden = state.isBalanceHidden,
|
||||
modifier = movableItemModifier,
|
||||
)
|
||||
|
||||
if (state is WalletMultiCurrencyState) {
|
||||
val contentTokenListState = state.tokensListState as? WalletTokensListState.ContentState
|
||||
|
|
|
|||
|
|
@ -22,10 +22,11 @@ import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency
|
|||
internal fun LazyListScope.contentItems(
|
||||
state: WalletState.ContentState,
|
||||
txHistoryItems: LazyPagingItems<TxHistoryState.TxHistoryItemState>?,
|
||||
isBalanceHidden: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
when (state) {
|
||||
is WalletMultiCurrencyState -> tokensListItems(state.tokensListState, modifier)
|
||||
is WalletSingleCurrencyState -> txHistoryItems(state.txHistoryState, txHistoryItems, modifier)
|
||||
is WalletSingleCurrencyState -> txHistoryItems(state.txHistoryState, txHistoryItems, isBalanceHidden, modifier)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue