diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt new file mode 100644 index 0000000000..532fc81270 --- /dev/null +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt @@ -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, + 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, +} \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountClickIntents.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountClickIntents.kt new file mode 100644 index 0000000000..f9c92b77a1 --- /dev/null +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountClickIntents.kt @@ -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() +} \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountClickIntentsStub.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountClickIntentsStub.kt new file mode 100644 index 0000000000..98bcb53665 --- /dev/null +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountClickIntentsStub.kt @@ -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() {} +} \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/SwapNavigationModelCallback.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/SwapNavigationModelCallback.kt new file mode 100644 index 0000000000..2dfd5a4775 --- /dev/null +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/SwapNavigationModelCallback.kt @@ -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) +} \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/entity/NavigationUM.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/entity/NavigationUM.kt new file mode 100644 index 0000000000..b491576333 --- /dev/null +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/entity/NavigationUM.kt @@ -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? = null, + ) : NavigationUM() + + data object Empty : NavigationUM() +} \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/swap/SwapRoute.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/swap/SwapRoute.kt new file mode 100644 index 0000000000..2d7da88a11 --- /dev/null +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/swap/SwapRoute.kt @@ -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() +} \ No newline at end of file