Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-17 13:56:42 +04:00
parent 75802c1551
commit 1ca2672884
42 changed files with 160 additions and 625 deletions

View file

@ -19,10 +19,6 @@
"name": "TWI_485_USEDESK_ENABLED",
"version": "undefined"
},
{
"name": "APP_REDESIGN_ENABLED",
"version": "6.0"
},
{
"name": "VIRTUAL_ACCOUNTS_ENABLED",
"version": "undefined"

View file

@ -39,7 +39,6 @@ internal class FeatureTogglesNamingConventionTest {
/** Toggles created before the AND_/TWI_ naming convention. Do NOT add new entries. */
val EXCLUDED_TOGGLES_LIST = setOf(
"ADDRESS_SYNC_ENABLED",
"APP_REDESIGN_ENABLED",
"NEW_CARD_SCANNING_ENABLED",
"VIRTUAL_ACCOUNTS_ENABLED",
"VISA_ONBOARDING_ENABLED",

View file

@ -1,7 +0,0 @@
package com.tangem.core.ui
interface DesignFeatureToggles {
val isRedesignEnabled: Boolean
val isWarningsRefactoringEnabled: Boolean
}

View file

@ -19,6 +19,4 @@ interface UiDependencies {
val globalTopSnackbarHostState: TangemTopSnackbarHostState
val eventMessageHandler: EventMessageHandler
val designFeatureToggles: DesignFeatureToggles
}

View file

@ -10,44 +10,15 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.tangem.core.ui.R
import com.tangem.core.ui.components.buttons.SecondarySmallButton
import com.tangem.core.ui.components.buttons.SmallButtonConfig
import com.tangem.core.ui.ds.button.*
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.res.LocalRedesignEnabled
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.core.ui.res.TangemThemePreviewRedesign
@Composable
fun UnableToLoadData(onRetryClick: () -> Unit, modifier: Modifier = Modifier) {
if (LocalRedesignEnabled.current) {
UnableToLoadDataV2(onRetryClick, modifier)
} else {
UnableToLoadDataV1(onRetryClick, modifier)
}
}
@Composable
private fun UnableToLoadDataV1(onRetryClick: () -> Unit, modifier: Modifier = Modifier) {
Column(
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing12),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = stringResourceSafe(R.string.markets_loading_error_title),
style = TangemTheme.typography.caption1,
color = TangemTheme.colors.text.tertiary,
)
SecondarySmallButton(
config = SmallButtonConfig(
text = resourceReference(R.string.try_to_load_data_again_button_title),
onClick = onRetryClick,
),
)
}
UnableToLoadDataV2(onRetryClick, modifier)
}
@Composable
@ -80,13 +51,4 @@ private fun PreviewV2() {
TangemThemePreviewRedesign {
UnableToLoadDataV2(onRetryClick = {})
}
}
@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun PreviewV1() {
TangemThemePreview {
UnableToLoadDataV1(onRetryClick = {})
}
}

View file

@ -2,22 +2,13 @@ package com.tangem.core.ui.components.bottomsheets.message
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.tangem.core.ui.res.LocalRedesignEnabled
@Composable
fun MessageBottomSheet(state: MessageBottomSheetUM, onDismissRequest: () -> Unit) {
if (LocalRedesignEnabled.current) {
MessageBottomSheetV2(state, onDismissRequest)
} else {
MessageBottomSheetV1(state, onDismissRequest)
}
MessageBottomSheetV2(state, onDismissRequest)
}
@Composable
fun MessageBottomSheetContent(state: MessageBottomSheetUM, modifier: Modifier = Modifier) {
if (LocalRedesignEnabled.current) {
MessageBottomSheetContentV2(state, modifier)
} else {
MessageBottomSheetContentV1(state, modifier)
}
MessageBottomSheetContentV2(state, modifier)
}

View file

@ -19,7 +19,6 @@ 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
@ -51,11 +50,7 @@ fun TangemCurrencyIcon(state: CurrencyIconState, modifier: Modifier = Modifier,
modifier = iconModifier,
shouldShowTopBadge = shouldDisplayNetwork,
networkBadgeSize = 14.dp,
networkBadgeBackground = if (LocalRedesignEnabled.current) {
TangemTheme.colors2.surface.level1
} else {
TangemTheme.colors.background.primary
},
networkBadgeBackground = TangemTheme.colors2.surface.level1,
)
}
}

View file

@ -7,10 +7,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
@ -21,7 +19,6 @@ import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.res.LocalRedesignEnabled
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.core.ui.res.TangemThemePreviewRedesign
@ -34,67 +31,13 @@ fun DescriptionItem(
hasFullDescription: Boolean,
onReadMoreClick: () -> Unit,
modifier: Modifier = Modifier,
textStyle: TextStyle = TangemTheme.typography.body2,
) {
if (LocalRedesignEnabled.current) {
DescriptionItemV2(
description = description,
hasFullDescription = hasFullDescription,
onReadMoreClick = onReadMoreClick,
modifier = modifier,
)
} else {
DescriptionItemV1(
description = description,
hasFullDescription = hasFullDescription,
onReadMoreClick = onReadMoreClick,
modifier = modifier,
textStyle = textStyle,
)
}
}
@Composable
private fun DescriptionItemV1(
description: TextReference,
hasFullDescription: Boolean,
onReadMoreClick: () -> Unit,
modifier: Modifier = Modifier,
textStyle: TextStyle = TangemTheme.typography.body2,
) {
if (hasFullDescription) {
val text = buildAnnotatedString {
withStyle(SpanStyle(color = TangemTheme.colors.text.secondary)) {
append(description.resolveReference())
}
withStyle(SpanStyle(color = TangemTheme.colors.text.accent)) {
append(
" " + stringResourceSafe(R.string.common_read_more).replace(
' ',
StringsSigns.NON_BREAKING_SPACE,
),
)
}
}
Text(
modifier = modifier
.clickable(
interactionSource = null,
indication = null,
onClick = onReadMoreClick,
),
text = text,
style = textStyle,
)
} else {
Text(
modifier = modifier,
text = description.resolveReference(),
style = textStyle,
color = TangemTheme.colors.text.secondary,
)
}
DescriptionItemV2(
description = description,
hasFullDescription = hasFullDescription,
onReadMoreClick = onReadMoreClick,
modifier = modifier,
)
}
@Composable
@ -141,34 +84,7 @@ private fun DescriptionItemV2(
@Composable
fun DescriptionPlaceholder(modifier: Modifier = Modifier) {
if (LocalRedesignEnabled.current) {
DescriptionPlaceholderV2(modifier)
} else {
DescriptionPlaceholderV1(modifier)
}
}
@Composable
private fun DescriptionPlaceholderV1(modifier: Modifier = Modifier) {
Column(
modifier = modifier,
) {
TextShimmer(
modifier = Modifier.fillMaxWidth(),
style = TangemTheme.typography.body2,
textSizeHeight = true,
)
TextShimmer(
modifier = Modifier.fillMaxWidth(),
style = TangemTheme.typography.body2,
textSizeHeight = true,
)
TextShimmer(
modifier = Modifier.fillMaxWidth(fraction = 0.8f),
style = TangemTheme.typography.body2,
textSizeHeight = true,
)
}
DescriptionPlaceholderV2(modifier)
}
@Composable
@ -213,17 +129,15 @@ private fun ContentPreviewV1() {
@Preview
@Composable
private fun ContentPreviewV2() {
CompositionLocalProvider(LocalRedesignEnabled provides true) {
TangemThemePreviewRedesign {
DescriptionItem(
description = stringReference(
"XRP (XRP) is a cryptocurrency launched in January 2009, where the first " +
"genesis block was mined on 9th January 2009",
),
hasFullDescription = true,
onReadMoreClick = {},
)
}
TangemThemePreviewRedesign {
DescriptionItem(
description = stringReference(
"XRP (XRP) is a cryptocurrency launched in January 2009, where the first " +
"genesis block was mined on 9th January 2009",
),
hasFullDescription = true,
onReadMoreClick = {},
)
}
}
@ -245,16 +159,14 @@ private fun PreviewPlaceholderV1() {
@Preview
@Composable
private fun PreviewPlaceholderV2() {
CompositionLocalProvider(LocalRedesignEnabled provides true) {
TangemThemePreviewRedesign {
PreviewShimmerContainer(
actualContent = {
ContentPreviewV2()
},
shimmerContent = {
DescriptionPlaceholder()
},
)
}
TangemThemePreviewRedesign {
PreviewShimmerContainer(
actualContent = {
ContentPreviewV2()
},
shimmerContent = {
DescriptionPlaceholder()
},
)
}
}

View file

@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
@ -14,7 +13,6 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import com.tangem.core.ui.R
import com.tangem.core.ui.res.LocalRedesignEnabled
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.core.ui.res.TangemThemePreviewRedesign
@ -27,72 +25,13 @@ fun PriceChangeInPercent(
modifier: Modifier = Modifier,
isDisabled: Boolean = false,
) {
if (LocalRedesignEnabled.current) {
PriceChangeInPercentV2(
modifier = modifier,
valueInPercent = valueInPercent,
type = type,
textStyle = textStyle,
isDisabled = isDisabled,
)
} else {
PriceChangeInPercentV1(
modifier = modifier,
valueInPercent = valueInPercent,
type = type,
textStyle = textStyle,
)
}
}
@Composable
private fun PriceChangeInPercentV1(
valueInPercent: String,
type: PriceChangeType,
textStyle: TextStyle,
modifier: Modifier = Modifier,
) {
if (valueInPercent.isBlank()) {
Box(modifier)
return
}
Row(
PriceChangeInPercentV2(
modifier = modifier,
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing2),
) {
Icon(
modifier = Modifier
.size(TangemTheme.dimens.size8)
.align(Alignment.CenterVertically),
imageVector = ImageVector.vectorResource(
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,
)
Text(
text = valueInPercent,
color = when (type) {
PriceChangeType.UP -> TangemTheme.colors.text.accent
PriceChangeType.DOWN -> TangemTheme.colors.text.warning
PriceChangeType.NEUTRAL -> TangemTheme.colors.text.disabled
},
style = textStyle,
overflow = TextOverflow.Visible,
maxLines = 1,
)
}
valueInPercent = valueInPercent,
type = type,
textStyle = textStyle,
isDisabled = isDisabled,
)
}
@Composable
@ -191,31 +130,29 @@ private fun PreviewV1() {
@Composable
private fun PreviewV2() {
TangemThemePreviewRedesign {
CompositionLocalProvider(LocalRedesignEnabled provides true) {
Column {
PriceChangeInPercent(
valueInPercent = "52.00%",
type = PriceChangeType.NEUTRAL,
textStyle = TangemTheme.typography2.captionRegular12,
)
PriceChangeInPercent(
valueInPercent = "52.00%",
type = PriceChangeType.UP,
textStyle = TangemTheme.typography2.captionRegular12,
isDisabled = true,
)
PriceChangeInPercent(
valueInPercent = "52.00%",
type = PriceChangeType.DOWN,
textStyle = TangemTheme.typography2.captionRegular12,
isDisabled = false,
)
PriceChangeInPercent(
valueInPercent = "52.00%",
type = PriceChangeType.DOWN,
textStyle = TangemTheme.typography2.captionRegular12,
)
}
Column {
PriceChangeInPercent(
valueInPercent = "52.00%",
type = PriceChangeType.NEUTRAL,
textStyle = TangemTheme.typography2.captionRegular12,
)
PriceChangeInPercent(
valueInPercent = "52.00%",
type = PriceChangeType.UP,
textStyle = TangemTheme.typography2.captionRegular12,
isDisabled = true,
)
PriceChangeInPercent(
valueInPercent = "52.00%",
type = PriceChangeType.DOWN,
textStyle = TangemTheme.typography2.captionRegular12,
isDisabled = false,
)
PriceChangeInPercent(
valueInPercent = "52.00%",
type = PriceChangeType.DOWN,
textStyle = TangemTheme.typography2.captionRegular12,
)
}
}
}

View file

@ -6,9 +6,6 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.SnackbarResult
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -28,10 +25,6 @@ import com.tangem.core.ui.res.*
@Composable
fun EventMessageEffect(
messageHandler: EventMessageHandler = LocalEventMessageHandler.current,
snackbarHostState: SnackbarHostState = LocalSnackbarHostState.current,
onShowSnackbar: suspend (SnackbarMessage, Context) -> Unit = { message, context ->
showSnackbar(snackbarHostState, message, context)
},
topSnackbarHostState: TangemTopSnackbarHostState = LocalTopSnackbarHostState.current,
onShowTopSnackbar: suspend (SnackbarMessage) -> Unit = { message ->
topSnackbarHostState.showSnackbar(message)
@ -44,16 +37,11 @@ fun EventMessageEffect(
var dialogMessage: DialogMessage? by remember { mutableStateOf(value = null) }
var bottomSheetMessage: BottomSheetMessage? by remember { mutableStateOf(value = null) }
var loadingMessage: GlobalLoadingMessage? by remember { mutableStateOf(value = null) }
val isRedesignEnabled = LocalRedesignEnabled.current
EventEffect(event = messageEvent) { message ->
when (message) {
is SnackbarMessage -> {
if (isRedesignEnabled) {
onShowTopSnackbar(message)
} else {
onShowSnackbar(message, context)
}
onShowTopSnackbar(message)
}
is DialogMessage -> {
dialogMessage = message
@ -155,23 +143,6 @@ private fun MessageDialog(message: DialogMessage, onDismissRequest: () -> Unit)
)
}
private suspend fun showSnackbar(snackbarHostState: SnackbarHostState, message: SnackbarMessage, context: Context) {
val result = snackbarHostState.showSnackbar(
message = message.message.resolveReference(context.resources),
actionLabel = message.actionLabel?.resolveReference(context.resources),
duration = when (message.duration) {
SnackbarMessage.Duration.Short -> SnackbarDuration.Short
SnackbarMessage.Duration.Long -> SnackbarDuration.Long
SnackbarMessage.Duration.Indefinite -> SnackbarDuration.Indefinite
},
)
when (result) {
SnackbarResult.Dismissed -> message.onDismissRequest()
SnackbarResult.ActionPerformed -> message.action?.invoke()
}
}
private fun showToast(message: ToastMessage, context: Context) {
Toast.makeText(
/* context = */ context,

View file

@ -65,11 +65,7 @@ fun TangemTheme(
typography = typography,
dimens = dimens,
content = {
if (uiDependencies.designFeatureToggles.isRedesignEnabled) {
TangemThemeRedesign { content() }
} else {
content()
}
TangemThemeRedesign { content() }
},
)
}
@ -452,14 +448,6 @@ val LocalHazeState = staticCompositionLocalOf<HazeState> {
error("No HazeState provided")
}
val LocalRedesignEnabled = staticCompositionLocalOf<Boolean> {
false
}
val LocalVisaRedesignEnabled = staticCompositionLocalOf<Boolean> {
false
}
val LocalPowerSavingState = compositionLocalOf<PowerSavingState> {
error("No PowerSavingState provided")
}

View file

@ -37,7 +37,6 @@ fun TangemThemeRedesign(content: @Composable () -> Unit) {
colorScheme = tangemColorScheme(colors = rememberedColors),
) {
CompositionLocalProvider(
LocalRedesignEnabled provides true,
LocalTangemColors provides rememberedColors,
LocalTangemColors2 provides if (LocalIsInDarkTheme.current) darkThemeColors2() else lightThemeColors2(),
LocalTangemColors3 provides rememberedColors3,