Updated on 2026-08-14

This commit is contained in:
Tangem 2023-09-29 12:23:14 +05:00
parent 294c7139ee
commit fd29bcdc08
12 changed files with 29 additions and 23 deletions

View file

@ -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

View file

@ -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<MarketPriceBlockState>(
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"),
),
)

View file

@ -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

View file

@ -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 {

View file

@ -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,

View file

@ -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),

View file

@ -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(

View file

@ -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%",

View file

@ -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

View file

@ -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),

View file

@ -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),

View file

@ -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(