Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-13 12:53:59 +04:00
parent c0092847b7
commit 503106376c
27 changed files with 887 additions and 58 deletions

View file

@ -28,7 +28,7 @@ interface ChooseTokenBridge : ChooseTokenBridgeInternal {
data class Settings(
val title: TextReference,
val isShowMarketBlock: Boolean,
val chooserBlock: ChooserBlock,
val isShowPaymentAccount: Boolean,
val isAppBarShown: Boolean = true,
/**
@ -40,24 +40,24 @@ interface ChooseTokenBridge : ChooseTokenBridgeInternal {
companion object {
val SwapFrom = Settings(
title = resourceReference(R.string.swapping_from_title),
isShowMarketBlock = true,
chooserBlock = ChooserBlock.Market,
isShowPaymentAccount = true,
)
val SwapTo = Settings(
title = resourceReference(R.string.swapping_to_title),
isShowMarketBlock = true,
chooserBlock = ChooserBlock.Market,
isShowPaymentAccount = true,
)
val AddFunds = Settings(
title = resourceReference(R.string.swapping_to_title),
isShowMarketBlock = true,
chooserBlock = ChooserBlock.Market,
isShowPaymentAccount = false,
isAppBarShown = false,
isShowSingleCurrencyWallets = true,
)
val Transfer = Settings(
title = resourceReference(R.string.common_transfer),
isShowMarketBlock = false,
chooserBlock = ChooserBlock.None,
isShowPaymentAccount = false,
isAppBarShown = false,
isShowSingleCurrencyWallets = true,
@ -116,6 +116,20 @@ data class ChooseTokenResult(
.any { it.value }
}
/**
* Which "add a token" block the chooser shows. Mutually exclusive by construction.
*/
sealed interface ChooserBlock {
data object None : ChooserBlock
data object Market : ChooserBlock
/**
* Shows an "add these tokens" block (e.g. Onramp promo payout). The caller owns [predefinedTokens]
* and pushes into it; the chooser derives the "add" cells and a network filter from it.
*/
data class Predefined(val predefinedTokens: StateFlow<List<PredefinedTokenToAdd>>) : ChooserBlock
}
sealed interface ChooseTokenAnalyticsPayload {
@Suppress("BooleanPropertyNaming")

View file

@ -0,0 +1,19 @@
package com.tangem.features.commonfeatures.api.choosetoken
import com.tangem.domain.markets.RawMarketToken
import com.tangem.domain.markets.TokenMarketInfo
/**
* A token offered for adding to the portfolio inside the token chooser, independent of any
* campaign/promo model. Callers convert their own models (e.g. promo payout tokens) into this type,
* so the chooser stays agnostic of feature-specific sources.
*
* Exactly one [network] per token the chooser renders one "add" row per [PredefinedTokenToAdd].
* [TokenMarketInfo.Network.decimalCount] must be resolved by the caller a network without decimals
* cannot be added and must be dropped before reaching the chooser.
*/
data class PredefinedTokenToAdd(
val token: RawMarketToken,
val network: TokenMarketInfo.Network,
val iconUrl: String? = null,
)