Updated on 2026-08-14
This commit is contained in:
parent
75802c1551
commit
1ca2672884
42 changed files with 160 additions and 625 deletions
|
|
@ -4,7 +4,6 @@ import android.content.res.Configuration
|
|||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
|
@ -93,11 +92,9 @@ private fun PreviewV1() {
|
|||
@Composable
|
||||
private fun PreviewV2() {
|
||||
TangemThemePreviewRedesign {
|
||||
CompositionLocalProvider(LocalRedesignEnabled provides true) {
|
||||
Column(Modifier.background(TangemTheme.colors2.surface.level3)) {
|
||||
repeat(20) {
|
||||
MarketsListItemPlaceholder()
|
||||
}
|
||||
Column(Modifier.background(TangemTheme.colors2.surface.level3)) {
|
||||
repeat(20) {
|
||||
MarketsListItemPlaceholder()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,9 @@ object QuickActionsConverter {
|
|||
fun quickActions(
|
||||
cryptoData: CryptoCurrencyData,
|
||||
tokenActionsHandler: TokenActionsHandler,
|
||||
isRedesignEnabled: Boolean,
|
||||
context: TokenActionsContext = TokenActionsContext.Markets,
|
||||
): QuickActions {
|
||||
val states = toQuickActionStates(cryptoData.actions, isRedesignEnabled, context)
|
||||
val states = toQuickActionStates(cryptoData.actions, context)
|
||||
return QuickActions(
|
||||
actions = states.map { it.action }.toImmutableList(),
|
||||
onQuickActionClick = { quickActionUM ->
|
||||
|
|
@ -70,21 +69,18 @@ object QuickActionsConverter {
|
|||
*/
|
||||
fun toQuickActions(
|
||||
actions: List<TokenActionsState.ActionState>,
|
||||
isRedesignEnabled: Boolean,
|
||||
context: TokenActionsContext = TokenActionsContext.Markets,
|
||||
): ImmutableList<QuickActionUM> =
|
||||
toQuickActionStates(actions, isRedesignEnabled, context).map { it.action }.toImmutableList()
|
||||
): ImmutableList<QuickActionUM> = toQuickActionStates(actions, context).map { it.action }.toImmutableList()
|
||||
|
||||
private fun toQuickActionStates(
|
||||
actions: List<TokenActionsState.ActionState>,
|
||||
isRedesignEnabled: Boolean,
|
||||
context: TokenActionsContext,
|
||||
): List<QuickActionState> {
|
||||
val allowed = context.allowedActionsInOrder
|
||||
?: return actions
|
||||
.filter { it.unavailabilityReason == ScenarioUnavailabilityReason.None }
|
||||
.mapNotNull { action ->
|
||||
action.toQuickActionUM(isRedesignEnabled)?.let { QuickActionState(it, isEnabled = true) }
|
||||
action.toQuickActionUM()?.let { QuickActionState(it, isEnabled = true) }
|
||||
}
|
||||
|
||||
val byBsAction = actions.associateBy { it.toBsAction() }
|
||||
|
|
@ -94,13 +90,13 @@ object QuickActionsConverter {
|
|||
when (action) {
|
||||
TokenActionsBSContentUM.Action.SendWithSwap ->
|
||||
if (isExchangeAvailable) {
|
||||
QuickActionState(swapAndSendUM(isRedesignEnabled), isEnabled = true)
|
||||
QuickActionState(QuickActionUM.V2.SwapAndSend, isEnabled = true)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
else -> {
|
||||
val state = byBsAction[action] ?: return@mapNotNull null
|
||||
val um = state.toQuickActionUM(isRedesignEnabled) ?: return@mapNotNull null
|
||||
val um = state.toQuickActionUM() ?: return@mapNotNull null
|
||||
QuickActionState(um, isEnabled = state.unavailabilityReason == ScenarioUnavailabilityReason.None)
|
||||
}
|
||||
}
|
||||
|
|
@ -109,13 +105,7 @@ object QuickActionsConverter {
|
|||
|
||||
private data class QuickActionState(val action: QuickActionUM, val isEnabled: Boolean)
|
||||
|
||||
private fun swapAndSendUM(isRedesignEnabled: Boolean): QuickActionUM =
|
||||
if (isRedesignEnabled) QuickActionUM.V2.SwapAndSend else QuickActionUM.V1.SwapAndSend
|
||||
|
||||
private fun TokenActionsState.ActionState.toQuickActionUM(isRedesignEnabled: Boolean): QuickActionUM? =
|
||||
if (isRedesignEnabled) toV2() else toV1()
|
||||
|
||||
private fun TokenActionsState.ActionState.toV2(): QuickActionUM? = when (this) {
|
||||
private fun TokenActionsState.ActionState.toQuickActionUM(): QuickActionUM? = when (this) {
|
||||
is TokenActionsState.ActionState.Buy -> QuickActionUM.V2.Buy
|
||||
is TokenActionsState.ActionState.Swap -> QuickActionUM.V2.Exchange(shouldShowBadge)
|
||||
is TokenActionsState.ActionState.Receive -> QuickActionUM.V2.Receive
|
||||
|
|
@ -126,17 +116,6 @@ object QuickActionsConverter {
|
|||
else -> null
|
||||
}
|
||||
|
||||
private fun TokenActionsState.ActionState.toV1(): QuickActionUM? = when (this) {
|
||||
is TokenActionsState.ActionState.Buy -> QuickActionUM.V1.Buy
|
||||
is TokenActionsState.ActionState.Swap -> QuickActionUM.V1.Exchange(shouldShowBadge)
|
||||
is TokenActionsState.ActionState.Receive -> QuickActionUM.V1.Receive
|
||||
is TokenActionsState.ActionState.Send -> QuickActionUM.V1.Send
|
||||
is TokenActionsState.ActionState.Sell -> QuickActionUM.V1.Sell
|
||||
is TokenActionsState.ActionState.Stake -> QuickActionUM.V1.Stake
|
||||
is TokenActionsState.ActionState.YieldMode -> QuickActionUM.V1.YieldMode(apy)
|
||||
else -> null
|
||||
}
|
||||
|
||||
private fun TokenActionsState.ActionState.toBsAction(): TokenActionsBSContentUM.Action? = when (this) {
|
||||
is TokenActionsState.ActionState.Buy -> TokenActionsBSContentUM.Action.Buy
|
||||
is TokenActionsState.ActionState.Swap -> TokenActionsBSContentUM.Action.Exchange
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ internal class QuickActionsConverterTest {
|
|||
// Act
|
||||
val result = QuickActionsConverter.toQuickActions(
|
||||
actions = actions,
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.AddFunds,
|
||||
)
|
||||
|
||||
|
|
@ -45,7 +44,6 @@ internal class QuickActionsConverterTest {
|
|||
// Act
|
||||
val result = QuickActionsConverter.toQuickActions(
|
||||
actions = actions,
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.Markets,
|
||||
)
|
||||
|
||||
|
|
@ -68,7 +66,6 @@ internal class QuickActionsConverterTest {
|
|||
// Act
|
||||
val result = QuickActionsConverter.toQuickActions(
|
||||
actions = actions,
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.Markets,
|
||||
)
|
||||
|
||||
|
|
@ -92,7 +89,6 @@ internal class QuickActionsConverterTest {
|
|||
// Act
|
||||
val result = QuickActionsConverter.toQuickActions(
|
||||
actions = actions,
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.Transfer,
|
||||
)
|
||||
|
||||
|
|
@ -116,7 +112,6 @@ internal class QuickActionsConverterTest {
|
|||
// Act
|
||||
val result = QuickActionsConverter.toQuickActions(
|
||||
actions = actions,
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.Transfer,
|
||||
)
|
||||
|
||||
|
|
@ -141,7 +136,6 @@ internal class QuickActionsConverterTest {
|
|||
// Act
|
||||
val result = QuickActionsConverter.toQuickActions(
|
||||
actions = actions,
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.AddFunds,
|
||||
)
|
||||
|
||||
|
|
@ -167,7 +161,6 @@ internal class QuickActionsConverterTest {
|
|||
// Act
|
||||
val result = QuickActionsConverter.toQuickActions(
|
||||
actions = actions,
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.Transfer,
|
||||
)
|
||||
|
||||
|
|
@ -194,7 +187,6 @@ internal class QuickActionsConverterTest {
|
|||
val result = QuickActionsConverter.quickActions(
|
||||
cryptoData = cryptoData(actions),
|
||||
tokenActionsHandler = mockk(relaxed = true),
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.Transfer,
|
||||
)
|
||||
|
||||
|
|
@ -215,7 +207,6 @@ internal class QuickActionsConverterTest {
|
|||
val result = QuickActionsConverter.quickActions(
|
||||
cryptoData = cryptoData(actions),
|
||||
tokenActionsHandler = mockk(relaxed = true),
|
||||
isRedesignEnabled = true,
|
||||
context = TokenActionsContext.AddFunds,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,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.runtime.Immutable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -30,7 +29,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
|
||||
|
|
@ -190,12 +188,10 @@ private fun PortfolioSelectRowPreview(@PreviewParameter(PreviewProvider::class)
|
|||
@Composable
|
||||
private fun PortfolioSelectRowPreviewV2(@PreviewParameter(PreviewProvider::class) state: PortfolioSelectUM) {
|
||||
TangemThemePreviewRedesign {
|
||||
CompositionLocalProvider(LocalRedesignEnabled provides true) {
|
||||
PortfolioSelectRowV2(
|
||||
state = state,
|
||||
modifier = Modifier.background(TangemTheme.colors2.surface.level3),
|
||||
)
|
||||
}
|
||||
PortfolioSelectRowV2(
|
||||
state = state,
|
||||
modifier = Modifier.background(TangemTheme.colors2.surface.level3),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|||
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.Color
|
||||
|
|
@ -37,7 +36,6 @@ import com.tangem.core.ui.ds.row.TangemRowContainer
|
|||
import com.tangem.core.ui.ds.row.TangemRowLayoutId
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
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.TangemThemePreviewRedesign
|
||||
|
||||
|
|
@ -202,15 +200,13 @@ private fun AddButton(state: AddTokenUM.Button, modifier: Modifier = Modifier) {
|
|||
@Composable
|
||||
private fun Preview(@PreviewParameter(PreviewProvider::class) state: AddTokenUM) {
|
||||
TangemThemePreviewRedesign {
|
||||
CompositionLocalProvider(LocalRedesignEnabled provides true) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(TangemTheme.colors2.surface.level2)
|
||||
.padding(horizontal = 16.dp),
|
||||
) {
|
||||
AddTokenContentV2(state = state)
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(TangemTheme.colors2.surface.level2)
|
||||
.padding(horizontal = 16.dp),
|
||||
) {
|
||||
AddTokenContentV2(state = state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
package com.tangem.common.ui.expressStatus
|
||||
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.tangem.common.ui.R
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateIconUM
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateUM
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
|
||||
fun LazyListScope.expressTransactionsItemsLegacy(
|
||||
expressTxs: PersistentList<ExpressTransactionStateUM>,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
items(
|
||||
count = expressTxs.size,
|
||||
key = { index -> expressTxs[index].info.txId },
|
||||
contentType = { index -> expressTxs[index]::class.java },
|
||||
) { index ->
|
||||
val itemInfo = expressTxs[index].info
|
||||
val (iconRes, tint) = when (itemInfo.iconState) {
|
||||
ExpressTransactionStateIconUM.Warning -> {
|
||||
R.drawable.ic_alert_triangle_20 to TangemTheme.colors.icon.attention
|
||||
}
|
||||
ExpressTransactionStateIconUM.Error -> {
|
||||
R.drawable.ic_alert_circle_24 to TangemTheme.colors.icon.warning
|
||||
}
|
||||
ExpressTransactionStateIconUM.None -> null to null
|
||||
}
|
||||
|
||||
ExpressStatusItem(
|
||||
title = itemInfo.title,
|
||||
fromTokenIconState = itemInfo.fromCurrencyIcon,
|
||||
toTokenIconState = itemInfo.toCurrencyIcon,
|
||||
fromAmount = itemInfo.fromAmount,
|
||||
fromSymbol = itemInfo.fromAmountSymbol,
|
||||
toAmount = itemInfo.toAmount,
|
||||
toSymbol = itemInfo.toAmountSymbol,
|
||||
subtitle = itemInfo.subtitle,
|
||||
onClick = itemInfo.onClick,
|
||||
infoIconRes = iconRes,
|
||||
infoIconTint = tint,
|
||||
modifier = modifier.animateItem(),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue