Updated on 2026-08-14

This commit is contained in:
Tangem 2024-02-29 13:50:16 +00:00
commit 6d0b295ca3
219 changed files with 3720 additions and 1687 deletions

View file

@ -4,6 +4,10 @@ plugins {
id("configuration")
}
android {
namespace = "com.tangem.core.ui"
}
dependencies {
/** Project - Common */
implementation(projects.common)

View file

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.tangem.core.ui" />

View file

@ -1,6 +1,7 @@
package com.tangem.core.ui.components
import androidx.annotation.FloatRange
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.*
@ -84,9 +85,11 @@ fun ResizableText(
var readyToDraw by remember { mutableStateOf(value = false) }
Text(
modifier = modifier.drawWithContent {
if (readyToDraw) drawContent()
},
modifier = modifier
.drawWithContent {
if (readyToDraw) drawContent()
}
.wrapContentHeight(),
text = text,
color = color,
fontSize = fontSize,

View file

@ -163,11 +163,13 @@ private fun PriceChangeInPercent(config: PriceChangeState.Content) {
id = when (type) {
PriceChangeType.UP -> R.drawable.ic_arrow_up_8
PriceChangeType.DOWN -> R.drawable.ic_arrow_down_8
PriceChangeType.NEUTRAL -> R.drawable.ic_elipse_8
},
),
tint = when (type) {
PriceChangeType.UP -> TangemTheme.colors.icon.accent
PriceChangeType.DOWN -> TangemTheme.colors.icon.warning
PriceChangeType.NEUTRAL -> TangemTheme.colors.icon.inactive
},
contentDescription = null,
)
@ -177,6 +179,7 @@ private fun PriceChangeInPercent(config: PriceChangeState.Content) {
color = when (type) {
PriceChangeType.UP -> TangemTheme.colors.text.accent
PriceChangeType.DOWN -> TangemTheme.colors.text.warning
PriceChangeType.NEUTRAL -> TangemTheme.colors.text.disabled
},
style = TangemTheme.typography.body2,
)
@ -251,6 +254,14 @@ private class WalletMarketPriceBlockStateProvider : CollectionPreviewParameterPr
type = PriceChangeType.UP,
),
),
MarketPriceBlockState.Content(
currencySymbol = "BTC",
price = "98900 $",
priceChangeConfig = PriceChangeState.Content(
valueInPercent = "0.00%",
type = PriceChangeType.NEUTRAL,
),
),
MarketPriceBlockState.Loading(currencySymbol = "BTC"),
MarketPriceBlockState.Error(currencySymbol = "BTC"),
),

View file

@ -5,9 +5,4 @@ sealed class PriceChangeState {
data class Content(val valueInPercent: String, val type: PriceChangeType) : PriceChangeState()
object Unknown : PriceChangeState()
}
/** Price changing type */
enum class PriceChangeType {
UP, DOWN
}

View file

@ -0,0 +1,6 @@
package com.tangem.core.ui.components.marketprice
/** Price changing type */
enum class PriceChangeType {
UP, DOWN, NEUTRAL,
}

View file

@ -0,0 +1,21 @@
package com.tangem.core.ui.components.marketprice.utils
import com.tangem.core.ui.components.marketprice.PriceChangeType
import java.math.BigDecimal
import java.math.RoundingMode
object PriceChangeConverter {
fun fromBigDecimal(value: BigDecimal?, scale: Int = 2): PriceChangeType {
val formattedValue = value
?.movePointRight(2)
?.setScale(scale, RoundingMode.HALF_UP)
?: return PriceChangeType.NEUTRAL
return when (formattedValue.signum()) {
1 -> PriceChangeType.UP
-1 -> PriceChangeType.DOWN
else -> PriceChangeType.NEUTRAL
}
}
}

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="8dp"
android:height="8dp"
android:viewportWidth="8"
android:viewportHeight="8">
<path
android:fillColor="#000"
android:pathData="M3,4m-1,0a1,1 0,1 1,2 0a1,1 0,1 1,-2 0" />
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,8C13.061,8 14.078,8.421 14.828,9.172C15.578,9.922 16,10.939 16,12C16,13.061 15.578,14.078 14.828,14.828C14.078,15.579 13.061,16 12,16C10.939,16 9.922,15.579 9.172,14.828C8.421,14.078 8,13.061 8,12C8,10.939 8.421,9.922 9.172,9.172C9.922,8.421 10.939,8 12,8ZM12,10C11.469,10 10.961,10.211 10.586,10.586C10.211,10.961 10,11.47 10,12C10,12.53 10.211,13.039 10.586,13.414C10.961,13.789 11.469,14 12,14C12.53,14 13.039,13.789 13.414,13.414C13.789,13.039 14,12.53 14,12C14,11.47 13.789,10.961 13.414,10.586C13.039,10.211 12.53,10 12,10ZM10,22C9.75,22 9.54,21.82 9.5,21.58L9.13,18.93C8.5,18.68 7.96,18.34 7.44,17.94L4.95,18.95C4.73,19.03 4.46,18.95 4.34,18.73L2.34,15.27C2.21,15.05 2.27,14.78 2.46,14.63L4.57,12.97L4.5,12L4.57,11L2.46,9.37C2.27,9.22 2.21,8.95 2.34,8.73L4.34,5.27C4.46,5.05 4.73,4.96 4.95,5.05L7.44,6.05C7.96,5.66 8.5,5.32 9.13,5.07L9.5,2.42C9.54,2.18 9.75,2 10,2H14C14.25,2 14.46,2.18 14.5,2.42L14.87,5.07C15.5,5.32 16.04,5.66 16.56,6.05L19.05,5.05C19.27,4.96 19.54,5.05 19.66,5.27L21.66,8.73C21.79,8.95 21.73,9.22 21.54,9.37L19.43,11L19.5,12L19.43,13L21.54,14.63C21.73,14.78 21.79,15.05 21.66,15.27L19.66,18.73C19.54,18.95 19.27,19.04 19.05,18.95L16.56,17.95C16.04,18.34 15.5,18.68 14.87,18.93L14.5,21.58C14.46,21.82 14.25,22 14,22H10ZM11.25,4L10.88,6.61C9.68,6.86 8.62,7.5 7.85,8.39L5.44,7.35L4.69,8.65L6.8,10.2C6.4,11.37 6.4,12.64 6.8,13.8L4.68,15.36L5.43,16.66L7.86,15.62C8.63,16.5 9.68,17.14 10.87,17.38L11.24,20H12.76L13.13,17.39C14.32,17.14 15.37,16.5 16.14,15.62L18.57,16.66L19.32,15.36L17.2,13.81C17.6,12.64 17.6,11.37 17.2,10.2L19.31,8.65L18.56,7.35L16.15,8.39C15.38,7.5 14.32,6.86 13.12,6.62L12.75,4H11.25Z"
android:fillColor="#1E1E1E"/>
</vector>