Updated on 2026-08-14

This commit is contained in:
Tangem 2024-08-14 12:52:27 +03:00
parent c6d333dbeb
commit 244f9bc61d
19 changed files with 224 additions and 77 deletions

View file

@ -314,6 +314,7 @@ private fun MarketChartPreview(
TangemThemePreview {
val growingColor = TangemTheme.colors.icon.accent
val fallingColor = TangemTheme.colors.icon.warning
val neutralColor = TangemTheme.colors.icon.informative
val chartState = rememberMarketChartState(
dataProducer = dataProducer,
@ -324,6 +325,7 @@ private fun MarketChartPreview(
when (it) {
MarketChartLook.Type.Growing -> growingColor
MarketChartLook.Type.Falling -> fallingColor
MarketChartLook.Type.Neutral -> neutralColor
}
},
)
@ -382,10 +384,10 @@ private fun MarketChartPreview(
dataProducer.runTransaction {
updateLook {
it.copy(
type = if (it.type == MarketChartLook.Type.Growing) {
MarketChartLook.Type.Falling
} else {
MarketChartLook.Type.Growing
type = when (it.type) {
MarketChartLook.Type.Growing -> MarketChartLook.Type.Falling
MarketChartLook.Type.Falling -> MarketChartLook.Type.Neutral
MarketChartLook.Type.Neutral -> MarketChartLook.Type.Growing
},
)
}

View file

@ -36,6 +36,7 @@ fun MarketChartMini(
type: MarketChartLook.Type = MarketChartLook.Type.Growing,
growingColor: Color = TangemTheme.colors.icon.accent,
fallingColor: Color = TangemTheme.colors.icon.warning,
neutralColor: Color = TangemTheme.colors.icon.informative,
) {
val model = remember(rawData) {
CartesianChartModel(LineCartesianLayerModel.build { series(rawData.y) })
@ -44,6 +45,7 @@ fun MarketChartMini(
val lineColor = when (type) {
MarketChartLook.Type.Growing -> growingColor
MarketChartLook.Type.Falling -> fallingColor
MarketChartLook.Type.Neutral -> neutralColor
}
val lineSpec = rememberLine(
@ -85,6 +87,8 @@ private fun Preview() {
MarketChartMini(rawData = data, type = MarketChartLook.Type.Growing)
SpacerH16()
MarketChartMini(rawData = data, type = MarketChartLook.Type.Falling)
SpacerH16()
MarketChartMini(rawData = data, type = MarketChartLook.Type.Neutral)
}
}
}

View file

@ -24,5 +24,6 @@ data class MarketChartLook(
enum class Type {
Growing,
Falling,
Neutral,
}
}

View file

@ -24,6 +24,7 @@ fun rememberMarketChartState(
when (it) {
MarketChartLook.Type.Growing -> Color.Green
MarketChartLook.Type.Falling -> Color.Red
MarketChartLook.Type.Neutral -> Color.Gray
}
}
},