From fd29bcdc08bb47eac49d8e37940d136af9c9b3fd Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 29 Sep 2023 12:23:14 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../redux/middlewares/MultiWalletMiddleware.kt | 1 + .../components/marketprice/MarketPriceBlock.kt | 10 +++++----- .../marketprice/MarketPriceBlockState.kt | 8 ++++---- .../navigation/TokenDetailsArguments.kt | 1 + .../tokendetails/TokenDetailsPreviewData.kt | 2 +- .../TokenDetailsLoadedBalanceConverter.kt | 17 ++++++++++------- .../TokenDetailsSkeletonStateConverter.kt | 2 +- .../presentation/common/WalletPreviewData.kt | 2 +- .../presentation/router/DefaultWalletRouter.kt | 1 + ...alletSingleCurrencyLoadedBalanceConverter.kt | 4 ++-- .../factory/WalletSkeletonStateConverter.kt | 2 +- .../factory/WalletsUnlockStateConverter.kt | 2 +- 12 files changed, 29 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt index 1e42d1a91f..9b4d3fe816 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt @@ -139,6 +139,7 @@ class MultiWalletMiddleware { return TokenDetailsArguments( currencyId = cryptoCurrency.id, currencyName = cryptoCurrency.name, + currencySymbol = cryptoCurrency.symbol, iconUrl = cryptoCurrency.iconUrl, coinType = when (cryptoCurrency) { is CryptoCurrency.Coin -> TokenDetailsArguments.CoinType.Native diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlock.kt b/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlock.kt index 585426d477..40cb551701 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlock.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlock.kt @@ -51,7 +51,7 @@ fun MarketPriceBlock(state: MarketPriceBlockState, modifier: Modifier = Modifier verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing6), horizontalAlignment = Alignment.Start, ) { - Title(currencyName = state.currencyName) + Title(currencyName = state.currencySymbol) Content(state = state, rootWidth = rootWidth) } @@ -213,7 +213,7 @@ private fun Preview_MarketPriceBlock_Dark( private class WalletMarketPriceBlockStateProvider : CollectionPreviewParameterProvider( collection = listOf( MarketPriceBlockState.Content( - currencyName = "BTC", + currencySymbol = "BTC", price = "98900 $", priceChangeConfig = PriceChangeState.Content( valueInPercent = "5.16%", @@ -221,14 +221,14 @@ private class WalletMarketPriceBlockStateProvider : CollectionPreviewParameterPr ), ), MarketPriceBlockState.Content( - currencyName = "BTC", + currencySymbol = "BTC", price = "98900 $", priceChangeConfig = PriceChangeState.Content( valueInPercent = "10.89%", type = PriceChangeType.UP, ), ), - MarketPriceBlockState.Loading(currencyName = "BTC"), - MarketPriceBlockState.Error(currencyName = "BTC"), + MarketPriceBlockState.Loading(currencySymbol = "BTC"), + MarketPriceBlockState.Error(currencySymbol = "BTC"), ), ) \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlockState.kt b/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlockState.kt index e1c7a1e21a..566ce6fef6 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlockState.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/marketprice/MarketPriceBlockState.kt @@ -5,14 +5,14 @@ import androidx.compose.runtime.Immutable @Immutable sealed interface MarketPriceBlockState { - val currencyName: String + val currencySymbol: String - data class Error(override val currencyName: String) : MarketPriceBlockState + data class Error(override val currencySymbol: String) : MarketPriceBlockState - data class Loading(override val currencyName: String) : MarketPriceBlockState + data class Loading(override val currencySymbol: String) : MarketPriceBlockState data class Content( - override val currencyName: String, + override val currencySymbol: String, val price: String, val priceChangeConfig: PriceChangeState.Content, ) : MarketPriceBlockState diff --git a/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/navigation/TokenDetailsArguments.kt b/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/navigation/TokenDetailsArguments.kt index 30c0ecc912..03a33f3af3 100644 --- a/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/navigation/TokenDetailsArguments.kt +++ b/features/tokendetails/api/src/main/kotlin/com/tangem/features/tokendetails/navigation/TokenDetailsArguments.kt @@ -9,6 +9,7 @@ import kotlinx.parcelize.Parcelize data class TokenDetailsArguments( val currencyId: CryptoCurrency.ID, val currencyName: String, + val currencySymbol: String, val iconUrl: String?, val coinType: CoinType, ) : Parcelable { 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 d7771e9eb6..47fb487c28 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 @@ -70,7 +70,7 @@ internal object TokenDetailsPreviewData { ) val balanceError = TokenDetailsBalanceBlockState.Error(actionButtons = actionButtons) - private val marketPriceLoading = MarketPriceBlockState.Loading(currencyName = "USDT") + private val marketPriceLoading = MarketPriceBlockState.Loading(currencySymbol = "USDT") private val pullToRefreshConfig = TokenDetailsPullToRefreshConfig( isRefreshing = false, 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 9bb7136de7..9240092123 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 @@ -37,17 +37,17 @@ internal class TokenDetailsLoadedBalanceConverter( val state = currentStateProvider() return state.copy( tokenBalanceBlockState = TokenDetailsBalanceBlockState.Error(state.tokenBalanceBlockState.actionButtons), - marketPriceBlockState = MarketPriceBlockState.Error(state.marketPriceBlockState.currencyName), + marketPriceBlockState = MarketPriceBlockState.Error(state.marketPriceBlockState.currencySymbol), notifications = persistentListOf(TokenDetailsNotification.NetworksUnreachable), ) } private fun convert(status: CryptoCurrencyStatus): TokenDetailsState { val state = currentStateProvider() - val currencyName = state.marketPriceBlockState.currencyName + val currencyName = state.marketPriceBlockState.currencySymbol return state.copy( tokenBalanceBlockState = getBalanceState(state.tokenBalanceBlockState, status), - marketPriceBlockState = getMarketPriceState(status = status.value, currencyName = currencyName), + marketPriceBlockState = getMarketPriceState(status = status.value, currencySymbol = currencyName), pendingTxs = status.value.pendingTransactions.map(txHistoryItemConverter::convert).toPersistentList(), ) } @@ -80,10 +80,13 @@ internal class TokenDetailsLoadedBalanceConverter( } } - private fun getMarketPriceState(status: CryptoCurrencyStatus.Status, currencyName: String): MarketPriceBlockState { + private fun getMarketPriceState( + status: CryptoCurrencyStatus.Status, + currencySymbol: String, + ): MarketPriceBlockState { return when (status) { - is CryptoCurrencyStatus.Loading -> MarketPriceBlockState.Loading(currencyName) - is CryptoCurrencyStatus.NoQuote -> MarketPriceBlockState.Error(currencyName) + is CryptoCurrencyStatus.Loading -> MarketPriceBlockState.Loading(currencySymbol) + is CryptoCurrencyStatus.NoQuote -> MarketPriceBlockState.Error(currencySymbol) is CryptoCurrencyStatus.Loaded, is CryptoCurrencyStatus.Custom, is CryptoCurrencyStatus.MissedDerivation, @@ -91,7 +94,7 @@ internal class TokenDetailsLoadedBalanceConverter( is CryptoCurrencyStatus.NoAmount, is CryptoCurrencyStatus.Unreachable, -> MarketPriceBlockState.Content( - currencyName = currencyName, + currencySymbol = currencySymbol, price = formatPrice(status, appCurrencyProvider()), priceChangeConfig = PriceChangeState.Content( valueInPercent = formatPriceChange(status), 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 d149791b9e..9392fa607c 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 @@ -38,7 +38,7 @@ internal class TokenDetailsSkeletonStateConverter( }, ), tokenBalanceBlockState = TokenDetailsBalanceBlockState.Loading(actionButtons = createButtons()), - marketPriceBlockState = MarketPriceBlockState.Loading(value.currencyName), + marketPriceBlockState = MarketPriceBlockState.Loading(value.currencySymbol), notifications = persistentListOf(), pendingTxs = persistentListOf(), txHistoryState = TxHistoryState.Content( 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 f3786031b5..2e38ce1e26 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 @@ -414,7 +414,7 @@ internal object WalletPreviewData { buttons = manageButtons, bottomSheetConfig = bottomSheet, marketPriceBlockState = MarketPriceBlockState.Content( - currencyName = "BTC", + currencySymbol = "BTC", price = "98900.12$", priceChangeConfig = PriceChangeState.Content( valueInPercent = "5.16%", diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt index dbe5b06c33..f134aeade2 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt @@ -117,6 +117,7 @@ internal class DefaultWalletRouter(private val reduxNavController: ReduxNavContr TokenDetailsRouter.TOKEN_DETAILS_ARGS to TokenDetailsArguments( currencyId = currency.id, currencyName = currency.name, + currencySymbol = currency.symbol, iconUrl = currency.iconUrl, coinType = when (currency) { is CryptoCurrency.Coin -> TokenDetailsArguments.CoinType.Native diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSingleCurrencyLoadedBalanceConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSingleCurrencyLoadedBalanceConverter.kt index 99e0575bb5..ff8df226a1 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSingleCurrencyLoadedBalanceConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSingleCurrencyLoadedBalanceConverter.kt @@ -38,7 +38,7 @@ internal class WalletSingleCurrencyLoadedBalanceConverter( private fun convertContent(status: CryptoCurrencyStatus): WalletState { return when (val state = currentStateProvider()) { is WalletSingleCurrencyState.Content -> { - val currencyName = state.marketPriceBlockState.currencyName + val currencyName = state.marketPriceBlockState.currencySymbol state.copy( walletsListConfig = getUpdatedSelectedWallet(status = status.value, state = state), @@ -58,7 +58,7 @@ internal class WalletSingleCurrencyLoadedBalanceConverter( is CryptoCurrencyStatus.NoQuote, is CryptoCurrencyStatus.Loaded, -> MarketPriceBlockState.Content( - currencyName = currencyName, + currencySymbol = currencyName, price = formatPrice(status, appCurrencyProvider()), priceChangeConfig = PriceChangeState.Content( valueInPercent = formatPriceChange(status), 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 ffc4fb691f..51a78e138e 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 @@ -68,7 +68,7 @@ internal class WalletSkeletonStateConverter( notifications = persistentListOf(), bottomSheetConfig = null, buttons = createButtons(), - marketPriceBlockState = MarketPriceBlockState.Loading(currencyName = currencyName), + marketPriceBlockState = MarketPriceBlockState.Loading(currencySymbol = currencyName), txHistoryState = TxHistoryState.Content( contentItems = MutableStateFlow( value = TxHistoryState.getDefaultLoadingTransactions(clickIntents::onExploreClick), 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 ed986d7f0e..b1488f51a6 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 @@ -68,7 +68,7 @@ internal class WalletsUnlockStateConverter( bottomSheetConfig = null, buttons = buttons, marketPriceBlockState = MarketPriceBlockState.Loading( - currencyName = action.selectedWallet.getPrimaryCurrencyName(), + currencySymbol = action.selectedWallet.getPrimaryCurrencyName(), ), txHistoryState = TxHistoryState.Content( contentItems = MutableStateFlow(