Updated on 2026-08-14
This commit is contained in:
parent
c6fc0d49ba
commit
31b1b2182b
11 changed files with 110 additions and 96 deletions
|
|
@ -130,7 +130,7 @@ private fun Price(price: String, modifier: Modifier = Modifier) {
|
|||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
private fun PriceChangeInPercent(config: PriceChangeConfig) {
|
||||
private fun PriceChangeInPercent(config: PriceChangeState.Content) {
|
||||
AnimatedContent(targetState = config.type, label = "Update price change") { type ->
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
@ -139,13 +139,13 @@ private fun PriceChangeInPercent(config: PriceChangeConfig) {
|
|||
Icon(
|
||||
painter = painterResource(
|
||||
id = when (type) {
|
||||
PriceChangeConfig.Type.UP -> R.drawable.ic_arrow_up_8
|
||||
PriceChangeConfig.Type.DOWN -> R.drawable.ic_arrow_down_8
|
||||
PriceChangeType.UP -> R.drawable.ic_arrow_up_8
|
||||
PriceChangeType.DOWN -> R.drawable.ic_arrow_down_8
|
||||
},
|
||||
),
|
||||
tint = when (type) {
|
||||
PriceChangeConfig.Type.UP -> TangemTheme.colors.icon.accent
|
||||
PriceChangeConfig.Type.DOWN -> TangemTheme.colors.icon.warning
|
||||
PriceChangeType.UP -> TangemTheme.colors.icon.accent
|
||||
PriceChangeType.DOWN -> TangemTheme.colors.icon.warning
|
||||
},
|
||||
contentDescription = null,
|
||||
)
|
||||
|
|
@ -153,8 +153,8 @@ private fun PriceChangeInPercent(config: PriceChangeConfig) {
|
|||
Text(
|
||||
text = config.valueInPercent,
|
||||
color = when (type) {
|
||||
PriceChangeConfig.Type.UP -> TangemTheme.colors.text.accent
|
||||
PriceChangeConfig.Type.DOWN -> TangemTheme.colors.text.warning
|
||||
PriceChangeType.UP -> TangemTheme.colors.text.accent
|
||||
PriceChangeType.DOWN -> TangemTheme.colors.text.warning
|
||||
},
|
||||
style = TangemTheme.typography.body2,
|
||||
)
|
||||
|
|
@ -215,17 +215,17 @@ private class WalletMarketPriceBlockStateProvider : CollectionPreviewParameterPr
|
|||
MarketPriceBlockState.Content(
|
||||
currencyName = "BTC",
|
||||
price = "98900 $",
|
||||
priceChangeConfig = PriceChangeConfig(
|
||||
priceChangeConfig = PriceChangeState.Content(
|
||||
valueInPercent = "5.16%",
|
||||
type = PriceChangeConfig.Type.DOWN,
|
||||
type = PriceChangeType.DOWN,
|
||||
),
|
||||
),
|
||||
MarketPriceBlockState.Content(
|
||||
currencyName = "BTC",
|
||||
price = "98900 $",
|
||||
priceChangeConfig = PriceChangeConfig(
|
||||
priceChangeConfig = PriceChangeState.Content(
|
||||
valueInPercent = "10.89%",
|
||||
type = PriceChangeConfig.Type.UP,
|
||||
type = PriceChangeType.UP,
|
||||
),
|
||||
),
|
||||
MarketPriceBlockState.Loading(currencyName = "BTC"),
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ sealed interface MarketPriceBlockState {
|
|||
data class Content(
|
||||
override val currencyName: String,
|
||||
val price: String,
|
||||
val priceChangeConfig: PriceChangeConfig,
|
||||
val priceChangeConfig: PriceChangeState.Content,
|
||||
) : MarketPriceBlockState
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.tangem.core.ui.components.marketprice
|
||||
|
||||
data class PriceChangeConfig(val valueInPercent: String, val type: Type) {
|
||||
|
||||
/** Price changing type */
|
||||
enum class Type {
|
||||
UP, DOWN
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.tangem.core.ui.components.marketprice
|
||||
|
||||
sealed class PriceChangeState {
|
||||
|
||||
data class Content(val valueInPercent: String, val type: PriceChangeType) : PriceChangeState()
|
||||
|
||||
object Unknown : PriceChangeState()
|
||||
}
|
||||
|
||||
/** Price changing type */
|
||||
enum class PriceChangeType {
|
||||
UP, DOWN
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue