Updated on 2026-08-14
This commit is contained in:
parent
04c90d11db
commit
f6d9c35468
6 changed files with 175 additions and 0 deletions
|
|
@ -0,0 +1,93 @@
|
|||
package com.tangem.features.swap.v2.impl.amount.entity
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.core.ui.components.atoms.text.TextEllipsis
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.express.models.ExpressRateType
|
||||
import com.tangem.domain.swap.models.SwapCurrencies
|
||||
import com.tangem.domain.swap.models.SwapDirection
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
internal sealed class SwapAmountUM {
|
||||
|
||||
abstract val isPrimaryButtonEnabled: Boolean
|
||||
abstract val primaryAmount: SwapAmountFieldUM
|
||||
abstract val secondaryAmount: SwapAmountFieldUM
|
||||
abstract val selectedAmountType: SwapAmountType
|
||||
|
||||
data object Empty : SwapAmountUM() {
|
||||
override val isPrimaryButtonEnabled = false
|
||||
override val selectedAmountType = SwapAmountType.From
|
||||
override val primaryAmount = SwapAmountFieldUM.Empty(SwapAmountType.From)
|
||||
override val secondaryAmount = SwapAmountFieldUM.Empty(SwapAmountType.To)
|
||||
}
|
||||
|
||||
data class Content(
|
||||
override val isPrimaryButtonEnabled: Boolean,
|
||||
|
||||
// two amount fields
|
||||
override val primaryAmount: SwapAmountFieldUM,
|
||||
override val secondaryAmount: SwapAmountFieldUM,
|
||||
override val selectedAmountType: SwapAmountType,
|
||||
val primaryCryptoCurrencyStatus: CryptoCurrencyStatus?,
|
||||
val secondaryCryptoCurrencyStatus: CryptoCurrencyStatus?,
|
||||
|
||||
// selected swap route
|
||||
val swapDirection: SwapDirection,
|
||||
val swapRateType: ExpressRateType,
|
||||
|
||||
// swap models
|
||||
val swapCurrencies: SwapCurrencies,
|
||||
val swapQuotes: ImmutableList<SwapQuoteUM>,
|
||||
val selectedQuote: SwapQuoteUM,
|
||||
|
||||
// extra data
|
||||
val appCurrency: AppCurrency?,
|
||||
) : SwapAmountUM()
|
||||
}
|
||||
|
||||
@Immutable
|
||||
sealed class SwapAmountFieldUM {
|
||||
abstract val amountType: SwapAmountType
|
||||
abstract val amountField: AmountState
|
||||
|
||||
data class Empty(
|
||||
override val amountType: SwapAmountType,
|
||||
) : SwapAmountFieldUM() {
|
||||
override val amountField: AmountState = AmountState.Empty(isPrimaryButtonEnabled = false)
|
||||
}
|
||||
|
||||
data class Loading(
|
||||
override val amountType: SwapAmountType,
|
||||
) : SwapAmountFieldUM() {
|
||||
override val amountField: AmountState = AmountState.Empty(isPrimaryButtonEnabled = false)
|
||||
}
|
||||
|
||||
data class Content(
|
||||
override val amountType: SwapAmountType,
|
||||
override val amountField: AmountState,
|
||||
val priceImpact: TextReference?,
|
||||
val title: TextReference,
|
||||
val subtitle: TextReference,
|
||||
val subtitleEllipsis: TextEllipsis,
|
||||
val isClickEnabled: Boolean,
|
||||
) : SwapAmountFieldUM()
|
||||
}
|
||||
|
||||
@Immutable
|
||||
sealed class PriceImpactUM {
|
||||
|
||||
data object Empty : PriceImpactUM()
|
||||
|
||||
data class Value(val value: Float) : PriceImpactUM()
|
||||
}
|
||||
|
||||
enum class SwapAmountType {
|
||||
From,
|
||||
To,
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.tangem.features.swap.v2.impl.amount.model
|
||||
|
||||
import com.tangem.common.ui.amountScreen.AmountScreenClickIntents
|
||||
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
|
||||
|
||||
internal interface SwapAmountClickIntents : AmountScreenClickIntents {
|
||||
|
||||
fun onExpandEditField(selectedAmountType: SwapAmountType)
|
||||
fun onSelectTokenClick()
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.features.swap.v2.impl.amount.ui.preview
|
||||
|
||||
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
|
||||
import com.tangem.features.swap.v2.impl.amount.model.SwapAmountClickIntents
|
||||
|
||||
internal object SwapAmountClickIntentsStub : SwapAmountClickIntents {
|
||||
override fun onExpandEditField(selectedAmountType: SwapAmountType) {}
|
||||
|
||||
override fun onSelectTokenClick() {}
|
||||
|
||||
override fun onAmountValueChange(value: String) {}
|
||||
|
||||
override fun onAmountPasteTriggerDismiss() {}
|
||||
|
||||
override fun onMaxValueClick() {}
|
||||
|
||||
override fun onCurrencyChangeClick(isFiat: Boolean) {}
|
||||
|
||||
override fun onAmountNext() {}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.tangem.features.swap.v2.impl.common
|
||||
|
||||
import com.tangem.features.swap.v2.impl.common.entity.NavigationUM
|
||||
|
||||
internal interface SwapNavigationModelCallback {
|
||||
fun onNavigationResult(navigationUM: NavigationUM)
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.tangem.features.swap.v2.impl.common.entity
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.common.ui.navigationButtons.NavigationButton
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
||||
@Immutable
|
||||
internal sealed class NavigationUM {
|
||||
data class Content(
|
||||
val title: TextReference,
|
||||
val subtitle: TextReference?,
|
||||
@DrawableRes val backIconRes: Int,
|
||||
val backIconClick: () -> Unit,
|
||||
@DrawableRes val additionalIconRes: Int? = null,
|
||||
val additionalIconClick: (() -> Unit)? = null,
|
||||
val primaryButton: NavigationButton,
|
||||
val secondaryPairButtonsUM: Pair<NavigationButton, NavigationButton>? = null,
|
||||
) : NavigationUM()
|
||||
|
||||
data object Empty : NavigationUM()
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.features.swap.v2.impl.swap
|
||||
|
||||
import com.tangem.core.decompose.navigation.Route
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
internal sealed class SwapRoute : Route {
|
||||
|
||||
abstract val isEditMode: Boolean
|
||||
|
||||
data object Empty : SwapRoute() {
|
||||
override val isEditMode: Boolean = false
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data object Confirm : SwapRoute() {
|
||||
override val isEditMode: Boolean = true
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Amount(
|
||||
override val isEditMode: Boolean,
|
||||
) : SwapRoute()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue