Updated on 2026-08-14
This commit is contained in:
parent
94a9b132a2
commit
5b8839cf52
3 changed files with 70 additions and 45 deletions
|
|
@ -243,6 +243,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
primaryMinimumAmountBoundary = primaryMinimumAmountBoundary,
|
||||
secondaryMinimumAmountBoundary = secondaryMinimumAmountBoundary,
|
||||
value = value,
|
||||
isBalanceHidden = params.isBalanceHidingFlow.value,
|
||||
),
|
||||
)
|
||||
quoteTaskScheduler.cancelTask()
|
||||
|
|
@ -808,6 +809,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
primaryMinimumAmountBoundary = primaryMinimumAmountBoundary,
|
||||
secondaryMinimumAmountBoundary = secondaryMinimumAmountBoundary,
|
||||
value = secondaryValue,
|
||||
isBalanceHidden = params.isBalanceHidingFlow.value,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.tangem.domain.swap.models.SwapDirection
|
|||
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
|
||||
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
|
||||
import com.tangem.features.swap.v2.impl.amount.model.SwapAmountQuoteUtils.updateAmount
|
||||
import com.tangem.features.swap.v2.impl.amount.model.converter.SwapAmountUpdateSubtitleConverter
|
||||
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ internal class SwapAmountValueChangeTransformer(
|
|||
private val secondaryMaximumAmountBoundary: EnterAmountBoundary?,
|
||||
private val secondaryMinimumAmountBoundary: EnterAmountBoundary?,
|
||||
private val value: String,
|
||||
private val isBalanceHidden: Boolean,
|
||||
) : Transformer<SwapAmountUM> {
|
||||
override fun transform(prevState: SwapAmountUM): SwapAmountUM {
|
||||
if (prevState !is SwapAmountUM.Content) return prevState
|
||||
|
|
@ -50,7 +52,7 @@ internal class SwapAmountValueChangeTransformer(
|
|||
val contentState = updatedState as? SwapAmountUM.Content ?: return updatedState
|
||||
|
||||
val newState = if (value.isEmpty()) {
|
||||
contentState.clearOppositeField(prevState)
|
||||
contentState.clearOppositeField(prevState).updateSubtitlesForEmptyState()
|
||||
} else {
|
||||
contentState
|
||||
}
|
||||
|
|
@ -65,6 +67,32 @@ internal class SwapAmountValueChangeTransformer(
|
|||
)
|
||||
}
|
||||
|
||||
private fun SwapAmountUM.Content.updateSubtitlesForEmptyState(): SwapAmountUM.Content {
|
||||
val subtitleConverter = SwapAmountUpdateSubtitleConverter(
|
||||
selectedAmountType = selectedAmountType,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
val updatedPrimary = (primaryAmount as? SwapAmountFieldUM.Content)?.let { field ->
|
||||
subtitleConverter.updateSubtitles(
|
||||
field = field,
|
||||
cryptoCurrencyStatus = primaryCryptoCurrencyStatus,
|
||||
isAmountEmpty = true,
|
||||
)
|
||||
} ?: primaryAmount
|
||||
val secondaryField = secondaryAmount as? SwapAmountFieldUM.Content
|
||||
val secondaryStatus = secondaryCryptoCurrencyStatus
|
||||
val updatedSecondary = if (secondaryField != null && secondaryStatus != null) {
|
||||
subtitleConverter.updateSubtitles(
|
||||
field = secondaryField,
|
||||
cryptoCurrencyStatus = secondaryStatus,
|
||||
isAmountEmpty = true,
|
||||
)
|
||||
} else {
|
||||
secondaryAmount
|
||||
}
|
||||
return copy(primaryAmount = updatedPrimary, secondaryAmount = updatedSecondary)
|
||||
}
|
||||
|
||||
private fun SwapAmountUM.Content.clearOppositeField(prevState: SwapAmountUM.Content): SwapAmountUM.Content {
|
||||
val isPrimaryFieldEdited =
|
||||
selectedAmountType == SwapAmountType.From && swapDirection == SwapDirection.Direct
|
||||
|
|
|
|||
|
|
@ -348,55 +348,50 @@ private fun SwapAmountInfoMain(
|
|||
}
|
||||
|
||||
AnimatedContent(selectedQuote) { quote ->
|
||||
when (quote) {
|
||||
is SwapQuoteUM.Content -> {
|
||||
SpacerH2()
|
||||
if (amountFieldUM is SwapAmountFieldUM.Content) {
|
||||
SpacerH2()
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
EllipsisText(
|
||||
text = amountFieldUM.subtitleLeft.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = amountFieldUM.subtitleEllipsisLeft,
|
||||
modifier = Modifier.weight(1f, fill = false),
|
||||
)
|
||||
EllipsisText(
|
||||
text = amountFieldUM.subtitleRight.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = amountFieldUM.subtitleEllipsisRight,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
SpacerH2()
|
||||
TextShimmer(
|
||||
style = TangemTheme.typography.caption2,
|
||||
modifier = Modifier.width(72.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
SwapQuoteUM.Loading -> {
|
||||
SpacerH2()
|
||||
TextShimmer(
|
||||
style = TangemTheme.typography.caption2,
|
||||
modifier = Modifier.width(72.dp),
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
SpacerH2()
|
||||
Text(
|
||||
text = "",
|
||||
style = TangemTheme.typography.caption2,
|
||||
)
|
||||
}
|
||||
if (quote is SwapQuoteUM.Loading) {
|
||||
SpacerH2()
|
||||
TextShimmer(
|
||||
style = TangemTheme.typography.caption2,
|
||||
modifier = Modifier.width(72.dp),
|
||||
)
|
||||
} else {
|
||||
SwapAmountSubtitle(amountFieldUM)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SwapAmountSubtitle(amountFieldUM: SwapAmountFieldUM) {
|
||||
SpacerH2()
|
||||
if (amountFieldUM is SwapAmountFieldUM.Content) {
|
||||
SpacerH2()
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
EllipsisText(
|
||||
text = amountFieldUM.subtitleLeft.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = amountFieldUM.subtitleEllipsisLeft,
|
||||
modifier = Modifier.weight(1f, fill = false),
|
||||
)
|
||||
EllipsisText(
|
||||
text = amountFieldUM.subtitleRight.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = amountFieldUM.subtitleEllipsisRight,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
SpacerH2()
|
||||
TextShimmer(
|
||||
style = TangemTheme.typography.caption2,
|
||||
modifier = Modifier.width(72.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AmountMaxButton(onMaxAmountClick: () -> Unit) {
|
||||
Text(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue