Updated on 2026-08-14

This commit is contained in:
Tangem 2026-05-05 08:36:44 +02:00
parent c0fa56e200
commit 369f3bbd44
19 changed files with 283 additions and 86 deletions

View file

@ -46,7 +46,7 @@ enum class AccountIconSize {
@Composable
fun AccountResIcon(@DrawableRes resId: Int, color: Color, size: AccountIconSize, modifier: Modifier = Modifier) {
val boxSize by animateDpAsState(
targetValue = size.boxSizeInDp(),
targetValue = size.toBoxSize(),
animationSpec = animation(),
)
val boxShapeCornerSize by animateDpAsState(
@ -84,7 +84,7 @@ fun AccountResIcon(@DrawableRes resId: Int, color: Color, size: AccountIconSize,
@Composable
fun PaymentAccountIcon(size: AccountIconSize, modifier: Modifier = Modifier) {
val boxSize by animateDpAsState(
targetValue = size.boxSizeInDp(),
targetValue = size.toBoxSize(),
animationSpec = animation(),
)
val boxShapeCornerSize by animateDpAsState(
@ -115,7 +115,7 @@ fun PaymentAccountIcon(size: AccountIconSize, modifier: Modifier = Modifier) {
@Composable
fun AccountCharIcon(char: Char, color: Color, size: AccountIconSize, modifier: Modifier = Modifier) {
val boxSize by animateDpAsState(
size.boxSizeInDp(),
size.toBoxSize(),
animationSpec = animation(),
)
val boxShapeCornerSize by animateDpAsState(
@ -163,7 +163,7 @@ private fun AccountIconSize.iconSizeInDp(): Dp = when (this) {
AccountIconSize.RedesignedDefault -> 20.dp
}
private fun AccountIconSize.boxSizeInDp(): Dp = when (this) {
fun AccountIconSize.toBoxSize(): Dp = when (this) {
AccountIconSize.Default -> 36.dp
AccountIconSize.Large -> 88.dp
AccountIconSize.Medium -> 28.dp

View file

@ -19,10 +19,49 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.tangem.core.ui.components.CircleShimmer
import com.tangem.core.ui.extensions.conditional
import com.tangem.core.ui.res.LocalRedesignEnabled
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.test.TokenElementsTestTags
import com.tangem.core.ui.utils.getGreyScaleColorFilter
/**
* Cryptocurrency icon driven entirely by the supplied [modifier]: the icon and the network badge
* lay out within the size set by the modifier !!!no fixed icon/badge size params!!!.
* Use the more configurable [CurrencyIcon] when custom sizing is required.
*/
@Composable
fun TangemCurrencyIcon(state: CurrencyIconState, modifier: Modifier = Modifier, shouldDisplayNetwork: Boolean = true) {
Box(modifier = modifier) {
val iconModifier = Modifier.matchParentSize()
when (state) {
is CurrencyIconState.Loading -> LoadingIcon(modifier = iconModifier)
is CurrencyIconState.Locked -> LockedIcon(modifier = iconModifier)
is CurrencyIconState.Empty -> EmptyIcon(resId = state.resId, modifier = iconModifier)
is CurrencyIconState.CoinIcon,
is CurrencyIconState.FiatIcon,
is CurrencyIconState.CustomTokenIcon,
is CurrencyIconState.TokenIcon,
is CurrencyIconState.PaymentAccount,
is CurrencyIconState.CryptoPortfolio.Icon,
is CurrencyIconState.CryptoPortfolio.Letter,
-> {
ContentIconContainer(
icon = state,
modifier = iconModifier,
shouldShowTopBadge = shouldDisplayNetwork,
networkBadgeSize = 14.dp,
networkBadgeBackground = if (LocalRedesignEnabled.current) {
TangemTheme.colors2.surface.level1
} else {
TangemTheme.colors.background.primary
},
)
}
}
}
}
/**
* Cryptocurrency icon with network badge
*

View file

@ -16,8 +16,8 @@ import androidx.compose.ui.res.vectorResource
import coil.compose.SubcomposeAsyncImage
import coil.request.ImageRequest
import com.tangem.core.ui.components.CircleShimmer
import com.tangem.core.ui.components.currency.icon.CurrencyIcon
import com.tangem.core.ui.components.currency.icon.CurrencyIconState
import com.tangem.core.ui.components.currency.icon.TangemCurrencyIcon
import com.tangem.core.ui.components.icons.identicon.IdentIcon
import com.tangem.core.ui.extensions.ColorReference2
import com.tangem.core.ui.res.TangemTheme
@ -69,7 +69,7 @@ sealed interface TangemIconUM {
fun TangemIcon(tangemIconUM: TangemIconUM, modifier: Modifier = Modifier) {
when (tangemIconUM) {
is TangemIconUM.Currency -> {
CurrencyIcon(
TangemCurrencyIcon(
state = tangemIconUM.currencyIconState,
modifier = modifier,
)