Updated on 2026-08-14

This commit is contained in:
Tangem 2024-10-28 16:52:05 +04:00
parent 41131e5b73
commit f5eca5ab2a
23 changed files with 160 additions and 138 deletions

View file

@ -20,8 +20,21 @@ dependencies {
implementation(projects.core.ui)
implementation(projects.core.featuretoggles)
/** Project - Common */
implementation(projects.common.ui)
/** Project - Domain */
implementation(projects.domain.appCurrency)
implementation(projects.domain.appCurrency.models)
implementation(projects.domain.balanceHiding)
implementation(projects.domain.balanceHiding.models)
implementation(projects.domain.tokens)
implementation(projects.domain.tokens.models)
implementation(projects.domain.wallets.models)
/** DI */
implementation(deps.hilt.android)
implementation(project(":common:ui"))
kapt(deps.hilt.kapt)
/** AndroidX */
@ -40,4 +53,6 @@ dependencies {
/** Other */
implementation(deps.decompose.ext.compose)
implementation(deps.kotlin.immutable.collections)
implementation(deps.timber)
}

View file

@ -0,0 +1,46 @@
package com.tangem.features.onramp.selecttoken
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.context.child
import com.tangem.features.onramp.selecttoken.ui.OnrampSelectToken
import com.tangem.features.onramp.tokenlist.OnrampTokenListComponent
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
internal class DefaultOnrampSelectTokenComponent @AssistedInject constructor(
@Assisted appComponentContext: AppComponentContext,
onrampTokenListComponentFactory: OnrampTokenListComponent.Factory,
@Assisted private val params: OnrampSelectTokenComponent.Params,
) : AppComponentContext by appComponentContext, OnrampSelectTokenComponent {
private val onrampTokenListComponent: OnrampTokenListComponent = onrampTokenListComponentFactory.create(
context = child(key = "token_list"),
params = OnrampTokenListComponent.Params(
hasSearchBar = params.hasSearchBar,
userWalletId = params.userWalletId,
onTokenClick = params.onTokenClick,
),
)
@Composable
override fun Content(modifier: Modifier) {
OnrampSelectToken(
titleResId = params.titleResId,
onBackClick = router::pop,
onrampTokenListComponent = onrampTokenListComponent,
modifier = modifier,
)
}
@AssistedFactory
interface Factory : OnrampSelectTokenComponent.Factory {
override fun create(
context: AppComponentContext,
params: OnrampSelectTokenComponent.Params,
): DefaultOnrampSelectTokenComponent
}
}

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.selecttoken
package com.tangem.features.onramp.selecttoken
import androidx.annotation.StringRes
import com.tangem.core.decompose.factory.ComponentFactory
@ -11,9 +11,9 @@ import com.tangem.domain.wallets.models.UserWalletId
*
[REDACTED_AUTHOR]
*/
interface SelectTokenComponent : ComposableContentComponent {
interface OnrampSelectTokenComponent : ComposableContentComponent {
interface Factory : ComponentFactory<Params, SelectTokenComponent>
interface Factory : ComponentFactory<Params, OnrampSelectTokenComponent>
/**
* Params

View file

@ -0,0 +1,20 @@
package com.tangem.features.onramp.selecttoken.di
import com.tangem.features.onramp.selecttoken.DefaultOnrampSelectTokenComponent
import com.tangem.features.onramp.selecttoken.OnrampSelectTokenComponent
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal interface OnrampSelectTokenComponentModule {
@Binds
@Singleton
fun bindOnrampSelectTokenComponentFactory(
factory: DefaultOnrampSelectTokenComponent.Factory,
): OnrampSelectTokenComponent.Factory
}

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.selecttoken.ui
package com.tangem.features.onramp.selecttoken.ui
import androidx.activity.compose.BackHandler
import androidx.annotation.StringRes
@ -13,14 +13,14 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.tangem.core.ui.components.appbar.AppBarWithBackButton
import com.tangem.core.ui.res.TangemTheme
import com.tangem.feature.wallet.impl.R
import com.tangem.feature.wallet.presentation.tokenlist.TokenListComponent
import com.tangem.features.onramp.impl.R
import com.tangem.features.onramp.tokenlist.OnrampTokenListComponent
@Composable
internal fun SelectToken(
internal fun OnrampSelectToken(
@StringRes titleResId: Int,
onBackClick: () -> Unit,
tokenListComponent: TokenListComponent,
onrampTokenListComponent: OnrampTokenListComponent,
modifier: Modifier = Modifier,
) {
BackHandler(onBack = onBackClick)
@ -37,7 +37,7 @@ internal fun SelectToken(
iconRes = R.drawable.ic_close_24,
)
tokenListComponent.Content(
onrampTokenListComponent.Content(
contentPadding = PaddingValues(vertical = 8.dp, horizontal = 16.dp),
modifier = Modifier,
)

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist
package com.tangem.features.onramp.tokenlist
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
@ -8,19 +8,19 @@ import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.model.getOrCreateModel
import com.tangem.feature.wallet.presentation.tokenlist.model.TokenListModel
import com.tangem.feature.wallet.presentation.tokenlist.ui.TokenList
import com.tangem.features.onramp.tokenlist.model.OnrampTokenListModel
import com.tangem.features.onramp.tokenlist.ui.TokenList
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
@Stable
internal class DefaultTokenListComponent @AssistedInject constructor(
internal class DefaultOnrampTokenListComponent @AssistedInject constructor(
@Assisted context: AppComponentContext,
@Assisted params: TokenListComponent.Params,
) : TokenListComponent, AppComponentContext by context {
@Assisted params: OnrampTokenListComponent.Params,
) : OnrampTokenListComponent, AppComponentContext by context {
private val model: TokenListModel = getOrCreateModel(params)
private val model: OnrampTokenListModel = getOrCreateModel(params)
@Composable
override fun Content(contentPadding: PaddingValues, modifier: Modifier) {
@ -30,7 +30,10 @@ internal class DefaultTokenListComponent @AssistedInject constructor(
}
@AssistedFactory
interface Factory : TokenListComponent.Factory {
override fun create(context: AppComponentContext, params: TokenListComponent.Params): DefaultTokenListComponent
interface Factory : OnrampTokenListComponent.Factory {
override fun create(
context: AppComponentContext,
params: OnrampTokenListComponent.Params,
): DefaultOnrampTokenListComponent
}
}

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist
package com.tangem.features.onramp.tokenlist
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
@ -10,13 +10,13 @@ import com.tangem.domain.wallets.models.UserWalletId
/** Token list component that present list of token for multi-currency wallet */
@Stable
internal interface TokenListComponent {
internal interface OnrampTokenListComponent {
@Composable
fun Content(contentPadding: PaddingValues, modifier: Modifier)
/** Component factory */
interface Factory : ComponentFactory<Params, TokenListComponent>
interface Factory : ComponentFactory<Params, OnrampTokenListComponent>
/**
* Params

View file

@ -0,0 +1,20 @@
package com.tangem.features.onramp.tokenlist.di
import com.tangem.features.onramp.tokenlist.DefaultOnrampTokenListComponent
import com.tangem.features.onramp.tokenlist.OnrampTokenListComponent
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal interface OnrampTokenListComponentModule {
@Binds
@Singleton
fun bindOnrampTokenListComponentFactory(
factory: DefaultOnrampTokenListComponent.Factory,
): OnrampTokenListComponent.Factory
}

View file

@ -1,8 +1,8 @@
package com.tangem.feature.wallet.presentation.tokenlist.di
package com.tangem.features.onramp.tokenlist.di
import com.tangem.core.decompose.di.DecomposeComponent
import com.tangem.core.decompose.model.Model
import com.tangem.feature.wallet.presentation.tokenlist.model.TokenListModel
import com.tangem.features.onramp.tokenlist.model.OnrampTokenListModel
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
@ -11,10 +11,10 @@ import dagger.multibindings.IntoMap
@Module
@InstallIn(DecomposeComponent::class)
internal interface TokenListModelModule {
internal interface OnrampTokenListModelModule {
@Binds
@IntoMap
@ClassKey(TokenListModel::class)
fun provideTokenListModel(model: TokenListModel): Model
@ClassKey(OnrampTokenListModel::class)
fun bindOnrampTokenListModel(model: OnrampTokenListModel): Model
}

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist.entity
package com.tangem.features.onramp.tokenlist.entity
import com.tangem.core.ui.components.tokenlist.state.TokensListItemUM
import kotlinx.collections.immutable.ImmutableList

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist.entity
package com.tangem.features.onramp.tokenlist.entity
import com.tangem.core.ui.components.tokenlist.state.TokensListItemUM
import kotlinx.collections.immutable.persistentListOf

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist.entity
package com.tangem.features.onramp.tokenlist.entity
import com.tangem.utils.transformer.Transformer

View file

@ -1,8 +1,8 @@
package com.tangem.feature.wallet.presentation.tokenlist.entity.transformer
package com.tangem.features.onramp.tokenlist.entity.transformer
import com.tangem.core.ui.components.fields.entity.SearchBarUM
import com.tangem.feature.wallet.presentation.tokenlist.entity.TokenListUM
import com.tangem.feature.wallet.presentation.tokenlist.entity.TokenListUMTransformer
import com.tangem.features.onramp.tokenlist.entity.TokenListUM
import com.tangem.features.onramp.tokenlist.entity.TokenListUMTransformer
import kotlinx.collections.immutable.persistentListOf
/**

View file

@ -1,9 +1,9 @@
package com.tangem.feature.wallet.presentation.tokenlist.entity.transformer
package com.tangem.features.onramp.tokenlist.entity.transformer
import com.tangem.core.ui.components.fields.entity.SearchBarUM
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.feature.wallet.impl.R
import com.tangem.features.onramp.impl.R
internal class UpdateSearchBarActiveStateTransformer(private val isActive: Boolean) : SearchBarUMTransformer() {

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist.entity.transformer
package com.tangem.features.onramp.tokenlist.entity.transformer
import com.tangem.core.ui.components.fields.entity.SearchBarUM

View file

@ -1,13 +1,13 @@
package com.tangem.feature.wallet.presentation.tokenlist.entity.transformer
package com.tangem.features.onramp.tokenlist.entity.transformer
import com.tangem.common.ui.tokens.TokenItemStateConverter
import com.tangem.core.ui.components.fields.entity.SearchBarUM
import com.tangem.core.ui.components.tokenlist.state.TokensListItemUM
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.feature.wallet.impl.R
import com.tangem.feature.wallet.presentation.tokenlist.entity.TokenListUM
import com.tangem.feature.wallet.presentation.tokenlist.entity.TokenListUMTransformer
import com.tangem.features.onramp.impl.R
import com.tangem.features.onramp.tokenlist.entity.TokenListUM
import com.tangem.features.onramp.tokenlist.entity.TokenListUMTransformer
import kotlinx.collections.immutable.toImmutableList
internal class UpdateTokenItemsTransformer(

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist.model
package com.tangem.features.onramp.tokenlist.model
import arrow.core.getOrElse
import com.tangem.common.ui.tokens.TokenItemStateConverter
@ -11,20 +11,20 @@ import com.tangem.domain.core.utils.getOrElse
import com.tangem.domain.tokens.GetTokenListUseCase
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.tokens.model.TokenList
import com.tangem.feature.wallet.presentation.tokenlist.TokenListComponent
import com.tangem.feature.wallet.presentation.tokenlist.entity.TokenListUM
import com.tangem.feature.wallet.presentation.tokenlist.entity.TokenListUMController
import com.tangem.feature.wallet.presentation.tokenlist.entity.transformer.UpdateSearchBarActiveStateTransformer
import com.tangem.feature.wallet.presentation.tokenlist.entity.transformer.UpdateSearchQueryTransformer
import com.tangem.feature.wallet.presentation.tokenlist.entity.transformer.UpdateTokenItemsTransformer
import com.tangem.feature.wallet.presentation.tokenlist.utils.SearchTokensManager
import com.tangem.features.onramp.tokenlist.OnrampTokenListComponent
import com.tangem.features.onramp.tokenlist.entity.TokenListUM
import com.tangem.features.onramp.tokenlist.entity.TokenListUMController
import com.tangem.features.onramp.tokenlist.entity.transformer.UpdateSearchBarActiveStateTransformer
import com.tangem.features.onramp.tokenlist.entity.transformer.UpdateSearchQueryTransformer
import com.tangem.features.onramp.tokenlist.entity.transformer.UpdateTokenItemsTransformer
import com.tangem.features.onramp.tokenlist.utils.SearchTokensManager
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import javax.inject.Inject
@Suppress("LongParameterList")
internal class TokenListModel @Inject constructor(
internal class OnrampTokenListModel @Inject constructor(
paramsContainer: ParamsContainer,
override val dispatchers: CoroutineDispatcherProvider,
private val tokenListUMController: TokenListUMController,
@ -36,7 +36,7 @@ internal class TokenListModel @Inject constructor(
val state: StateFlow<TokenListUM> = tokenListUMController.state
private val params: TokenListComponent.Params = paramsContainer.require()
private val params: OnrampTokenListComponent.Params = paramsContainer.require()
init {
subscribeOnUpdateState()

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist.ui
package com.tangem.features.onramp.tokenlist.ui
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.PaddingValues
@ -14,8 +14,8 @@ import com.tangem.core.ui.components.tokenlist.TokenListItem
import com.tangem.core.ui.decorations.roundedShapeItemDecoration
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.feature.wallet.presentation.tokenlist.entity.TokenListUM
import com.tangem.feature.wallet.presentation.tokenlist.ui.preview.PreviewTokenListUMProvider
import com.tangem.features.onramp.tokenlist.entity.TokenListUM
import com.tangem.features.onramp.tokenlist.ui.preview.PreviewTokenListUMProvider
/**
* Token list

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist.ui.preview
package com.tangem.features.onramp.tokenlist.ui.preview
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import com.tangem.core.ui.components.currency.icon.CurrencyIconState
@ -7,8 +7,8 @@ import com.tangem.core.ui.components.marketprice.PriceChangeType
import com.tangem.core.ui.components.token.state.TokenItemState
import com.tangem.core.ui.components.tokenlist.state.TokensListItemUM
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.feature.wallet.impl.R
import com.tangem.feature.wallet.presentation.tokenlist.entity.TokenListUM
import com.tangem.features.onramp.impl.R
import com.tangem.features.onramp.tokenlist.entity.TokenListUM
import kotlinx.collections.immutable.toImmutableList
internal class PreviewTokenListUMProvider : PreviewParameterProvider<TokenListUM> {

View file

@ -1,4 +1,4 @@
package com.tangem.feature.wallet.presentation.tokenlist.utils
package com.tangem.features.onramp.tokenlist.utils
import com.tangem.utils.coroutines.JobHolder
import com.tangem.utils.coroutines.withDebounce

View file

@ -1,46 +0,0 @@
package com.tangem.feature.wallet.presentation.selecttoken
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.context.child
import com.tangem.feature.wallet.presentation.selecttoken.ui.SelectToken
import com.tangem.feature.wallet.presentation.tokenlist.TokenListComponent
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
internal class DefaultSelectTokenComponent @AssistedInject constructor(
@Assisted appComponentContext: AppComponentContext,
tokenListComponentFactory: TokenListComponent.Factory,
@Assisted private val params: SelectTokenComponent.Params,
) : AppComponentContext by appComponentContext, SelectTokenComponent {
private val tokenListComponent: TokenListComponent = tokenListComponentFactory.create(
context = child(key = "token_list"),
params = TokenListComponent.Params(
hasSearchBar = params.hasSearchBar,
userWalletId = params.userWalletId,
onTokenClick = params.onTokenClick,
),
)
@Composable
override fun Content(modifier: Modifier) {
SelectToken(
titleResId = params.titleResId,
onBackClick = router::pop,
tokenListComponent = tokenListComponent,
modifier = modifier,
)
}
@AssistedFactory
interface Factory : SelectTokenComponent.Factory {
override fun create(
context: AppComponentContext,
params: SelectTokenComponent.Params,
): DefaultSelectTokenComponent
}
}

View file

@ -1,18 +0,0 @@
package com.tangem.feature.wallet.presentation.selecttoken.di
import com.tangem.feature.wallet.presentation.selecttoken.DefaultSelectTokenComponent
import com.tangem.feature.wallet.presentation.selecttoken.SelectTokenComponent
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal interface SelectTokenComponentModule {
@Binds
@Singleton
fun bindSelectTokenComponentFactory(factory: DefaultSelectTokenComponent.Factory): SelectTokenComponent.Factory
}

View file

@ -1,18 +0,0 @@
package com.tangem.feature.wallet.presentation.tokenlist.di
import com.tangem.feature.wallet.presentation.tokenlist.DefaultTokenListComponent
import com.tangem.feature.wallet.presentation.tokenlist.TokenListComponent
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal interface TokenListComponentModule {
@Binds
@Singleton
fun bindTokenListComponentFactory(factory: DefaultTokenListComponent.Factory): TokenListComponent.Factory
}