diff --git a/common/src/main/java/com/tangem/common/Strings.kt b/common/src/main/java/com/tangem/common/Strings.kt index 402f3daa07..943b0de614 100644 --- a/common/src/main/java/com/tangem/common/Strings.kt +++ b/common/src/main/java/com/tangem/common/Strings.kt @@ -2,5 +2,5 @@ package com.tangem.common object Strings { - const val STARS = "***" + const val STARS = "\u2217\u2217\u2217" } \ No newline at end of file diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index 7814c986a3..4f39028ae4 100644 --- a/core/ui/build.gradle.kts +++ b/core/ui/build.gradle.kts @@ -5,6 +5,9 @@ plugins { } dependencies { + /** Project - Common */ + implementation(projects.common) + /** Project - Domain */ implementation(projects.domain.tokens.models) implementation(projects.domain.appTheme.models) diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/Transaction.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/Transaction.kt index 66ab911a07..283bbf7b89 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/Transaction.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/Transaction.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import androidx.constraintlayout.compose.ConstraintLayout import androidx.constraintlayout.compose.Dimension +import com.tangem.common.Strings import com.tangem.core.ui.R import com.tangem.core.ui.components.CircleShimmer import com.tangem.core.ui.components.RectangleShimmer @@ -33,8 +34,9 @@ import java.util.UUID /** * Transaction component * - * @param state state - * @param modifier modifier + * @param state state + * @param isBalanceHidden is balance hidden + * @param modifier modifier * * @see Figma Component @@ -42,7 +44,7 @@ import java.util.UUID [REDACTED_AUTHOR] */ @Composable -fun Transaction(state: TransactionState, modifier: Modifier = Modifier) { +fun Transaction(state: TransactionState, isBalanceHidden: Boolean, modifier: Modifier = Modifier) { Surface( modifier = modifier .background(TangemTheme.colors.background.primary) @@ -89,6 +91,7 @@ fun Transaction(state: TransactionState, modifier: Modifier = Modifier) { Amount( state = state, + isBalanceHidden = isBalanceHidden, modifier = Modifier.constrainAs(amountItem) { start.linkTo(titleItem.end) top.linkTo(titleItem.top) @@ -265,11 +268,11 @@ private fun Subtitle(state: TransactionState, modifier: Modifier = Modifier) { } @Composable -private fun Amount(state: TransactionState, modifier: Modifier = Modifier) { +private fun Amount(state: TransactionState, isBalanceHidden: Boolean, modifier: Modifier = Modifier) { when (state) { is TransactionState.Content -> { Text( - text = state.amount, + text = if (isBalanceHidden) Strings.STARS else state.amount, modifier = modifier, textAlign = TextAlign.End, color = when (state.direction) { @@ -333,7 +336,7 @@ private fun Preview_TransactionItem_LightTheme( @PreviewParameter(TransactionItemStateProvider::class) state: TransactionState, ) { TangemTheme(isDark = false) { - Transaction(state) + Transaction(state = state, isBalanceHidden = false) } } @@ -343,7 +346,7 @@ private fun Preview_TransactionItem_DarkTheme( @PreviewParameter(TransactionItemStateProvider::class) state: TransactionState, ) { TangemTheme(isDark = true) { - Transaction(state) + Transaction(state = state, isBalanceHidden = false) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt index e2dec6eb86..3314333a5e 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt @@ -24,12 +24,14 @@ import com.tangem.core.ui.res.TangemTheme fun LazyListScope.txHistoryItems( state: TxHistoryState, txHistoryItems: LazyPagingItems?, + isBalanceHidden: Boolean, modifier: Modifier = Modifier, ) { when (state) { is TxHistoryState.Content -> { contentItems( txHistoryItems = requireNotNull(txHistoryItems), + isBalanceHidden = isBalanceHidden, modifier = modifier, ) } @@ -54,6 +56,7 @@ fun LazyListScope.txHistoryItems( @OptIn(ExperimentalFoundationApi::class) private fun LazyListScope.contentItems( txHistoryItems: LazyPagingItems, + isBalanceHidden: Boolean, modifier: Modifier = Modifier, ) { items( @@ -70,6 +73,7 @@ private fun LazyListScope.contentItems( txHistoryItems[index]?.let { item -> TxHistoryListItem( state = item, + isBalanceHidden = isBalanceHidden, modifier = modifier .animateItemPlacement() .roundedShapeItemDecoration( diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryContentItem.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryContentItem.kt index 6f918f3cad..b532c2d533 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryContentItem.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TxHistoryContentItem.kt @@ -5,7 +5,11 @@ import androidx.compose.ui.Modifier import com.tangem.core.ui.components.transactions.state.TxHistoryState @Composable -internal fun TxHistoryListItem(state: TxHistoryState.TxHistoryItemState, modifier: Modifier = Modifier) { +internal fun TxHistoryListItem( + state: TxHistoryState.TxHistoryItemState, + isBalanceHidden: Boolean, + modifier: Modifier = Modifier, +) { when (state) { is TxHistoryState.TxHistoryItemState.GroupTitle -> { TxHistoryGroupTitle(config = state, modifier = modifier) @@ -14,7 +18,11 @@ internal fun TxHistoryListItem(state: TxHistoryState.TxHistoryItemState, modifie TxHistoryTitle(config = state, modifier = modifier) } is TxHistoryState.TxHistoryItemState.Transaction -> { - Transaction(state = state.state, modifier = modifier) + Transaction( + state = state.state, + isBalanceHidden = isBalanceHidden, + modifier = modifier, + ) } } } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt index 2fb3b9b125..d7771e9eb6 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt @@ -67,7 +67,6 @@ internal object TokenDetailsPreviewData { actionButtons = actionButtons, fiatBalance = "123,00$", cryptoBalance = "866,96 USDT", - isBalanceHidden = false, ) val balanceError = TokenDetailsBalanceBlockState.Error(actionButtons = actionButtons) @@ -93,5 +92,6 @@ internal object TokenDetailsPreviewData { pendingTxs = persistentListOf(), pullToRefreshConfig = pullToRefreshConfig, bottomSheetConfig = null, + isBalanceHidden = false, ) } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsBalanceBlockState.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsBalanceBlockState.kt index 9bcf4d84c3..2f066dae01 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsBalanceBlockState.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsBalanceBlockState.kt @@ -15,7 +15,6 @@ internal sealed class TokenDetailsBalanceBlockState { override val actionButtons: ImmutableList, val fiatBalance: String, val cryptoBalance: String, - val isBalanceHidden: Boolean, ) : TokenDetailsBalanceBlockState() data class Error( diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsState.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsState.kt index cdf8590f46..936440ff36 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsState.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsState.kt @@ -21,4 +21,5 @@ internal data class TokenDetailsState( val dialogConfig: TokenDetailsDialogConfig?, val pullToRefreshConfig: TokenDetailsPullToRefreshConfig, val bottomSheetConfig: TangemBottomSheetConfig?, + val isBalanceHidden: Boolean, ) \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsLoadedBalanceConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsLoadedBalanceConverter.kt index cc8b4d17d0..9bb7136de7 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsLoadedBalanceConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsLoadedBalanceConverter.kt @@ -21,7 +21,6 @@ import java.math.BigDecimal internal class TokenDetailsLoadedBalanceConverter( private val currentStateProvider: Provider, private val appCurrencyProvider: Provider, - private val isBalanceHiddenProvider: Provider, private val symbol: String, private val decimals: Int, ) : Converter, TokenDetailsState> { @@ -65,7 +64,6 @@ internal class TokenDetailsLoadedBalanceConverter( actionButtons = currentState.actionButtons, fiatBalance = formatFiatAmount(status.value, appCurrencyProvider()), cryptoBalance = formatCryptoAmount(status), - isBalanceHidden = isBalanceHiddenProvider(), ) } is CryptoCurrencyStatus.Loading -> { diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt index 3cd81399df..d149791b9e 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt @@ -49,6 +49,7 @@ internal class TokenDetailsSkeletonStateConverter( dialogConfig = null, pullToRefreshConfig = createPullToRefresh(), bottomSheetConfig = null, + isBalanceHidden = true, ) } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt index fde99ca794..52ef44ac9c 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt @@ -17,7 +17,6 @@ import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.domain.txhistory.models.TxHistoryStateError -import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsBalanceBlockState import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsDialogConfig import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.txhistory.TokenDetailsLoadedTxHistoryConverter @@ -29,7 +28,6 @@ import kotlinx.coroutines.flow.Flow internal class TokenDetailsStateFactory( private val currentStateProvider: Provider, private val appCurrencyProvider: Provider, - private val isBalanceHiddenProvider: Provider, private val clickIntents: TokenDetailsClickIntents, currencySymbolProvider: Provider, currencyDecimalsProvider: Provider, @@ -47,7 +45,6 @@ internal class TokenDetailsStateFactory( TokenDetailsLoadedBalanceConverter( currentStateProvider = currentStateProvider, appCurrencyProvider = appCurrencyProvider, - isBalanceHiddenProvider = isBalanceHiddenProvider, symbol = currencySymbolProvider(), decimals = currencyDecimalsProvider(), ) @@ -100,7 +97,9 @@ internal class TokenDetailsStateFactory( fun getLoadedTxHistoryState( txHistoryEither: Either>>, ): TokenDetailsState { - return loadedTxHistoryConverter.convert(txHistoryEither) + return currentStateProvider().copy( + txHistoryState = loadedTxHistoryConverter.convert(txHistoryEither), + ) } fun getStateWithClosedDialog(): TokenDetailsState { @@ -203,14 +202,8 @@ internal class TokenDetailsStateFactory( fun getStateWithUpdatedHidden(isBalanceHidden: Boolean): TokenDetailsState { val currentState = currentStateProvider() - val possibleTokenBalanceBlockState = currentState.tokenBalanceBlockState as? - TokenDetailsBalanceBlockState.Content - possibleTokenBalanceBlockState?.let { - return currentState.copy( - tokenBalanceBlockState = possibleTokenBalanceBlockState.copy(isBalanceHidden = isBalanceHidden), - ) - } ?: return currentState + return currentState.copy(isBalanceHidden = isBalanceHidden) } fun getStateWithNotifications(warnings: Set): TokenDetailsState { diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsLoadedTxHistoryConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsLoadedTxHistoryConverter.kt index 4c5fbc9fa2..b5675ea9f0 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsLoadedTxHistoryConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsLoadedTxHistoryConverter.kt @@ -16,7 +16,7 @@ internal class TokenDetailsLoadedTxHistoryConverter( private val clickIntents: TokenDetailsClickIntents, symbol: String, decimals: Int, -) : Converter>>, TokenDetailsState> { +) : Converter>>, TxHistoryState> { private val txHistoryItemFlowConverter by lazy { TokenDetailsTxHistoryItemFlowConverter( @@ -27,23 +27,19 @@ internal class TokenDetailsLoadedTxHistoryConverter( ) } - override fun convert(value: Either>>): TokenDetailsState { + override fun convert(value: Either>>): TxHistoryState { return value.fold(ifLeft = ::convertError, ifRight = ::convert) } - private fun convertError(error: TxHistoryListError): TokenDetailsState { - return currentStateProvider().copy( - txHistoryState = when (error) { - is TxHistoryListError.DataError -> { - TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick) - } - }, - ) + private fun convertError(error: TxHistoryListError): TxHistoryState { + return when (error) { + is TxHistoryListError.DataError -> { + TxHistoryState.Error(onReloadClick = clickIntents::onReloadClick) + } + } } - private fun convert(items: Flow>): TokenDetailsState { - return currentStateProvider().copy( - txHistoryState = txHistoryItemFlowConverter.convert(value = items), - ) + private fun convert(items: Flow>): TxHistoryState { + return txHistoryItemFlowConverter.convert(value = items) } } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryItemFlowConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryItemFlowConverter.kt index 11d8ee4aaf..b4e618aeb3 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryItemFlowConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryItemFlowConverter.kt @@ -30,7 +30,10 @@ internal class TokenDetailsTxHistoryItemFlowConverter( ) : Converter>, TxHistoryState> { private val txHistoryItemConverter by lazy { - TokenDetailsTxHistoryTransactionStateConverter(symbol = symbol, decimals = decimals) + TokenDetailsTxHistoryTransactionStateConverter( + symbol = symbol, + decimals = decimals, + ) } override fun convert(value: Flow>): TxHistoryState { diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryToTransactionStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryToTransactionStateConverter.kt index 2b8eaca2ad..5c11efff45 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryToTransactionStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryToTransactionStateConverter.kt @@ -29,7 +29,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( TxHistoryItem.TransactionType.Deposit -> TransactionState.Custom( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -39,7 +39,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( TxHistoryItem.TransactionType.Submit -> TransactionState.Custom( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -49,7 +49,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( TxHistoryItem.TransactionType.Supply -> TransactionState.Custom( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -59,7 +59,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( TxHistoryItem.TransactionType.Unoswap -> TransactionState.Custom( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -69,7 +69,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( TxHistoryItem.TransactionType.Withdraw -> TransactionState.Custom( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -79,7 +79,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( is TxHistoryItem.TransactionType.Custom -> TransactionState.Custom( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -93,7 +93,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( return TransactionState.Transfer( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -104,7 +104,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( return TransactionState.Approve( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -114,7 +114,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( return TransactionState.Swap( txHash = item.txHash, address = item.direction.extractAddress(), - amount = item.extractFormattedCryptoBalance(), + amount = item.getAmount(), timestamp = item.timestampInMillis.toTimeFormat(), status = item.status.tiUiStatus(), direction = item.direction.toUiDirection(), @@ -141,7 +141,7 @@ internal class TokenDetailsTxHistoryToTransactionStateConverter( is TxHistoryItem.TransactionDirection.Outgoing -> TransactionState.Content.Direction.OUTGOING } - private fun TxHistoryItem.extractFormattedCryptoBalance(): String { + private fun TxHistoryItem.getAmount(): String { val prefix = when (direction) { is TxHistoryItem.TransactionDirection.Incoming -> "+" is TxHistoryItem.TransactionDirection.Outgoing -> "-" diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryTransactionStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryTransactionStateConverter.kt index be32a72923..f4174cafae 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryTransactionStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/txhistory/TokenDetailsTxHistoryTransactionStateConverter.kt @@ -26,7 +26,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +36,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +46,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +56,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +66,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +76,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +90,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +101,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +111,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( 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 +142,7 @@ internal class TokenDetailsTxHistoryTransactionStateConverter( is TxHistoryItem.TransactionDirection.Outgoing -> TransactionState.Content.Direction.OUTGOING } - private fun TxHistoryItem.extractFormattedCryptoBalance(): String { + private fun TxHistoryItem.getAmount(): String { val prefix = when (direction) { is TxHistoryItem.TransactionDirection.Incoming -> "+" is TxHistoryItem.TransactionDirection.Outgoing -> "-" diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt index 908501c1d0..5ff3e0fff7 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt @@ -79,7 +79,13 @@ internal fun TokenDetailsScreen(state: TokenDetailsState) { state = state.tokenInfoBlockState, ) } - item { TokenDetailsBalanceBlock(modifier = itemModifier, state = state.tokenBalanceBlockState) } + item { + TokenDetailsBalanceBlock( + modifier = itemModifier, + isBalanceHidden = state.isBalanceHidden, + state = state.tokenBalanceBlockState, + ) + } items( items = state.notifications.filter { it.isVisible }, key = { it.config::class.java }, @@ -95,11 +101,16 @@ internal fun TokenDetailsScreen(state: TokenDetailsState) { item { PendingTxsBlock( pendingTxs = state.pendingTxs, + isBalanceHidden = state.isBalanceHidden, modifier = itemModifier, ) } } - txHistoryItems(state = state.txHistoryState, txHistoryItems = txHistoryItems) + txHistoryItems( + state = state.txHistoryState, + isBalanceHidden = state.isBalanceHidden, + txHistoryItems = txHistoryItems, + ) } PullRefreshIndicator( @@ -127,7 +138,11 @@ internal fun TokenDetailsScreen(state: TokenDetailsState) { } @Composable -private fun PendingTxsBlock(pendingTxs: PersistentList, modifier: Modifier = Modifier) { +private fun PendingTxsBlock( + pendingTxs: PersistentList, + isBalanceHidden: Boolean, + modifier: Modifier = Modifier, +) { Column( modifier = modifier .clip(shape = TangemTheme.shapes.roundedCornersXMedium) @@ -135,7 +150,7 @@ private fun PendingTxsBlock(pendingTxs: PersistentList, modifi verticalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing8), horizontalAlignment = Alignment.Start, ) { - pendingTxs.fastForEach { Transaction(state = it) } + pendingTxs.fastForEach { Transaction(state = it, isBalanceHidden = isBalanceHidden) } } } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsBalanceBlock.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsBalanceBlock.kt index 2a3cf30680..0fc3606d9b 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsBalanceBlock.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsBalanceBlock.kt @@ -9,6 +9,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider +import com.tangem.common.Strings.STARS import com.tangem.core.ui.components.RectangleShimmer import com.tangem.core.ui.components.buttons.HorizontalActionChips import com.tangem.core.ui.res.TangemTheme @@ -20,7 +21,11 @@ import com.tangem.features.tokendetails.impl.R import kotlinx.collections.immutable.toImmutableList @Composable -internal fun TokenDetailsBalanceBlock(state: TokenDetailsBalanceBlockState, modifier: Modifier = Modifier) { +internal fun TokenDetailsBalanceBlock( + state: TokenDetailsBalanceBlockState, + isBalanceHidden: Boolean, + modifier: Modifier = Modifier, +) { Surface( modifier = modifier.fillMaxWidth(), shape = TangemTheme.shapes.roundedCornersXMedium, @@ -41,12 +46,14 @@ internal fun TokenDetailsBalanceBlock(state: TokenDetailsBalanceBlockState, modi ) FiatBalance( state = state, + isBalanceHidden = isBalanceHidden, modifier = Modifier .padding(top = TangemTheme.dimens.spacing4) .padding(horizontal = TangemTheme.dimens.spacing12), ) CryptoBalance( state = state, + isBalanceHidden = isBalanceHidden, modifier = Modifier .padding(top = TangemTheme.dimens.spacing4) .padding(horizontal = TangemTheme.dimens.spacing12), @@ -62,7 +69,11 @@ internal fun TokenDetailsBalanceBlock(state: TokenDetailsBalanceBlockState, modi } @Composable -private fun FiatBalance(state: TokenDetailsBalanceBlockState, modifier: Modifier = Modifier) { +private fun FiatBalance( + state: TokenDetailsBalanceBlockState, + isBalanceHidden: Boolean, + modifier: Modifier = Modifier, +) { when (state) { is TokenDetailsBalanceBlockState.Loading -> RectangleShimmer( modifier = modifier.size( @@ -72,7 +83,7 @@ private fun FiatBalance(state: TokenDetailsBalanceBlockState, modifier: Modifier ) is TokenDetailsBalanceBlockState.Content -> Text( modifier = modifier, - text = if (state.isBalanceHidden) DOTS else state.fiatBalance, + text = if (isBalanceHidden) STARS else state.fiatBalance, style = TangemTheme.typography.h2, color = TangemTheme.colors.text.primary1, ) @@ -86,7 +97,11 @@ private fun FiatBalance(state: TokenDetailsBalanceBlockState, modifier: Modifier } @Composable -private fun CryptoBalance(state: TokenDetailsBalanceBlockState, modifier: Modifier = Modifier) { +private fun CryptoBalance( + state: TokenDetailsBalanceBlockState, + isBalanceHidden: Boolean, + modifier: Modifier = Modifier, +) { when (state) { is TokenDetailsBalanceBlockState.Loading -> RectangleShimmer( modifier = modifier.size( @@ -96,7 +111,7 @@ private fun CryptoBalance(state: TokenDetailsBalanceBlockState, modifier: Modifi ) is TokenDetailsBalanceBlockState.Content -> Text( modifier = modifier, - text = if (state.isBalanceHidden) DOTS else state.cryptoBalance, + text = if (isBalanceHidden) STARS else state.cryptoBalance, style = TangemTheme.typography.caption, color = TangemTheme.colors.text.tertiary, ) @@ -115,7 +130,7 @@ private fun Preview_TokenDetailsBalanceBlock_LightTheme( @PreviewParameter(TokenDetailsBalanceBlockStateProvider::class) state: TokenDetailsBalanceBlockState, ) { TangemTheme(isDark = false) { - TokenDetailsBalanceBlock(state) + TokenDetailsBalanceBlock(state = state, isBalanceHidden = false) } } @@ -125,7 +140,7 @@ private fun Preview_TokenDetailsBalanceBlock_DarkTheme( @PreviewParameter(TokenDetailsBalanceBlockStateProvider::class) state: TokenDetailsBalanceBlockState, ) { TangemTheme(isDark = true) { - TokenDetailsBalanceBlock(state) + TokenDetailsBalanceBlock(state = state, isBalanceHidden = false) } } @@ -135,6 +150,4 @@ private class TokenDetailsBalanceBlockStateProvider : CollectionPreviewParameter TokenDetailsPreviewData.balanceContent, TokenDetailsPreviewData.balanceError, ), -) - -const val DOTS = "***" \ No newline at end of file +) \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt index 4487529033..2e1ffc3c93 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt @@ -78,12 +78,10 @@ internal class TokenDetailsViewModel @Inject constructor( private var cryptoCurrency by Delegates.notNull() private val selectedAppCurrencyFlow: StateFlow = createSelectedAppCurrencyFlow() - private var isBalanceHidden = true private val stateFactory = TokenDetailsStateFactory( currentStateProvider = Provider { uiState }, appCurrencyProvider = Provider(selectedAppCurrencyFlow::value), - isBalanceHiddenProvider = Provider { isBalanceHidden }, clickIntents = this, currencySymbolProvider = Provider { cryptoCurrency.symbol }, currencyDecimalsProvider = Provider { cryptoCurrency.decimals }, @@ -125,8 +123,9 @@ internal class TokenDetailsViewModel @Inject constructor( isBalanceHiddenUseCase() .flowWithLifecycle(owner.lifecycle) .onEach { hidden -> - isBalanceHidden = hidden - uiState = stateFactory.getStateWithUpdatedHidden(isBalanceHidden = hidden) + uiState = stateFactory.getStateWithUpdatedHidden( + isBalanceHidden = hidden, + ) } .launchIn(viewModelScope) @@ -186,11 +185,9 @@ internal class TokenDetailsViewModel @Inject constructor( } txHistoryItemsCountEither.onRight { - uiState = stateFactory.getLoadedTxHistoryState( - txHistoryEither = txHistoryItemsUseCase(currency = cryptoCurrency).map { - it.cachedIn(viewModelScope) - }, - ) + val either = txHistoryItemsUseCase(currency = cryptoCurrency) + .map { it.cachedIn(viewModelScope) } + uiState = stateFactory.getLoadedTxHistoryState(txHistoryEither = either) } } } 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 5ae45f4206..f3786031b5 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 @@ -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, ) } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMultiCurrencyState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMultiCurrencyState.kt index d91449abb4..0a71550228 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMultiCurrencyState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMultiCurrencyState.kt @@ -26,6 +26,7 @@ internal sealed class WalletMultiCurrencyState : WalletState.ContentState() { override val bottomSheetConfig: TangemBottomSheetConfig?, override val tokensListState: WalletTokensListState, override val event: StateEvent = 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 = consumedEvent(), + override val isBalanceHidden: Boolean, ) : WalletMultiCurrencyState(), WalletLockedState { override val notifications = persistentListOf( 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 6a5467d025..4bb761d008 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 @@ -38,6 +38,7 @@ internal sealed class WalletSingleCurrencyState : WalletState.ContentState() { override val buttons: PersistentList, override val txHistoryState: TxHistoryState, override val event: StateEvent = 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 = consumedEvent(), + override val isBalanceHidden: Boolean, val onExploreClick: () -> Unit, ) : WalletSingleCurrencyState(), WalletLockedState { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletState.kt index 9872db9572..a3e9904881 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletState.kt @@ -39,6 +39,9 @@ internal sealed class WalletState { /** State event */ abstract val event: StateEvent + /** 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 = 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, ) } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletLockedConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletLockedConverter.kt index 51cb49325d..8007a4cf4d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletLockedConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletLockedConverter.kt @@ -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, ) } 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 55520ad855..ffc4fb691f 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 @@ -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, ) } 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 f4b1ade111..92783093a4 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 @@ -88,6 +88,7 @@ internal class WalletStateFactory( private val loadedTxHistoryConverter by lazy { WalletLoadedTxHistoryConverter( currentStateProvider = currentStateProvider, + isBalanceHiddenProvider = isBalanceHiddenProvider, currentCardTypeResolverProvider = currentCardTypeResolverProvider, clickIntents = clickIntents, ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt index 39f3eb7cc9..ed986d7f0e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt @@ -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, ) } 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 202fcc3ae5..7d2636f3a2 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 @@ -27,6 +27,7 @@ internal class WalletLoadedTxHistoryConverter( private val currentStateProvider: Provider, private val currentCardTypeResolverProvider: Provider, private val clickIntents: WalletClickIntents, + private val isBalanceHiddenProvider: Provider, ) : Converter>>, WalletState> { private val walletTxHistoryItemFlowConverter by lazy { @@ -34,6 +35,7 @@ internal class WalletLoadedTxHistoryConverter( currentStateProvider = currentStateProvider, blockchain = currentCardTypeResolverProvider().getBlockchain(), clickIntents = clickIntents, + isBalanceHiddenProvider = isBalanceHiddenProvider, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletTxHistoryItemFlowConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletTxHistoryItemFlowConverter.kt index bac145142e..2789256422 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletTxHistoryItemFlowConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletTxHistoryItemFlowConverter.kt @@ -35,12 +35,17 @@ import org.joda.time.DateTimeZone */ internal class WalletTxHistoryItemFlowConverter( private val currentStateProvider: Provider, + private val isBalanceHiddenProvider: Provider, private val blockchain: Blockchain, private val clickIntents: WalletClickIntents, ) : Converter>, 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>): TxHistoryState? { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletTxHistoryTransactionStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletTxHistoryTransactionStateConverter.kt index 44dedce7b4..c4af843d2b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletTxHistoryTransactionStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/txhistory/WalletTxHistoryTransactionStateConverter.kt @@ -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, ) : Converter { 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 -> "-" diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt index bacaea655a..8d61d90510 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt @@ -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 diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletContent.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletContent.kt index 211ad0e75f..cfdc6e5955 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletContent.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletContent.kt @@ -22,10 +22,11 @@ import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency internal fun LazyListScope.contentItems( state: WalletState.ContentState, txHistoryItems: LazyPagingItems?, + 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) } } \ No newline at end of file