Updated on 2026-08-14
This commit is contained in:
parent
96a748c904
commit
a950ca16b7
8 changed files with 55 additions and 24 deletions
|
|
@ -24,6 +24,7 @@ dependencies {
|
|||
implementation(projects.core.featuretoggles)
|
||||
|
||||
/** Project - Common */
|
||||
implementation(projects.common.routing)
|
||||
implementation(projects.common.ui)
|
||||
|
||||
/** Project - Domain */
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ import com.tangem.core.decompose.context.AppComponentContext
|
|||
import com.tangem.core.decompose.context.child
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.features.onramp.component.SwapSelectTokensComponent
|
||||
import com.tangem.features.onramp.tokenlist.entity.OnrampOperation
|
||||
import com.tangem.features.onramp.swap.availablepairs.AvailableSwapPairsComponent
|
||||
import com.tangem.features.onramp.swap.model.SwapSelectTokensModel
|
||||
import com.tangem.features.onramp.swap.ui.SwapSelectTokens
|
||||
import com.tangem.features.onramp.tokenlist.OnrampTokenListComponent
|
||||
import com.tangem.features.onramp.tokenlist.entity.OnrampOperation
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
|
@ -19,11 +20,12 @@ import dagger.assisted.AssistedInject
|
|||
@Stable
|
||||
internal class DefaultSwapSelectTokensComponent @AssistedInject constructor(
|
||||
tokenListComponentFactory: OnrampTokenListComponent.Factory,
|
||||
availableSwapPairsComponentFactory: AvailableSwapPairsComponent.Factory,
|
||||
@Assisted private val appComponentContext: AppComponentContext,
|
||||
@Assisted private val params: SwapSelectTokensComponent.Params,
|
||||
) : AppComponentContext by appComponentContext, SwapSelectTokensComponent {
|
||||
|
||||
private val model: SwapSelectTokensModel = getOrCreateModel()
|
||||
private val model: SwapSelectTokensModel = getOrCreateModel(params)
|
||||
|
||||
private val selectFromTokenListComponent: OnrampTokenListComponent = tokenListComponentFactory.create(
|
||||
context = child(key = "select_from_token_list"),
|
||||
|
|
@ -35,15 +37,15 @@ internal class DefaultSwapSelectTokensComponent @AssistedInject constructor(
|
|||
),
|
||||
)
|
||||
|
||||
private val selectToTokenListComponent: OnrampTokenListComponent = tokenListComponentFactory.create(
|
||||
context = child(key = "select_to_token_list"),
|
||||
params = OnrampTokenListComponent.Params(
|
||||
filterOperation = OnrampOperation.SWAP,
|
||||
hasSearchBar = true,
|
||||
userWalletId = params.userWalletId,
|
||||
onTokenClick = model::selectToToken,
|
||||
),
|
||||
)
|
||||
private val selectToTokenListComponent: AvailableSwapPairsComponent =
|
||||
availableSwapPairsComponentFactory.create(
|
||||
context = child(key = "select_to_token_list"),
|
||||
params = AvailableSwapPairsComponent.Params(
|
||||
userWalletId = params.userWalletId,
|
||||
selectedStatus = model.fromCurrencyStatus,
|
||||
onTokenClick = model::selectToToken,
|
||||
),
|
||||
)
|
||||
|
||||
@Composable
|
||||
override fun Content(modifier: Modifier) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.tangem.features.onramp.swap.entity.transformer.RemoveSelectedFromToke
|
|||
import com.tangem.features.onramp.swap.entity.transformer.SelectFromTokenTransformer
|
||||
import com.tangem.features.onramp.swap.entity.transformer.SelectToTokenTransformer
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -20,8 +21,10 @@ internal class SwapSelectTokensModel @Inject constructor(
|
|||
|
||||
val state: StateFlow<SwapSelectTokensUM> = controller.state
|
||||
|
||||
private var fromCurrencyStatus: CryptoCurrencyStatus? = null
|
||||
private var toCurrencyStatus: CryptoCurrencyStatus? = null
|
||||
val fromCurrencyStatus: StateFlow<CryptoCurrencyStatus?> get() = _fromCurrencyStatus
|
||||
|
||||
private val _fromCurrencyStatus = MutableStateFlow<CryptoCurrencyStatus?>(value = null)
|
||||
private val _toCurrencyStatus = MutableStateFlow<CryptoCurrencyStatus?>(value = null)
|
||||
|
||||
/**
|
||||
* Select "from" token
|
||||
|
|
@ -30,7 +33,7 @@ internal class SwapSelectTokensModel @Inject constructor(
|
|||
* @param status crypto currency status
|
||||
*/
|
||||
fun selectFromToken(selectedTokenItemState: TokenItemState, status: CryptoCurrencyStatus) {
|
||||
fromCurrencyStatus = status
|
||||
_fromCurrencyStatus.value = status
|
||||
|
||||
controller.update(
|
||||
transformer = SelectFromTokenTransformer(
|
||||
|
|
@ -47,7 +50,7 @@ internal class SwapSelectTokensModel @Inject constructor(
|
|||
* @param status crypto currency status
|
||||
*/
|
||||
fun selectToToken(selectedTokenItemState: TokenItemState, status: CryptoCurrencyStatus) {
|
||||
toCurrencyStatus = status
|
||||
_toCurrencyStatus.value = status
|
||||
|
||||
controller.update(transformer = SelectToTokenTransformer(selectedTokenItemState))
|
||||
|
||||
|
|
@ -55,7 +58,7 @@ internal class SwapSelectTokensModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun onRemoveClick() {
|
||||
fromCurrencyStatus = null
|
||||
_fromCurrencyStatus.value = null
|
||||
|
||||
controller.update(transformer = RemoveSelectedFromTokenTransformer)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import androidx.compose.ui.unit.dp
|
|||
import com.tangem.core.ui.components.appbar.AppBarWithBackButton
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.features.onramp.impl.R
|
||||
import com.tangem.features.onramp.swap.availablepairs.AvailableSwapPairsComponent
|
||||
import com.tangem.features.onramp.swap.entity.ExchangeCardUM
|
||||
import com.tangem.features.onramp.swap.entity.SwapSelectTokensUM
|
||||
import com.tangem.features.onramp.tokenlist.OnrampTokenListComponent
|
||||
|
|
@ -34,7 +35,7 @@ import com.tangem.features.onramp.tokenlist.OnrampTokenListComponent
|
|||
internal fun SwapSelectTokens(
|
||||
state: SwapSelectTokensUM,
|
||||
selectFromTokenListComponent: OnrampTokenListComponent,
|
||||
selectToTokenListComponent: OnrampTokenListComponent,
|
||||
selectToTokenListComponent: AvailableSwapPairsComponent,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
BackHandler(onBack = state.onBackClick)
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ internal class WalletCurrencyActionsClickIntentsImplementor @Inject constructor(
|
|||
|
||||
override fun onMultiWalletSwapClick(userWalletId: UserWalletId) {
|
||||
// TODO [REDACTED_JIRA]
|
||||
// appRouter.push(route = AppRoute.SwapCrypto(userWalletId = userWalletId))
|
||||
appRouter.push(route = AppRoute.SwapCrypto(userWalletId = userWalletId))
|
||||
}
|
||||
|
||||
override fun onMultiWalletBuyClick(userWalletId: UserWalletId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue