Updated on 2026-08-14
This commit is contained in:
parent
2e857d5e3e
commit
45fa120411
49 changed files with 669 additions and 92 deletions
|
|
@ -81,6 +81,7 @@ dependencies {
|
|||
|
||||
/* Common */
|
||||
implementation(projects.common.ui)
|
||||
implementation(projects.common.uiMarkets)
|
||||
implementation(projects.common.uiCharts)
|
||||
implementation(projects.common.routing)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.tangem.common.routing.AppRoute
|
|||
import com.tangem.common.ui.charts.state.MarketChartData
|
||||
import com.tangem.common.ui.charts.state.converter.PriceAndTimePointValuesConverter
|
||||
import com.tangem.common.ui.charts.state.sorted
|
||||
import com.tangem.common.ui.markets.toMarketsListItemPriceAnnotated
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
|
|
@ -62,6 +63,8 @@ internal class TokenMarketBlockModel @Inject constructor(
|
|||
TokenMarketBlockUM(
|
||||
currencySymbol = params.cryptoCurrency.symbol,
|
||||
currentPrice = null,
|
||||
currentPriceValue = null,
|
||||
priceAnnotated = null,
|
||||
h24Percent = null,
|
||||
priceChangeType = PriceChangeType.NEUTRAL,
|
||||
chartData = null,
|
||||
|
|
@ -86,15 +89,21 @@ internal class TokenMarketBlockModel @Inject constructor(
|
|||
h24Percent = res.priceChange,
|
||||
)
|
||||
|
||||
val appCurrency = currentAppCurrency.value
|
||||
state.value = state.value.copy(
|
||||
currentPrice = res.fiatRate.format {
|
||||
fiat(
|
||||
// TODO get currency from quotes use case [REDACTED_TASK_KEY]
|
||||
fiatCurrencyCode = currentAppCurrency.value.code,
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
// TODO get currency from quotes use case [REDACTED_TASK_KEY]
|
||||
fiatCurrencySymbol = currentAppCurrency.value.symbol,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
).price()
|
||||
},
|
||||
currentPriceValue = res.fiatRate,
|
||||
priceAnnotated = res.fiatRate.toMarketsListItemPriceAnnotated(
|
||||
appCurrencyCode = appCurrency.code,
|
||||
appCurrencySymbol = appCurrency.symbol,
|
||||
),
|
||||
h24Percent = res.priceChange.format { percent() },
|
||||
priceChangeType = PriceChangeType.fromBigDecimal(res.priceChange),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import com.tangem.core.ui.components.TextShimmer
|
|||
import com.tangem.core.ui.components.block.BlockCard
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeInPercent
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeType
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
|
|
@ -27,6 +29,7 @@ import com.tangem.features.markets.impl.R
|
|||
import com.tangem.features.markets.token.block.impl.model.formatter.toChartType
|
||||
import com.tangem.features.markets.token.block.impl.ui.state.TokenMarketBlockUM
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import java.math.BigDecimal
|
||||
import kotlin.random.Random
|
||||
|
||||
@Composable
|
||||
|
|
@ -47,6 +50,8 @@ internal fun TokenMarketBlockLegacy(state: TokenMarketBlockUM, modifier: Modifie
|
|||
modifier = Modifier.weight(1f),
|
||||
symbol = state.currencySymbol,
|
||||
priceText = state.currentPrice,
|
||||
priceValue = state.currentPriceValue,
|
||||
priceAnnotated = state.priceAnnotated,
|
||||
percentText = state.h24Percent,
|
||||
type = state.priceChangeType,
|
||||
)
|
||||
|
|
@ -61,11 +66,14 @@ internal fun TokenMarketBlockLegacy(state: TokenMarketBlockUM, modifier: Modifie
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun LeftSide(
|
||||
symbol: String,
|
||||
priceText: String?,
|
||||
priceValue: BigDecimal?,
|
||||
priceAnnotated: TextReference?,
|
||||
percentText: String?,
|
||||
type: PriceChangeType,
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
@ -88,6 +96,8 @@ private fun LeftSide(
|
|||
modifier = Modifier.alignByBaseline(),
|
||||
price = priceText,
|
||||
priceChangeType = type,
|
||||
priceValue = priceValue ?: BigDecimal.ZERO,
|
||||
priceAnnotated = priceAnnotated ?: TextReference.EMPTY,
|
||||
)
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8),
|
||||
|
|
@ -181,6 +191,8 @@ private fun Preview() {
|
|||
priceChangeType = PriceChangeType.UP,
|
||||
chartData = data,
|
||||
onClick = {},
|
||||
currentPriceValue = BigDecimal(1234),
|
||||
priceAnnotated = stringReference("0,5$"),
|
||||
)
|
||||
|
||||
TangemThemePreview {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,14 @@ package com.tangem.features.markets.token.block.impl.ui.state
|
|||
|
||||
import com.tangem.common.ui.charts.state.MarketChartRawData
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeType
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import java.math.BigDecimal
|
||||
|
||||
internal data class TokenMarketBlockUM(
|
||||
val currencySymbol: String,
|
||||
val currentPrice: String?,
|
||||
val currentPriceValue: BigDecimal?,
|
||||
val priceAnnotated: TextReference?,
|
||||
val h24Percent: String?,
|
||||
val priceChangeType: PriceChangeType,
|
||||
val chartData: MarketChartRawData?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue