Updated on 2026-08-14
This commit is contained in:
commit
84f8cdf7d2
159 changed files with 1006 additions and 6331 deletions
|
|
@ -14,9 +14,5 @@
|
|||
{
|
||||
"name": "REDESIGNED_SEND_SCREEN_ENABLED",
|
||||
"version": "undefined"
|
||||
},
|
||||
{
|
||||
"name": "WALLETS_SCROLLING_PREVIEW_ENABLED",
|
||||
"version": "5.5.0"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
package com.tangem.features.wallet.featuretoggles
|
||||
|
||||
/**
|
||||
* Wallet feature toggles
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
interface WalletFeatureToggles {
|
||||
|
||||
val isWalletsScrollingPreviewEnabled: Boolean
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package com.tangem.feature.wallet.di
|
||||
|
||||
import com.tangem.core.featuretoggle.manager.FeatureTogglesManager
|
||||
import com.tangem.feature.wallet.featuretoggles.DefaultWalletFeatureToggles
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal object WalletFeatureTogglesModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideWalletFeatureToggles(featureTogglesManager: FeatureTogglesManager): WalletFeatureToggles {
|
||||
return DefaultWalletFeatureToggles(featureTogglesManager = featureTogglesManager)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.tangem.feature.wallet.di
|
|||
|
||||
import com.tangem.core.navigation.ReduxNavController
|
||||
import com.tangem.feature.wallet.presentation.router.DefaultWalletRouter
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
import com.tangem.features.wallet.navigation.WalletRouter
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
|
@ -16,10 +15,7 @@ internal object WalletRouterModule {
|
|||
|
||||
@Provides
|
||||
@ActivityScoped
|
||||
fun provideWalletRouter(
|
||||
reduxNavController: ReduxNavController,
|
||||
walletFeatureToggles: WalletFeatureToggles,
|
||||
): WalletRouter {
|
||||
return DefaultWalletRouter(reduxNavController = reduxNavController, walletFeatureToggles = walletFeatureToggles)
|
||||
fun provideWalletRouter(reduxNavController: ReduxNavController): WalletRouter {
|
||||
return DefaultWalletRouter(reduxNavController = reduxNavController)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package com.tangem.feature.wallet.featuretoggles
|
||||
|
||||
import com.tangem.core.featuretoggle.manager.FeatureTogglesManager
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
|
||||
/**
|
||||
* Default implementation of Wallet feature toggles
|
||||
*
|
||||
* @property featureTogglesManager manager for getting information about the availability of feature toggles
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class DefaultWalletFeatureToggles(
|
||||
private val featureTogglesManager: FeatureTogglesManager,
|
||||
) : WalletFeatureToggles {
|
||||
|
||||
override val isWalletsScrollingPreviewEnabled: Boolean
|
||||
get() = featureTogglesManager.isFeatureEnabled(name = "WALLETS_SCROLLING_PREVIEW_ENABLED")
|
||||
}
|
||||
|
|
@ -1,17 +1,10 @@
|
|||
package com.tangem.feature.wallet.presentation.common
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.currency.tokenicon.TokenIconState
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeState
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeType
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.res.TangemColorPalette
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
|
|
@ -19,16 +12,9 @@ import com.tangem.feature.wallet.presentation.common.state.TokenItemState
|
|||
import com.tangem.feature.wallet.presentation.organizetokens.model.DraggableItem
|
||||
import com.tangem.feature.wallet.presentation.organizetokens.model.OrganizeTokensListState
|
||||
import com.tangem.feature.wallet.presentation.organizetokens.model.OrganizeTokensState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.ActionsBottomSheetConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.TokenActionButtonConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTokensListState.TokensListItemState
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.*
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import java.util.UUID
|
||||
|
||||
@Suppress("LargeClass")
|
||||
|
|
@ -80,14 +66,6 @@ internal object WalletPreviewData {
|
|||
)
|
||||
}
|
||||
|
||||
val walletListConfig by lazy {
|
||||
WalletsListConfig(
|
||||
selectedWalletIndex = 0,
|
||||
wallets = wallets.values.toPersistentList(),
|
||||
onWalletChange = {},
|
||||
)
|
||||
}
|
||||
|
||||
val coinIconState
|
||||
get() = TokenIconState.CoinIcon(
|
||||
url = null,
|
||||
|
|
@ -320,146 +298,4 @@ internal object WalletPreviewData {
|
|||
),
|
||||
).toImmutableList(),
|
||||
)
|
||||
|
||||
private val manageButtons by lazy {
|
||||
persistentListOf(
|
||||
WalletManageButton.Buy(enabled = true, onClick = {}),
|
||||
WalletManageButton.Send(enabled = true, onClick = {}),
|
||||
WalletManageButton.Receive(enabled = true, onClick = {}),
|
||||
WalletManageButton.Sell(enabled = true, onClick = {}),
|
||||
WalletManageButton.Swap(enabled = true, onClick = {}),
|
||||
)
|
||||
}
|
||||
|
||||
val multicurrencyWalletScreenState by lazy {
|
||||
WalletMultiCurrencyState.Content(
|
||||
onBackClick = {},
|
||||
topBarConfig = topBarConfig,
|
||||
walletsListConfig = walletListConfig,
|
||||
tokensListState = WalletTokensListState.Content(
|
||||
persistentListOf(
|
||||
TokensListItemState.NetworkGroupTitle(id = 0, stringReference("Bitcoin")),
|
||||
TokensListItemState.Token(
|
||||
tokenItemVisibleState.copy(
|
||||
id = "token_1",
|
||||
titleState = TokenItemState.TitleState.Content(text = "Ethereum"),
|
||||
cryptoAmountState = TokenItemState.CryptoAmountState.Content("1,89340821 ETH"),
|
||||
),
|
||||
),
|
||||
TokensListItemState.Token(
|
||||
tokenItemVisibleState.copy(
|
||||
id = "token_2",
|
||||
titleState = TokenItemState.TitleState.Content(text = "Ethereum"),
|
||||
cryptoAmountState = TokenItemState.CryptoAmountState.Content("1,89340821 ETH"),
|
||||
),
|
||||
),
|
||||
TokensListItemState.Token(
|
||||
tokenItemVisibleState.copy(
|
||||
id = "token_3",
|
||||
titleState = TokenItemState.TitleState.Content(text = "Ethereum"),
|
||||
cryptoAmountState = TokenItemState.CryptoAmountState.Content("1,89340821 ETH"),
|
||||
),
|
||||
),
|
||||
TokensListItemState.Token(
|
||||
tokenItemVisibleState.copy(
|
||||
id = "token_4",
|
||||
titleState = TokenItemState.TitleState.Content(text = "Ethereum"),
|
||||
cryptoAmountState = TokenItemState.CryptoAmountState.Content("1,89340821 ETH"),
|
||||
),
|
||||
),
|
||||
TokensListItemState.NetworkGroupTitle(id = 1, stringReference("Ethereum")),
|
||||
TokensListItemState.Token(
|
||||
tokenItemVisibleState.copy(
|
||||
id = "token_5",
|
||||
titleState = TokenItemState.TitleState.Content(text = "Ethereum"),
|
||||
cryptoAmountState = TokenItemState.CryptoAmountState.Content("1,89340821 ETH"),
|
||||
),
|
||||
),
|
||||
),
|
||||
organizeTokensButton = WalletTokensListState.OrganizeTokensButtonState.Visible(isEnabled = true, {}),
|
||||
),
|
||||
pullToRefreshConfig = WalletPullToRefreshConfig(
|
||||
isRefreshing = false,
|
||||
onRefresh = {},
|
||||
),
|
||||
notifications = persistentListOf(
|
||||
WalletNotification.Critical.DevCard,
|
||||
WalletNotification.Informational.MissingAddresses(missingAddressesCount = 0, onGenerateClick = {}),
|
||||
WalletNotification.Warning.NetworksUnreachable,
|
||||
),
|
||||
bottomSheetConfig = bottomSheet,
|
||||
onManageTokensClick = {},
|
||||
event = consumedEvent(),
|
||||
isBalanceHidden = false,
|
||||
)
|
||||
}
|
||||
|
||||
val singleWalletScreenState by lazy {
|
||||
WalletSingleCurrencyState.Content(
|
||||
onBackClick = {},
|
||||
topBarConfig = topBarConfig,
|
||||
walletsListConfig = walletListConfig,
|
||||
pullToRefreshConfig = WalletPullToRefreshConfig(
|
||||
isRefreshing = false,
|
||||
onRefresh = {},
|
||||
),
|
||||
notifications = persistentListOf(WalletNotification.Warning.NetworksUnreachable),
|
||||
buttons = manageButtons,
|
||||
bottomSheetConfig = bottomSheet,
|
||||
marketPriceBlockState = MarketPriceBlockState.Content(
|
||||
currencySymbol = "BTC",
|
||||
price = "98900.12$",
|
||||
priceChangeConfig = PriceChangeState.Content(
|
||||
valueInPercent = "5.16%",
|
||||
type = PriceChangeType.UP,
|
||||
),
|
||||
),
|
||||
txHistoryState = TxHistoryState.Content(
|
||||
contentItems = MutableStateFlow(
|
||||
PagingData.from(
|
||||
listOf(
|
||||
TxHistoryState.TxHistoryItemState.GroupTitle(
|
||||
title = "Today",
|
||||
itemKey = UUID.randomUUID().toString(),
|
||||
),
|
||||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
amount = "-0.500913 BTC",
|
||||
time = "8:41",
|
||||
status = TransactionState.Content.Status.Unconfirmed,
|
||||
direction = TransactionState.Content.Direction.OUTGOING,
|
||||
iconRes = com.tangem.core.ui.R.drawable.ic_arrow_up_24,
|
||||
title = resourceReference(com.tangem.core.ui.R.string.common_transfer),
|
||||
subtitle = TextReference.Str("33BddS...ga2B"),
|
||||
timestamp = 0L,
|
||||
onClick = {},
|
||||
),
|
||||
),
|
||||
TxHistoryState.TxHistoryItemState.GroupTitle(
|
||||
title = "Yesterday",
|
||||
itemKey = UUID.randomUUID().toString(),
|
||||
),
|
||||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
amount = "-0.500913 BTC",
|
||||
time = "8:41",
|
||||
status = TransactionState.Content.Status.Confirmed,
|
||||
direction = TransactionState.Content.Direction.OUTGOING,
|
||||
iconRes = com.tangem.core.ui.R.drawable.ic_arrow_up_24,
|
||||
title = resourceReference(com.tangem.core.ui.R.string.common_transfer),
|
||||
subtitle = TextReference.Str("33BddS...ga2B"),
|
||||
timestamp = 0L,
|
||||
onClick = {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
event = consumedEvent(),
|
||||
isBalanceHidden = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -26,17 +26,13 @@ import com.tangem.feature.wallet.presentation.WalletFragment
|
|||
import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensScreen
|
||||
import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensViewModel
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.WalletScreen
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.WalletScreenV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletViewModel
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletViewModelV2
|
||||
import com.tangem.features.tokendetails.navigation.TokenDetailsRouter
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/** Default implementation of wallet feature router */
|
||||
internal class DefaultWalletRouter(
|
||||
private val reduxNavController: ReduxNavController,
|
||||
private val walletFeatureToggles: WalletFeatureToggles,
|
||||
) : InnerWalletRouter {
|
||||
|
||||
private var navController: NavHostController by Delegates.notNull()
|
||||
|
|
@ -53,21 +49,12 @@ internal class DefaultWalletRouter(
|
|||
startDestination = WalletRoute.Wallet.route,
|
||||
) {
|
||||
composable(WalletRoute.Wallet.route) {
|
||||
if (walletFeatureToggles.isWalletsScrollingPreviewEnabled) {
|
||||
val viewModel = hiltViewModel<WalletViewModelV2>().apply {
|
||||
setWalletRouter(router = this@DefaultWalletRouter)
|
||||
subscribeToLifecycle(LocalLifecycleOwner.current)
|
||||
}
|
||||
|
||||
WalletScreenV2(state = viewModel.uiState.collectAsStateWithLifecycle().value)
|
||||
} else {
|
||||
val viewModel = hiltViewModel<WalletViewModel>().apply {
|
||||
router = this@DefaultWalletRouter
|
||||
}
|
||||
LocalLifecycleOwner.current.lifecycle.addObserver(viewModel)
|
||||
|
||||
WalletScreen(state = viewModel.uiState)
|
||||
val viewModel = hiltViewModel<WalletViewModel>().apply {
|
||||
setWalletRouter(router = this@DefaultWalletRouter)
|
||||
subscribeToLifecycle(LocalLifecycleOwner.current)
|
||||
}
|
||||
|
||||
WalletScreen(state = viewModel.uiState.collectAsStateWithLifecycle().value)
|
||||
}
|
||||
|
||||
composable(
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import com.tangem.domain.tokens.model.TokenList
|
|||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.Basic
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.MainScreen
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import java.math.BigDecimal
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package com.tangem.feature.wallet.presentation.wallet.analytics.utils
|
|||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.analytics.models.AnalyticsEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.MainScreen
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import javax.inject.Inject
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import com.tangem.domain.tokens.model.NetworkGroup
|
|||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase
|
||||
import com.tangem.domain.wallets.usecase.IsNeedToBackupUseCase
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -37,7 +37,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
|
||||
private var readyForRateAppNotification = false
|
||||
|
||||
fun create(clickIntents: WalletClickIntentsV2): Flow<ImmutableList<WalletNotification>> {
|
||||
fun create(clickIntents: WalletClickIntents): Flow<ImmutableList<WalletNotification>> {
|
||||
val userWallet = getSelectedWalletSyncUseCase().fold(
|
||||
ifLeft = {
|
||||
Timber.e("Failed to get selected wallet $it")
|
||||
|
|
@ -88,7 +88,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
private fun MutableList<WalletNotification>.addInformationalNotifications(
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
maybeTokenList: Either<TokenListError, TokenList>,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
addIf(
|
||||
element = WalletNotification.Informational.DemoCard,
|
||||
|
|
@ -100,7 +100,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
|
||||
private fun MutableList<WalletNotification>.addMissingAddressesNotification(
|
||||
maybeTokenList: Either<TokenListError, TokenList>,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
val currencies = maybeTokenList.getMissingAddressCurrencies()
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
cardTypesResolver: CardTypesResolver,
|
||||
tokenList: Either<TokenListError, TokenList>,
|
||||
isNeedToBackup: Boolean,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
addIf(
|
||||
element = WalletNotification.Warning.MissingBackup(
|
||||
|
|
@ -173,7 +173,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
|
|||
|
||||
private fun MutableList<WalletNotification>.addRateTheAppNotification(
|
||||
isReadyToShowRating: Boolean,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
addIf(
|
||||
element = WalletNotification.RateApp(
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
|||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase
|
||||
import com.tangem.domain.wallets.usecase.IsNeedToBackupUseCase
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -33,7 +33,7 @@ internal class GetSingleWalletWarningsFactory @Inject constructor(
|
|||
|
||||
private var readyForRateAppNotification = false
|
||||
|
||||
fun create(clickIntents: WalletClickIntentsV2): Flow<ImmutableList<WalletNotification>> {
|
||||
fun create(clickIntents: WalletClickIntents): Flow<ImmutableList<WalletNotification>> {
|
||||
val userWallet = getSelectedWalletSyncUseCase().fold(
|
||||
ifLeft = {
|
||||
Timber.e("Failed to get selected wallet $it")
|
||||
|
|
@ -99,7 +99,7 @@ internal class GetSingleWalletWarningsFactory @Inject constructor(
|
|||
cardTypesResolver: CardTypesResolver,
|
||||
maybePrimaryCurrencyStatus: Either<CurrencyStatusError, CryptoCurrencyStatus>,
|
||||
isNeedToBackup: Boolean,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
val cryptoCurrencyStatus = maybePrimaryCurrencyStatus.fold(ifLeft = { null }, ifRight = { it })
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ internal class GetSingleWalletWarningsFactory @Inject constructor(
|
|||
|
||||
private fun MutableList<WalletNotification>.addRateTheAppNotification(
|
||||
isReadyToShowRating: Boolean,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
addIf(
|
||||
element = WalletNotification.RateApp(
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.tangem.core.ui.utils.BigDecimalFormatter
|
|||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletAdditionalInfo
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletAdditionalInfo
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.tangem.feature.wallet.presentation.wallet.loaders
|
|||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.loaders.implementors.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ internal class WalletContentLoaderFactory @Inject constructor(
|
|||
|
||||
fun create(
|
||||
userWallet: UserWallet,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
isRefresh: Boolean = false,
|
||||
): WalletContentLoader? {
|
||||
return when {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.tangem.feature.wallet.presentation.wallet.loaders
|
|||
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
|
@ -35,7 +35,7 @@ internal class WalletScreenContentLoader @Inject constructor(
|
|||
*/
|
||||
fun load(
|
||||
userWallet: UserWallet,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
isRefresh: Boolean = false,
|
||||
coroutineScope: CoroutineScope,
|
||||
) {
|
||||
|
|
@ -67,7 +67,7 @@ internal class WalletScreenContentLoader @Inject constructor(
|
|||
|
||||
private fun loadInternal(
|
||||
userWallet: UserWallet,
|
||||
clickIntents: WalletClickIntentsV2,
|
||||
clickIntents: WalletClickIntents,
|
||||
coroutineScope: CoroutineScope,
|
||||
isRefresh: Boolean,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@ import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAn
|
|||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.MultiWalletTokenListSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.MultiWalletWarningsSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.WalletConnectNetworksSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.WalletSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
internal class MultiWalletContentLoader(
|
||||
private val userWallet: UserWallet,
|
||||
private val stateHolder: WalletStateController,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
private val walletWithFundsChecker: WalletWithFundsChecker,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAn
|
|||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ internal class MultiWalletContentLoaderFactory @Inject constructor(
|
|||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
) {
|
||||
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntentsV2): WalletContentLoader {
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntents): WalletContentLoader {
|
||||
return MultiWalletContentLoader(
|
||||
userWallet = userWallet,
|
||||
clickIntents = clickIntents,
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsUseCase
|
|||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetSingleWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
internal class SingleWalletContentLoader(
|
||||
private val userWallet: UserWallet,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val isRefresh: Boolean,
|
||||
private val stateHolder: WalletStateController,
|
||||
private val getPrimaryCurrencyStatusUpdatesUseCase: GetPrimaryCurrencyStatusUpdatesUseCase,
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsUseCase
|
|||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetSingleWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ internal class SingleWalletContentLoaderFactory @Inject constructor(
|
|||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
) {
|
||||
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntentsV2, isRefresh: Boolean): WalletContentLoader {
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntents, isRefresh: Boolean): WalletContentLoader {
|
||||
return SingleWalletContentLoader(
|
||||
userWallet = userWallet,
|
||||
clickIntents = clickIntents,
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAn
|
|||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.MultiWalletWarningsSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.SingleWalletWithTokenListSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.WalletSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
internal class SingleWalletWithTokenContentLoader(
|
||||
private val userWallet: UserWallet,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val stateHolder: WalletStateController,
|
||||
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAn
|
|||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import javax.inject.Inject
|
||||
|
||||
// TODO: Refactor
|
||||
|
|
@ -23,7 +23,7 @@ internal class SingleWalletWithTokenContentLoaderFactory @Inject constructor(
|
|||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
) {
|
||||
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntentsV2): SingleWalletWithTokenContentLoader {
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntents): SingleWalletWithTokenContentLoader {
|
||||
return SingleWalletWithTokenContentLoader(
|
||||
userWallet = userWallet,
|
||||
clickIntents = clickIntents,
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
|
|||
import com.tangem.domain.visa.GetVisaCurrencyUseCase
|
||||
import com.tangem.domain.visa.GetVisaTxHistoryUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.VisaWalletSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.WalletSubscriber
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
|
||||
internal class VisaWalletContentLoader(
|
||||
private val userWallet: UserWallet,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val isRefresh: Boolean,
|
||||
private val stateController: WalletStateController,
|
||||
private val getVisaTxHistoryUseCase: GetVisaTxHistoryUseCase,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
|
|||
import com.tangem.domain.visa.GetVisaCurrencyUseCase
|
||||
import com.tangem.domain.visa.GetVisaTxHistoryUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ internal class VisaWalletContentLoaderFactory @Inject constructor(
|
|||
private val getVisaTxHistoryUseCase: GetVisaTxHistoryUseCase,
|
||||
) {
|
||||
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntentsV2, isRefresh: Boolean): WalletContentLoader {
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntents, isRefresh: Boolean): WalletContentLoader {
|
||||
return VisaWalletContentLoader(
|
||||
userWallet = userWallet,
|
||||
clickIntents = clickIntents,
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
|
||||
/**
|
||||
* Locked wallet state
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal sealed interface WalletLockedState {
|
||||
|
||||
/** Lambda be invoked when unlock wallet notification is clicked */
|
||||
val onUnlockWalletsNotificationClick: () -> Unit
|
||||
|
||||
/** Lambda be invoked when unlock wallet button is clicked */
|
||||
val onUnlockClick: () -> Unit
|
||||
|
||||
/** Lambda be invoked when scan button is clicked */
|
||||
val onScanClick: () -> Unit
|
||||
|
||||
/** Bottom sheet visibility */
|
||||
val isBottomSheetShow: Boolean
|
||||
|
||||
/** Lambda be invoked when bottom sheet is dismissed */
|
||||
val onBottomSheetDismiss: () -> Unit
|
||||
|
||||
/** Get selected wallet index */
|
||||
fun getSelectedWalletIndex(): Int {
|
||||
return when (this) {
|
||||
is WalletMultiCurrencyState.Locked -> walletsListConfig.selectedWalletIndex
|
||||
is WalletSingleCurrencyState.Locked -> walletsListConfig.selectedWalletIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.event.StateEvent
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.*
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
/**
|
||||
* Multi currency wallet state
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal sealed class WalletMultiCurrencyState : WalletState.ContentState() {
|
||||
|
||||
/** Tokens list state */
|
||||
abstract val tokensListState: WalletTokensListState
|
||||
|
||||
data class Content(
|
||||
override val onBackClick: () -> Unit,
|
||||
override val topBarConfig: WalletTopBarConfig,
|
||||
override val walletsListConfig: WalletsListConfig,
|
||||
override val pullToRefreshConfig: WalletPullToRefreshConfig,
|
||||
override val notifications: ImmutableList<WalletNotification>,
|
||||
override val bottomSheetConfig: TangemBottomSheetConfig?,
|
||||
override val tokensListState: WalletTokensListState,
|
||||
override val event: StateEvent<WalletEvent> = consumedEvent(),
|
||||
override val isBalanceHidden: Boolean,
|
||||
val isManageTokensAvailable: Boolean = true,
|
||||
val onManageTokensClick: () -> Unit,
|
||||
) : WalletMultiCurrencyState()
|
||||
|
||||
data class Locked(
|
||||
override val onBackClick: () -> Unit,
|
||||
override val topBarConfig: WalletTopBarConfig,
|
||||
override val walletsListConfig: WalletsListConfig,
|
||||
override val pullToRefreshConfig: WalletPullToRefreshConfig,
|
||||
override val onUnlockWalletsNotificationClick: () -> Unit,
|
||||
override val onUnlockClick: () -> Unit,
|
||||
override val onScanClick: () -> Unit,
|
||||
override val isBottomSheetShow: Boolean = false,
|
||||
override val onBottomSheetDismiss: () -> Unit = {},
|
||||
override val event: StateEvent<WalletEvent> = consumedEvent(),
|
||||
override val isBalanceHidden: Boolean,
|
||||
) : WalletMultiCurrencyState(), WalletLockedState {
|
||||
|
||||
override val notifications = persistentListOf(
|
||||
WalletNotification.UnlockWallets(onUnlockWalletsNotificationClick),
|
||||
)
|
||||
|
||||
override val bottomSheetConfig = TangemBottomSheetConfig(
|
||||
isShow = isBottomSheetShow,
|
||||
onDismissRequest = onBottomSheetDismiss,
|
||||
content = WalletBottomSheetConfig.UnlockWallets(
|
||||
onUnlockClick = onUnlockClick,
|
||||
onScanClick = onScanClick,
|
||||
),
|
||||
)
|
||||
|
||||
override val tokensListState: WalletTokensListState = WalletTokensListState.Locked
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.event.StateEvent
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.*
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
/**
|
||||
* Single currency wallet content state
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
@Immutable
|
||||
internal sealed class WalletSingleCurrencyState : WalletState.ContentState() {
|
||||
|
||||
/** Manage buttons */
|
||||
abstract val buttons: PersistentList<WalletManageButton>
|
||||
|
||||
/** Transactions history state */
|
||||
abstract val txHistoryState: TxHistoryState
|
||||
|
||||
data class Content(
|
||||
override val onBackClick: () -> Unit,
|
||||
override val topBarConfig: WalletTopBarConfig,
|
||||
override val walletsListConfig: WalletsListConfig,
|
||||
override val pullToRefreshConfig: WalletPullToRefreshConfig,
|
||||
override val notifications: ImmutableList<WalletNotification>,
|
||||
override val bottomSheetConfig: TangemBottomSheetConfig?,
|
||||
override val buttons: PersistentList<WalletManageButton>,
|
||||
override val txHistoryState: TxHistoryState,
|
||||
override val event: StateEvent<WalletEvent> = consumedEvent(),
|
||||
override val isBalanceHidden: Boolean,
|
||||
val marketPriceBlockState: MarketPriceBlockState,
|
||||
) : WalletSingleCurrencyState()
|
||||
|
||||
data class Locked(
|
||||
override val onBackClick: () -> Unit,
|
||||
override val topBarConfig: WalletTopBarConfig,
|
||||
override val walletsListConfig: WalletsListConfig,
|
||||
override val pullToRefreshConfig: WalletPullToRefreshConfig,
|
||||
override val buttons: PersistentList<WalletManageButton>,
|
||||
override val onUnlockWalletsNotificationClick: () -> Unit,
|
||||
override val onUnlockClick: () -> Unit,
|
||||
override val onScanClick: () -> Unit,
|
||||
override val isBottomSheetShow: Boolean = false,
|
||||
override val onBottomSheetDismiss: () -> Unit = {},
|
||||
override val event: StateEvent<WalletEvent> = consumedEvent(),
|
||||
override val isBalanceHidden: Boolean,
|
||||
val onExploreClick: () -> Unit,
|
||||
) : WalletSingleCurrencyState(), WalletLockedState {
|
||||
|
||||
override val notifications = persistentListOf(
|
||||
WalletNotification.UnlockWallets(onUnlockWalletsNotificationClick),
|
||||
)
|
||||
|
||||
override val bottomSheetConfig = TangemBottomSheetConfig(
|
||||
isShow = isBottomSheetShow,
|
||||
onDismissRequest = onBottomSheetDismiss,
|
||||
content = WalletBottomSheetConfig.UnlockWallets(
|
||||
onUnlockClick = onUnlockClick,
|
||||
onScanClick = onScanClick,
|
||||
),
|
||||
)
|
||||
|
||||
override val txHistoryState: TxHistoryState = TxHistoryState.Content(
|
||||
contentItems = MutableStateFlow(
|
||||
value = PagingData.from(
|
||||
data = listOf(
|
||||
TxHistoryState.TxHistoryItemState.Title(onExploreClick = onExploreClick),
|
||||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
state = TransactionState.Locked(txHash = LOCKED_TX_HASH),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
private companion object {
|
||||
const val LOCKED_TX_HASH = "LOCKED_TX_HASH"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.event.StateEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletPullToRefreshConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTopBarConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletsListConfig
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
/**
|
||||
* Wallet screen state
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal sealed class WalletState {
|
||||
|
||||
/** Lambda be invoked when back button is clicked */
|
||||
abstract val onBackClick: () -> Unit
|
||||
|
||||
/** Wallet screen content state */
|
||||
sealed class ContentState : WalletState() {
|
||||
|
||||
/** Top bar config */
|
||||
abstract val topBarConfig: WalletTopBarConfig
|
||||
|
||||
/** Wallets list config */
|
||||
abstract val walletsListConfig: WalletsListConfig
|
||||
|
||||
/** Pull to refresh config */
|
||||
abstract val pullToRefreshConfig: WalletPullToRefreshConfig
|
||||
|
||||
/** Notifications */
|
||||
abstract val notifications: ImmutableList<WalletNotification>
|
||||
|
||||
/** Bottom sheet config */
|
||||
abstract val bottomSheetConfig: TangemBottomSheetConfig?
|
||||
|
||||
/** State event */
|
||||
abstract val event: StateEvent<WalletEvent>
|
||||
|
||||
/** Whether balance should be hidden */
|
||||
abstract val isBalanceHidden: Boolean
|
||||
|
||||
/**
|
||||
* Util function that allow to make a copy
|
||||
*
|
||||
* @param walletsListConfig wallets list config
|
||||
* @param pullToRefreshConfig pull to refresh config
|
||||
* @param event state event
|
||||
*/
|
||||
fun copySealed(
|
||||
walletsListConfig: WalletsListConfig = this.walletsListConfig,
|
||||
pullToRefreshConfig: WalletPullToRefreshConfig = this.pullToRefreshConfig,
|
||||
event: StateEvent<WalletEvent> = this.event,
|
||||
isBalanceHidden: Boolean = this.isBalanceHidden,
|
||||
): ContentState {
|
||||
return when (this) {
|
||||
is WalletMultiCurrencyState.Content -> {
|
||||
copy(
|
||||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig,
|
||||
event = event,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
is WalletMultiCurrencyState.Locked -> {
|
||||
copy(
|
||||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig,
|
||||
event = event,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
is WalletSingleCurrencyState.Content -> {
|
||||
copy(
|
||||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig,
|
||||
event = event,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
is WalletSingleCurrencyState.Locked -> {
|
||||
copy(
|
||||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig,
|
||||
event = event,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial state
|
||||
*
|
||||
* @property onBackClick lambda be invoked when back button is clicked
|
||||
*/
|
||||
data class Initial(override val onBackClick: () -> Unit) : WalletState()
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2
|
||||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTopBarConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.NOT_INITIALIZED_WALLET_INDEX
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.CloseBottomSheetTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.OpenBottomSheetTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.WalletScreenStateTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.NOT_INITIALIZED_WALLET_INDEX
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTopBarConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.CloseBottomSheetTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.OpenBottomSheetTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.WalletScreenStateTransformer
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenItemState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import javax.annotation.concurrent.Immutable
|
||||
|
||||
/**
|
||||
* Wallet tokens list state
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal sealed class WalletTokensListState {
|
||||
|
||||
/** Empty token list state */
|
||||
object Empty : WalletTokensListState()
|
||||
|
||||
/**
|
||||
* Wallet content token list state
|
||||
*
|
||||
* @property items content items
|
||||
*/
|
||||
sealed class ContentState(
|
||||
open val items: ImmutableList<TokensListItemState>,
|
||||
open val organizeTokensButton: OrganizeTokensButtonState,
|
||||
) : WalletTokensListState()
|
||||
|
||||
/**
|
||||
* Loading content state
|
||||
*
|
||||
* @property items content items
|
||||
*/
|
||||
data class Loading(
|
||||
override val items: ImmutableList<TokensListItemState.Token> = persistentListOf(),
|
||||
) : ContentState(items = items, organizeTokensButton = OrganizeTokensButtonState.Hidden)
|
||||
|
||||
/**
|
||||
* Content state
|
||||
*
|
||||
* @property items content items
|
||||
* @property organizeTokensButton represents the state of the 'Organize Tokens' button
|
||||
*/
|
||||
data class Content(
|
||||
override val items: ImmutableList<TokensListItemState>,
|
||||
override val organizeTokensButton: OrganizeTokensButtonState,
|
||||
) : ContentState(items, organizeTokensButton)
|
||||
|
||||
/** Locked content state */
|
||||
object Locked : ContentState(
|
||||
items = persistentListOf(
|
||||
TokensListItemState.NetworkGroupTitle(id = 42, name = TextReference.Res(id = R.string.main_tokens)),
|
||||
TokensListItemState.Token(state = TokenItemState.Locked(id = LOCKED_TOKEN_ID)),
|
||||
),
|
||||
organizeTokensButton = OrganizeTokensButtonState.Hidden,
|
||||
)
|
||||
|
||||
/**
|
||||
* Represents the state of the 'Organize Tokens' button.
|
||||
*/
|
||||
@Immutable
|
||||
sealed class OrganizeTokensButtonState {
|
||||
|
||||
/** Represents the state where the 'Organize Tokens' button is hidden. */
|
||||
object Hidden : OrganizeTokensButtonState()
|
||||
|
||||
/**
|
||||
* Represents the state where the 'Organize Tokens' button is visible.
|
||||
*
|
||||
* @property isEnabled Indicates if the button is enabled or not.
|
||||
* @property onClick Callback to be executed when the button is clicked.
|
||||
*/
|
||||
data class Visible(
|
||||
val isEnabled: Boolean,
|
||||
val onClick: () -> Unit,
|
||||
) : OrganizeTokensButtonState()
|
||||
}
|
||||
|
||||
/** Tokens list item state */
|
||||
@Immutable
|
||||
sealed interface TokensListItemState {
|
||||
|
||||
val id: Any
|
||||
|
||||
/**
|
||||
* Network group title item
|
||||
*
|
||||
* @property name network name
|
||||
*/
|
||||
data class NetworkGroupTitle(
|
||||
override val id: Int,
|
||||
val name: TextReference,
|
||||
) : TokensListItemState
|
||||
|
||||
/**
|
||||
* Token item
|
||||
*
|
||||
* @property state token item state
|
||||
*/
|
||||
data class Token(val state: TokenItemState) : TokensListItemState {
|
||||
override val id: String = state.id
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val LOCKED_TOKEN_ID = "Locked#1"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
/**
|
||||
* Wallets list config
|
||||
*
|
||||
* @property selectedWalletIndex selected wallet index
|
||||
* @property wallets wallets list
|
||||
* @property onWalletChange lambda be invoked when wallet is swiped
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal data class WalletsListConfig(
|
||||
val selectedWalletIndex: Int,
|
||||
val wallets: ImmutableList<WalletCardState>,
|
||||
val onWalletChange: (Int) -> Unit,
|
||||
)
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.TokenActionsState
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenItemState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.TokenActionButtonConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.isNullOrZero
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
/**
|
||||
* Converter from loaded [TokenItemState.Content] to ImmutableList<[TokenActionButtonConfig]>
|
||||
*
|
||||
* @property currentWalletProvider current wallet provider
|
||||
* @property clickIntents screen click intents
|
||||
*/
|
||||
internal class TokenActionsProvider(
|
||||
private val currentWalletProvider: Provider<UserWallet>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) {
|
||||
|
||||
fun provideActions(tokenActions: TokenActionsState): ImmutableList<TokenActionButtonConfig> {
|
||||
return tokenActions.states
|
||||
.filterIfSingleWithToken()
|
||||
.mapNotNull {
|
||||
mapTokenActionState(
|
||||
actionsState = it,
|
||||
cryptoCurrencyStatus = tokenActions.cryptoCurrencyStatus,
|
||||
)
|
||||
}
|
||||
.toImmutableList()
|
||||
}
|
||||
|
||||
private fun List<TokenActionsState.ActionState>.filterIfSingleWithToken(): List<TokenActionsState.ActionState> {
|
||||
return if (currentWalletProvider().scanResponse.cardTypesResolver.isSingleWalletWithToken()) {
|
||||
filter { it !is TokenActionsState.ActionState.HideToken }
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
private fun mapTokenActionState(
|
||||
actionsState: TokenActionsState.ActionState,
|
||||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
): TokenActionButtonConfig? {
|
||||
if (actionsState is TokenActionsState.ActionState.Send && cryptoCurrencyStatus.value.amount.isNullOrZero()) {
|
||||
return null
|
||||
}
|
||||
val title: TextReference
|
||||
val icon: Int
|
||||
val action: () -> Unit
|
||||
when (actionsState) {
|
||||
is TokenActionsState.ActionState.Buy -> {
|
||||
title = resourceReference(R.string.common_buy)
|
||||
icon = R.drawable.ic_plus_24
|
||||
action = { clickIntents.onBuyClick(cryptoCurrencyStatus) }
|
||||
}
|
||||
is TokenActionsState.ActionState.Receive -> {
|
||||
title = resourceReference(R.string.common_receive)
|
||||
icon = R.drawable.ic_arrow_down_24
|
||||
action = { clickIntents.onReceiveClick(cryptoCurrencyStatus) }
|
||||
}
|
||||
is TokenActionsState.ActionState.Sell -> {
|
||||
title = resourceReference(R.string.common_sell)
|
||||
icon = R.drawable.ic_currency_24
|
||||
action = { clickIntents.onSellClick(cryptoCurrencyStatus) }
|
||||
}
|
||||
is TokenActionsState.ActionState.Send -> {
|
||||
title = resourceReference(R.string.common_send)
|
||||
icon = R.drawable.ic_arrow_up_24
|
||||
action = { clickIntents.onMultiCurrencySendClick(cryptoCurrencyStatus) }
|
||||
}
|
||||
is TokenActionsState.ActionState.Swap -> {
|
||||
title = resourceReference(R.string.swapping_swap_action)
|
||||
icon = R.drawable.ic_exchange_horizontal_24
|
||||
action = { clickIntents.onSwapClick(cryptoCurrencyStatus) }
|
||||
}
|
||||
is TokenActionsState.ActionState.CopyAddress -> {
|
||||
title = resourceReference(R.string.common_copy_address)
|
||||
icon = R.drawable.ic_copy_24
|
||||
action = { clickIntents.onCopyAddressClick(cryptoCurrencyStatus) }
|
||||
}
|
||||
is TokenActionsState.ActionState.HideToken -> {
|
||||
title = resourceReference(R.string.token_details_hide_token)
|
||||
icon = R.drawable.ic_hide_24
|
||||
action = { clickIntents.onHideTokensClick(cryptoCurrencyStatus) }
|
||||
}
|
||||
}
|
||||
return TokenActionButtonConfig(
|
||||
text = title,
|
||||
iconResId = icon,
|
||||
onClick = action,
|
||||
isWarning = actionsState is TokenActionsState.ActionState.HideToken,
|
||||
enabled = actionsState.enabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
|
||||
data class TokenListWithWallet(
|
||||
val tokenList: TokenList,
|
||||
val wallet: UserWallet,
|
||||
)
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.tokens.model.TokenActionsState
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
|
||||
internal class WalletCryptoCurrencyActionsConverter(
|
||||
private val currentWalletProvider: Provider<UserWallet>,
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<TokenActionsState, WalletState> {
|
||||
|
||||
override fun convert(value: TokenActionsState): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletSingleCurrencyState.Content -> state.copy(buttons = value.mapToManageButtons())
|
||||
is WalletSingleCurrencyState.Locked,
|
||||
is WalletMultiCurrencyState,
|
||||
is WalletState.Initial,
|
||||
-> state
|
||||
}
|
||||
}
|
||||
|
||||
private fun TokenActionsState.mapToManageButtons(): PersistentList<WalletManageButton> {
|
||||
return this.states
|
||||
.filterIfS2C()
|
||||
.mapNotNull { action ->
|
||||
when (action) {
|
||||
is TokenActionsState.ActionState.Buy -> {
|
||||
WalletManageButton.Buy(
|
||||
enabled = action.enabled,
|
||||
onClick = { clickIntents.onBuyClick(cryptoCurrencyStatus) },
|
||||
)
|
||||
}
|
||||
is TokenActionsState.ActionState.Receive -> {
|
||||
WalletManageButton.Receive(
|
||||
enabled = action.enabled,
|
||||
onClick = { clickIntents.onReceiveClick(cryptoCurrencyStatus) },
|
||||
)
|
||||
}
|
||||
is TokenActionsState.ActionState.Sell -> {
|
||||
WalletManageButton.Sell(
|
||||
enabled = action.enabled,
|
||||
onClick = { clickIntents.onSellClick(cryptoCurrencyStatus) },
|
||||
)
|
||||
}
|
||||
is TokenActionsState.ActionState.Send -> {
|
||||
WalletManageButton.Send(
|
||||
enabled = action.enabled,
|
||||
onClick = { clickIntents.onSingleCurrencySendClick(cryptoCurrencyStatus) },
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
.toPersistentList()
|
||||
}
|
||||
|
||||
private fun List<TokenActionsState.ActionState>.filterIfS2C(): List<TokenActionsState.ActionState> {
|
||||
return if (currentWalletProvider().scanResponse.cardTypesResolver.isStart2Coin()) {
|
||||
filterNot { it is TokenActionsState.ActionState.Buy || it is TokenActionsState.ActionState.Sell }
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.factory.WalletDeleteStateConverter.DeleteWalletModel
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletsUpdateActionResolver
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
/**
|
||||
* Converter that responds on wallet deleting action. Returns [WalletState] without deleted wallet.
|
||||
*
|
||||
* @property currentStateProvider current state provider
|
||||
*/
|
||||
internal class WalletDeleteStateConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
) : Converter<DeleteWalletModel, WalletState> {
|
||||
|
||||
override fun convert(value: DeleteWalletModel): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletState.ContentState -> {
|
||||
value.cacheState.copySealed(
|
||||
walletsListConfig = state.walletsListConfig.copy(
|
||||
selectedWalletIndex = value.action.selectedWalletIndex,
|
||||
wallets = state.walletsListConfig.wallets.deleteWallet(id = value.action.deletedWalletId),
|
||||
),
|
||||
pullToRefreshConfig = value.cacheState.pullToRefreshConfig.copy(isRefreshing = false),
|
||||
)
|
||||
}
|
||||
is WalletState.Initial -> state
|
||||
}
|
||||
}
|
||||
|
||||
private fun List<WalletCardState>.deleteWallet(id: UserWalletId): ImmutableList<WalletCardState> {
|
||||
return this
|
||||
.mapIndexedNotNull { index, currentWallet ->
|
||||
if (currentWallet.id == id) return@mapIndexedNotNull null
|
||||
getOrNull(index) ?: return@mapIndexedNotNull null
|
||||
}
|
||||
.toImmutableList()
|
||||
}
|
||||
|
||||
data class DeleteWalletModel(
|
||||
val cacheState: WalletState.ContentState,
|
||||
val action: WalletsUpdateActionResolver.Action.DeleteWallet,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import arrow.core.Either
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.error.TokenListError
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.TokenListErrorConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.TokenListToWalletStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
/**
|
||||
* Converter from loaded [TokenListError] or [TokenList] to [WalletMultiCurrencyState]
|
||||
*
|
||||
* @property currentStateProvider current ui state provider
|
||||
* @property tokenListErrorConverter converter of tokens list
|
||||
* @param appCurrencyProvider app currency provider
|
||||
* @param currentWalletProvider current wallet provider
|
||||
* @param clickIntents screen click intents
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
@Suppress("LongParameterList")
|
||||
internal class WalletLoadedTokensListConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val tokenListErrorConverter: TokenListErrorConverter,
|
||||
appCurrencyProvider: Provider<AppCurrency>,
|
||||
currentWalletProvider: Provider<UserWallet>,
|
||||
clickIntents: WalletClickIntents,
|
||||
) : Converter<Either<TokenListError, TokenListWithWallet>, WalletState> {
|
||||
|
||||
private val tokenListStateConverter = TokenListToWalletStateConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
currentWalletProvider = currentWalletProvider,
|
||||
appCurrencyProvider = appCurrencyProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
|
||||
override fun convert(value: Either<TokenListError, TokenListWithWallet>): WalletState {
|
||||
return value.fold(
|
||||
ifLeft = tokenListErrorConverter::convert,
|
||||
ifRight = tokenListStateConverter::convert,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletPullToRefreshConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTopBarConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
|
||||
internal class WalletLockedConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<Unit, WalletState> {
|
||||
|
||||
override fun convert(value: Unit): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletMultiCurrencyState.Content -> state.toMultiCurrencyLockedState()
|
||||
is WalletSingleCurrencyState.Content -> state.toSingleCurrencyLockedState()
|
||||
is WalletMultiCurrencyState.Locked,
|
||||
is WalletSingleCurrencyState.Locked,
|
||||
is WalletState.Initial,
|
||||
-> state
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletMultiCurrencyState.Content.toMultiCurrencyLockedState(): WalletState {
|
||||
return WalletMultiCurrencyState.Locked(
|
||||
onBackClick = onBackClick,
|
||||
topBarConfig = topBarConfig.updateCallback(),
|
||||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig.stopRefreshing(),
|
||||
onUnlockWalletsNotificationClick = clickIntents::onUnlockWalletNotificationClick,
|
||||
onUnlockClick = clickIntents::onUnlockWalletClick,
|
||||
onScanClick = clickIntents::onScanToUnlockWalletClick,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletSingleCurrencyState.Content.toSingleCurrencyLockedState(): WalletState {
|
||||
return WalletSingleCurrencyState.Locked(
|
||||
onBackClick = onBackClick,
|
||||
topBarConfig = topBarConfig.updateCallback(),
|
||||
walletsListConfig = walletsListConfig,
|
||||
pullToRefreshConfig = pullToRefreshConfig.stopRefreshing(),
|
||||
buttons = buttons.disableButtons(),
|
||||
onUnlockWalletsNotificationClick = clickIntents::onUnlockWalletNotificationClick,
|
||||
onUnlockClick = clickIntents::onUnlockWalletClick,
|
||||
onScanClick = clickIntents::onScanToUnlockWalletClick,
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletTopBarConfig.updateCallback(): WalletTopBarConfig {
|
||||
return copy(onDetailsClick = clickIntents::onUnlockWalletNotificationClick)
|
||||
}
|
||||
|
||||
private fun WalletPullToRefreshConfig.stopRefreshing(): WalletPullToRefreshConfig {
|
||||
return copy(isRefreshing = false)
|
||||
}
|
||||
|
||||
private fun PersistentList<WalletManageButton>.disableButtons(): PersistentList<WalletManageButton> {
|
||||
return this
|
||||
.map { button ->
|
||||
when (button) {
|
||||
is WalletManageButton.Buy -> button.copy(enabled = false)
|
||||
is WalletManageButton.Sell -> button.copy(enabled = false)
|
||||
is WalletManageButton.Send -> button.copy(enabled = false)
|
||||
is WalletManageButton.Swap -> button.copy(enabled = false)
|
||||
is WalletManageButton.Receive -> button.copy(enabled = false)
|
||||
}
|
||||
}
|
||||
.toPersistentList()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletPullToRefreshConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTokensListState
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.mutate
|
||||
|
||||
internal class WalletRefreshStateConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
) : Converter<Boolean, WalletState> {
|
||||
|
||||
override fun convert(value: Boolean): WalletState {
|
||||
val state = currentStateProvider()
|
||||
val contentState = state as? WalletState.ContentState ?: return state
|
||||
|
||||
return if (value) {
|
||||
contentState.getRefreshingState()
|
||||
} else {
|
||||
contentState.getRefreshedState()
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletState.ContentState.getRefreshingState(): WalletState {
|
||||
return when (this) {
|
||||
is WalletMultiCurrencyState.Content -> getRefreshingState()
|
||||
is WalletSingleCurrencyState.Content -> getRefreshingState()
|
||||
is WalletMultiCurrencyState.Locked,
|
||||
is WalletSingleCurrencyState.Locked,
|
||||
-> this
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletState.ContentState.getRefreshedState(): WalletState {
|
||||
return when (this) {
|
||||
is WalletMultiCurrencyState.Content -> getRefreshedState()
|
||||
is WalletSingleCurrencyState.Content -> getRefreshedState()
|
||||
is WalletMultiCurrencyState.Locked,
|
||||
is WalletSingleCurrencyState.Locked,
|
||||
-> this
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletMultiCurrencyState.Content.getRefreshingState(): WalletMultiCurrencyState {
|
||||
return copy(
|
||||
pullToRefreshConfig = updatePullToRefreshConfig(isRefreshing = true),
|
||||
tokensListState = updateTokenListState(isRefreshing = true),
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletSingleCurrencyState.Content.getRefreshingState(): WalletSingleCurrencyState {
|
||||
return copy(
|
||||
pullToRefreshConfig = updatePullToRefreshConfig(isRefreshing = true),
|
||||
buttons = updateButtons(isRefreshing = true),
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletMultiCurrencyState.Content.getRefreshedState(): WalletMultiCurrencyState {
|
||||
return copy(
|
||||
pullToRefreshConfig = updatePullToRefreshConfig(isRefreshing = false),
|
||||
tokensListState = updateTokenListState(isRefreshing = false),
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletSingleCurrencyState.Content.getRefreshedState(): WalletSingleCurrencyState {
|
||||
return copy(
|
||||
pullToRefreshConfig = updatePullToRefreshConfig(isRefreshing = false),
|
||||
buttons = updateButtons(isRefreshing = false),
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletMultiCurrencyState.updateTokenListState(isRefreshing: Boolean): WalletTokensListState {
|
||||
return when (val listState = tokensListState) {
|
||||
is WalletTokensListState.Content -> {
|
||||
when (listState.organizeTokensButton) {
|
||||
is WalletTokensListState.OrganizeTokensButtonState.Hidden -> listState
|
||||
is WalletTokensListState.OrganizeTokensButtonState.Visible -> listState.copy(
|
||||
organizeTokensButton = listState.organizeTokensButton.copy(
|
||||
isEnabled = !isRefreshing,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
is WalletTokensListState.Locked,
|
||||
is WalletTokensListState.Loading,
|
||||
is WalletTokensListState.Empty,
|
||||
-> listState
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletSingleCurrencyState.updateButtons(isRefreshing: Boolean): PersistentList<WalletManageButton> {
|
||||
val isButtonsEnabled = !isRefreshing
|
||||
|
||||
return buttons.mutate {
|
||||
it.mapNotNull { button ->
|
||||
when (button) {
|
||||
is WalletManageButton.Buy -> button.copy(enabled = isButtonsEnabled)
|
||||
is WalletManageButton.Send -> button.copy(enabled = isButtonsEnabled)
|
||||
is WalletManageButton.Sell -> button.copy(enabled = isButtonsEnabled)
|
||||
is WalletManageButton.Receive -> button
|
||||
is WalletManageButton.Swap -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletState.ContentState.updatePullToRefreshConfig(isRefreshing: Boolean): WalletPullToRefreshConfig {
|
||||
return pullToRefreshConfig.copy(isRefreshing = isRefreshing)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletsListConfig
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
internal class WalletRenameStateConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
) : Converter<String, WalletState> {
|
||||
|
||||
override fun convert(value: String): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletState.ContentState -> {
|
||||
state.copySealed(
|
||||
walletsListConfig = state.walletsListConfig.renameSelectedWallet(name = value),
|
||||
)
|
||||
}
|
||||
is WalletState.Initial -> state
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletsListConfig.renameSelectedWallet(name: String): WalletsListConfig {
|
||||
return copy(
|
||||
wallets = wallets
|
||||
.mapIndexed { index, walletCard ->
|
||||
if (index == selectedWalletIndex) walletCard.copySealed(title = name) else walletCard
|
||||
}
|
||||
.toImmutableList(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import arrow.core.Either
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeState
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeType
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.error.CurrencyStatusError
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.getCardsCount
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletsListConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.CurrencyStatusErrorConverter
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import java.math.BigDecimal
|
||||
|
||||
internal class WalletSingleCurrencyLoadedBalanceConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
private val currentWalletProvider: Provider<UserWallet>,
|
||||
private val currencyStatusErrorConverter: CurrencyStatusErrorConverter,
|
||||
) : Converter<Either<CurrencyStatusError, CryptoCurrencyStatus>, WalletState> {
|
||||
|
||||
override fun convert(value: Either<CurrencyStatusError, CryptoCurrencyStatus>): WalletState {
|
||||
return value.fold(
|
||||
ifLeft = currencyStatusErrorConverter::convert,
|
||||
ifRight = ::convertContent,
|
||||
)
|
||||
}
|
||||
|
||||
private fun convertContent(status: CryptoCurrencyStatus): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletSingleCurrencyState.Content -> {
|
||||
val currencyName = state.marketPriceBlockState.currencySymbol
|
||||
|
||||
state.copy(
|
||||
walletsListConfig = getUpdatedSelectedWallet(status = status.value, state = state),
|
||||
marketPriceBlockState = getMarketPriceState(status = status.value, currencySymbol = currencyName),
|
||||
)
|
||||
}
|
||||
is WalletMultiCurrencyState.Content,
|
||||
is WalletMultiCurrencyState.Locked,
|
||||
is WalletSingleCurrencyState.Locked,
|
||||
is WalletState.Initial,
|
||||
-> state
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMarketPriceState(
|
||||
status: CryptoCurrencyStatus.Status,
|
||||
currencySymbol: String,
|
||||
): MarketPriceBlockState {
|
||||
return when (status) {
|
||||
is CryptoCurrencyStatus.Loaded,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> status.toContentConfig(currencySymbol)
|
||||
is CryptoCurrencyStatus.NoAccount -> {
|
||||
if (status.fiatRate == null) {
|
||||
MarketPriceBlockState.Error(currencySymbol)
|
||||
} else {
|
||||
status.toContentConfig(currencySymbol)
|
||||
}
|
||||
}
|
||||
is CryptoCurrencyStatus.Loading -> MarketPriceBlockState.Loading(currencySymbol)
|
||||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
-> MarketPriceBlockState.Error(currencySymbol)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getUpdatedSelectedWallet(
|
||||
status: CryptoCurrencyStatus.Status,
|
||||
state: WalletSingleCurrencyState,
|
||||
): WalletsListConfig {
|
||||
val selectedWallet = state.walletsListConfig.wallets[state.walletsListConfig.selectedWalletIndex]
|
||||
|
||||
val updatedWallet = when (status) {
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
is CryptoCurrencyStatus.Loaded,
|
||||
is CryptoCurrencyStatus.NoAccount,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> {
|
||||
WalletCardState.Content(
|
||||
id = selectedWallet.id,
|
||||
title = selectedWallet.title,
|
||||
additionalInfo = WalletAdditionalInfoFactory.resolve(
|
||||
wallet = currentWalletProvider(),
|
||||
currencyAmount = status.amount,
|
||||
),
|
||||
imageResId = selectedWallet.imageResId,
|
||||
onRenameClick = selectedWallet.onRenameClick,
|
||||
onDeleteClick = selectedWallet.onDeleteClick,
|
||||
balance = formatFiatAmount(status = status, appCurrency = appCurrencyProvider()),
|
||||
cardCount = currentWalletProvider().getCardsCount(),
|
||||
)
|
||||
}
|
||||
is CryptoCurrencyStatus.Loading -> {
|
||||
WalletCardState.Loading(
|
||||
id = selectedWallet.id,
|
||||
title = selectedWallet.title,
|
||||
imageResId = selectedWallet.imageResId,
|
||||
onRenameClick = selectedWallet.onRenameClick,
|
||||
onDeleteClick = selectedWallet.onDeleteClick,
|
||||
)
|
||||
}
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Custom,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
-> {
|
||||
WalletCardState.Error(
|
||||
id = selectedWallet.id,
|
||||
title = selectedWallet.title,
|
||||
imageResId = selectedWallet.imageResId,
|
||||
onRenameClick = selectedWallet.onRenameClick,
|
||||
onDeleteClick = selectedWallet.onDeleteClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return state.walletsListConfig.copy(
|
||||
wallets = state.walletsListConfig.wallets.toPersistentList()
|
||||
.set(index = state.walletsListConfig.selectedWalletIndex, element = updatedWallet),
|
||||
)
|
||||
}
|
||||
|
||||
private fun CryptoCurrencyStatus.Status.toContentConfig(currencySymbol: String): MarketPriceBlockState.Content {
|
||||
return MarketPriceBlockState.Content(
|
||||
currencySymbol = currencySymbol,
|
||||
price = formatPrice(status = this, appCurrency = appCurrencyProvider()),
|
||||
priceChangeConfig = PriceChangeState.Content(
|
||||
valueInPercent = formatPriceChange(status = this),
|
||||
type = getPriceChangeType(status = this),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun getPriceChangeType(status: CryptoCurrencyStatus.Status): PriceChangeType {
|
||||
val priceChange = status.priceChange ?: return PriceChangeType.DOWN
|
||||
|
||||
return if (priceChange > BigDecimal.ZERO) PriceChangeType.UP else PriceChangeType.DOWN
|
||||
}
|
||||
|
||||
private fun formatPriceChange(status: CryptoCurrencyStatus.Status): String {
|
||||
val priceChange = status.priceChange ?: return BigDecimalFormatter.EMPTY_BALANCE_SIGN
|
||||
|
||||
return BigDecimalFormatter.formatPercent(
|
||||
percent = priceChange,
|
||||
useAbsoluteValue = true,
|
||||
)
|
||||
}
|
||||
|
||||
private fun formatPrice(status: CryptoCurrencyStatus.Status, appCurrency: AppCurrency): String {
|
||||
val fiatRate = status.fiatRate ?: return BigDecimalFormatter.EMPTY_BALANCE_SIGN
|
||||
|
||||
return BigDecimalFormatter.formatFiatAmount(
|
||||
fiatAmount = fiatRate,
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
)
|
||||
}
|
||||
|
||||
private fun formatFiatAmount(status: CryptoCurrencyStatus.Status, appCurrency: AppCurrency): String {
|
||||
val fiatAmount = status.fiatAmount ?: return BigDecimalFormatter.EMPTY_BALANCE_SIGN
|
||||
|
||||
return BigDecimalFormatter.formatFiatAmount(
|
||||
fiatAmount = fiatAmount,
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletImageResolver
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.factory.WalletSkeletonStateConverter.SkeletonModel
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
/**
|
||||
* Converter from loaded list of [UserWallet] to skeleton state of screen [WalletState.ContentState]
|
||||
*
|
||||
* @property currentStateProvider current ui state provider
|
||||
* @property clickIntents screen click intents
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class WalletSkeletonStateConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val isBalanceHiddenProvider: Provider<Boolean>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<SkeletonModel, WalletState.ContentState> {
|
||||
|
||||
override fun convert(value: SkeletonModel): WalletState.ContentState {
|
||||
val selectedWallet = value.wallets[value.selectedWalletIndex]
|
||||
|
||||
val isSingleWalletWithToken = !selectedWallet.isMultiCurrency &&
|
||||
selectedWallet.scanResponse.walletData?.token != null
|
||||
return if (selectedWallet.isMultiCurrency || isSingleWalletWithToken) {
|
||||
createMultiCurrencyState(value = value)
|
||||
} else {
|
||||
createSingleCurrencyState(value = value, currencyName = selectedWallet.getPrimaryCurrencyName())
|
||||
}
|
||||
}
|
||||
|
||||
private fun createMultiCurrencyState(value: SkeletonModel): WalletMultiCurrencyState {
|
||||
return WalletMultiCurrencyState.Content(
|
||||
onBackClick = clickIntents::onBackClick,
|
||||
topBarConfig = createTopBarConfig(),
|
||||
walletsListConfig = createWalletsListConfig(value),
|
||||
pullToRefreshConfig = createPullToRefreshConfig(),
|
||||
tokensListState = WalletTokensListState.Loading(),
|
||||
notifications = persistentListOf(),
|
||||
bottomSheetConfig = null,
|
||||
onManageTokensClick = clickIntents::onManageTokensClick,
|
||||
isBalanceHidden = isBalanceHiddenProvider(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun createSingleCurrencyState(value: SkeletonModel, currencyName: String): WalletSingleCurrencyState {
|
||||
return WalletSingleCurrencyState.Content(
|
||||
onBackClick = clickIntents::onBackClick,
|
||||
topBarConfig = createTopBarConfig(),
|
||||
walletsListConfig = createWalletsListConfig(value),
|
||||
pullToRefreshConfig = createPullToRefreshConfig(),
|
||||
notifications = persistentListOf(),
|
||||
bottomSheetConfig = null,
|
||||
buttons = createButtons(),
|
||||
marketPriceBlockState = MarketPriceBlockState.Loading(currencySymbol = currencyName),
|
||||
txHistoryState = TxHistoryState.Content(
|
||||
contentItems = MutableStateFlow(
|
||||
value = TxHistoryState.getDefaultLoadingTransactions(clickIntents::onExploreClick),
|
||||
),
|
||||
),
|
||||
isBalanceHidden = isBalanceHiddenProvider(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun UserWallet.getPrimaryCurrencyName(): String {
|
||||
return scanResponse.cardTypesResolver.getBlockchain().currency
|
||||
}
|
||||
|
||||
private fun createTopBarConfig(): WalletTopBarConfig {
|
||||
return WalletTopBarConfig(onDetailsClick = clickIntents::onDetailsClick)
|
||||
}
|
||||
|
||||
private fun createWalletsListConfig(value: SkeletonModel): WalletsListConfig {
|
||||
return WalletsListConfig(
|
||||
selectedWalletIndex = value.selectedWalletIndex,
|
||||
wallets = value.wallets.map(::createWalletCardState).toImmutableList(),
|
||||
onWalletChange = clickIntents::onWalletChange,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create wallet card state by [wallet].
|
||||
* If current wallet card state is initialized, then method returns it.
|
||||
* Otherwise, returns loading wallet card state.
|
||||
*/
|
||||
private fun createWalletCardState(wallet: UserWallet): WalletCardState {
|
||||
return currentStateProvider().getInitializedWalletCardState(wallet.walletId) ?: wallet.mapToWalletCardState()
|
||||
}
|
||||
|
||||
private fun WalletState.getInitializedWalletCardState(walledId: UserWalletId): WalletCardState? {
|
||||
return (this as? WalletState.ContentState)?.walletsListConfig?.wallets?.firstOrNull { it.id == walledId }
|
||||
}
|
||||
|
||||
private fun UserWallet.mapToWalletCardState(): WalletCardState {
|
||||
return if (isLocked) mapToLockedWalletCardState() else mapToLoadingWalletCardState()
|
||||
}
|
||||
|
||||
private fun UserWallet.mapToLockedWalletCardState(): WalletCardState {
|
||||
return WalletCardState.LockedContent(
|
||||
id = walletId,
|
||||
title = name,
|
||||
additionalInfo = WalletAdditionalInfoFactory.resolve(wallet = this),
|
||||
imageResId = createImageResId(),
|
||||
onRenameClick = clickIntents::onRenameClick,
|
||||
onDeleteClick = clickIntents::onDeleteBeforeConfirmationClick,
|
||||
)
|
||||
}
|
||||
|
||||
private fun UserWallet.mapToLoadingWalletCardState(): WalletCardState {
|
||||
return WalletCardState.Loading(
|
||||
id = walletId,
|
||||
title = name,
|
||||
additionalInfo = if (isMultiCurrency) WalletAdditionalInfoFactory.resolve(wallet = this) else null,
|
||||
imageResId = createImageResId(),
|
||||
onRenameClick = clickIntents::onRenameClick,
|
||||
onDeleteClick = clickIntents::onDeleteBeforeConfirmationClick,
|
||||
)
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
private fun UserWallet.createImageResId(): Int? {
|
||||
return WalletImageResolver.resolve(userWallet = this)
|
||||
}
|
||||
|
||||
private fun createPullToRefreshConfig(): WalletPullToRefreshConfig {
|
||||
return WalletPullToRefreshConfig(isRefreshing = false, onRefresh = clickIntents::onRefreshSwipe)
|
||||
}
|
||||
|
||||
private fun createButtons(): PersistentList<WalletManageButton> {
|
||||
return persistentListOf(
|
||||
WalletManageButton.Buy(enabled = false, onClick = {}),
|
||||
WalletManageButton.Send(enabled = false, onClick = {}),
|
||||
WalletManageButton.Receive(enabled = false, onClick = {}),
|
||||
WalletManageButton.Sell(enabled = false, onClick = {}),
|
||||
)
|
||||
}
|
||||
|
||||
data class SkeletonModel(val wallets: List<UserWallet>, val selectedWalletIndex: Int)
|
||||
}
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import arrow.core.Either
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.core.ui.event.triggeredEvent
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.common.CardTypesResolver
|
||||
import com.tangem.domain.tokens.error.CurrencyStatusError
|
||||
import com.tangem.domain.tokens.error.TokenListError
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.TokenActionsState
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.domain.txhistory.models.TxHistoryListError
|
||||
import com.tangem.domain.txhistory.models.TxHistoryStateError
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory.WalletLoadedTxHistoryConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory.WalletLoadingTxHistoryConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.CurrencyStatusErrorConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.HiddenStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.TokenListErrorConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletsUpdateActionResolver
|
||||
import com.tangem.utils.Provider
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/**
|
||||
* Main factory for creating [WalletState]
|
||||
*
|
||||
* @property currentStateProvider current ui state provider
|
||||
* @property currentCardTypeResolverProvider current card type resolver
|
||||
* @property currentWalletProvider current wallet
|
||||
* @property appCurrencyProvider app currency provider
|
||||
* @property clickIntents screen click intents
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
internal class WalletStateFactory(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val currentCardTypeResolverProvider: Provider<CardTypesResolver>,
|
||||
private val currentWalletProvider: Provider<UserWallet>,
|
||||
private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
private val isBalanceHiddenProvider: Provider<Boolean>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) {
|
||||
|
||||
private val tokenActionsProvider by lazy { TokenActionsProvider(currentWalletProvider, clickIntents) }
|
||||
|
||||
private val skeletonConverter by lazy {
|
||||
WalletSkeletonStateConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
isBalanceHiddenProvider = isBalanceHiddenProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
private val walletsUnlockStateConverter by lazy { WalletsUnlockStateConverter(currentStateProvider, clickIntents) }
|
||||
|
||||
private val walletRenameStateConverter by lazy { WalletRenameStateConverter(currentStateProvider) }
|
||||
|
||||
private val walletDeleteStateConverter by lazy { WalletDeleteStateConverter(currentStateProvider) }
|
||||
|
||||
private val hiddenStateConverter by lazy { HiddenStateConverter(currentStateProvider) }
|
||||
|
||||
private val walletUpdateCardCountConverter by lazy {
|
||||
WalletUpdateCardCountConverter(
|
||||
currentStateProvider,
|
||||
currentWalletProvider,
|
||||
)
|
||||
}
|
||||
|
||||
private val tokenListErrorConverter by lazy {
|
||||
TokenListErrorConverter(currentStateProvider)
|
||||
}
|
||||
private val currencyStatusErrorConverter by lazy {
|
||||
CurrencyStatusErrorConverter(currentStateProvider)
|
||||
}
|
||||
private val loadedTokensListConverter by lazy {
|
||||
WalletLoadedTokensListConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
tokenListErrorConverter = tokenListErrorConverter,
|
||||
appCurrencyProvider = appCurrencyProvider,
|
||||
currentWalletProvider = currentWalletProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
private val loadingTransactionsStateConverter by lazy {
|
||||
WalletLoadingTxHistoryConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
currentCardTypeResolverProvider = currentCardTypeResolverProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
private val loadedTxHistoryConverter by lazy {
|
||||
WalletLoadedTxHistoryConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
currentCardTypeResolverProvider = currentCardTypeResolverProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
private val singleCurrencyLoadedBalanceConverter by lazy {
|
||||
WalletSingleCurrencyLoadedBalanceConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
appCurrencyProvider = appCurrencyProvider,
|
||||
currentWalletProvider = currentWalletProvider,
|
||||
currencyStatusErrorConverter = currencyStatusErrorConverter,
|
||||
)
|
||||
}
|
||||
|
||||
private val lockedConverter by lazy {
|
||||
WalletLockedConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
private val refreshStateConverter by lazy {
|
||||
WalletRefreshStateConverter(currentStateProvider)
|
||||
}
|
||||
|
||||
private val cryptoCurrencyActionsConverter by lazy {
|
||||
WalletCryptoCurrencyActionsConverter(
|
||||
currentWalletProvider = currentWalletProvider,
|
||||
currentStateProvider = currentStateProvider,
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
fun getInitialState(): WalletState = WalletState.Initial(onBackClick = clickIntents::onBackClick)
|
||||
|
||||
fun getSkeletonState(wallets: List<UserWallet>, selectedWalletIndex: Int): WalletState {
|
||||
return skeletonConverter.convert(
|
||||
value = WalletSkeletonStateConverter.SkeletonModel(
|
||||
wallets = wallets,
|
||||
selectedWalletIndex = selectedWalletIndex,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fun getStateWithUpdatedWalletName(name: String): WalletState = walletRenameStateConverter.convert(value = name)
|
||||
|
||||
fun getStateWithUpdatedWalletCardCount(): WalletState = walletUpdateCardCountConverter.convert(Unit)
|
||||
|
||||
fun getUnlockedState(action: WalletsUpdateActionResolver.Action.UnlockWallet): WalletState {
|
||||
return walletsUnlockStateConverter.convert(value = action)
|
||||
}
|
||||
|
||||
fun getStateWithoutDeletedWallet(
|
||||
cacheState: WalletState.ContentState,
|
||||
action: WalletsUpdateActionResolver.Action.DeleteWallet,
|
||||
): WalletState {
|
||||
return walletDeleteStateConverter.convert(
|
||||
value = WalletDeleteStateConverter.DeleteWalletModel(cacheState = cacheState, action = action),
|
||||
)
|
||||
}
|
||||
|
||||
fun getStateByTokensList(maybeTokenListWithWallet: Either<TokenListError, TokenListWithWallet>): WalletState {
|
||||
return loadedTokensListConverter.convert(maybeTokenListWithWallet)
|
||||
}
|
||||
|
||||
fun getStateByTokenListError(error: TokenListError): WalletState {
|
||||
return tokenListErrorConverter.convert(error)
|
||||
}
|
||||
|
||||
fun getStateByNotifications(notifications: ImmutableList<WalletNotification>): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletMultiCurrencyState.Content -> state.copy(notifications = notifications)
|
||||
is WalletSingleCurrencyState.Content -> state.copy(notifications = notifications)
|
||||
else -> state
|
||||
}
|
||||
}
|
||||
|
||||
fun getRefreshingState(): WalletState = refreshStateConverter.convert(value = true)
|
||||
|
||||
fun getRefreshedState(): WalletState = refreshStateConverter.convert(value = false)
|
||||
|
||||
fun getStateWithOpenWalletBottomSheet(content: TangemBottomSheetConfigContent): WalletState {
|
||||
return when (val state = currentStateProvider() as WalletState.ContentState) {
|
||||
is WalletMultiCurrencyState.Content -> state.copy(
|
||||
bottomSheetConfig = TangemBottomSheetConfig(
|
||||
isShow = true,
|
||||
onDismissRequest = clickIntents::onDismissBottomSheet,
|
||||
content = content,
|
||||
),
|
||||
)
|
||||
is WalletMultiCurrencyState.Locked -> state.copy(
|
||||
isBottomSheetShow = true,
|
||||
onBottomSheetDismiss = clickIntents::onDismissBottomSheet,
|
||||
)
|
||||
is WalletSingleCurrencyState.Content -> state.copy(
|
||||
bottomSheetConfig = TangemBottomSheetConfig(
|
||||
isShow = true,
|
||||
onDismissRequest = clickIntents::onDismissBottomSheet,
|
||||
content = content,
|
||||
),
|
||||
)
|
||||
is WalletSingleCurrencyState.Locked -> state.copy(
|
||||
isBottomSheetShow = true,
|
||||
onBottomSheetDismiss = clickIntents::onDismissBottomSheet,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun getStateWithClosedBottomSheet(): WalletState {
|
||||
return when (val state = currentStateProvider() as WalletState.ContentState) {
|
||||
is WalletMultiCurrencyState.Content -> state.copy(
|
||||
bottomSheetConfig = state.bottomSheetConfig?.copy(isShow = false),
|
||||
)
|
||||
is WalletMultiCurrencyState.Locked -> state.copy(isBottomSheetShow = false)
|
||||
is WalletSingleCurrencyState.Content -> state.copy(
|
||||
bottomSheetConfig = state.bottomSheetConfig?.copy(isShow = false),
|
||||
)
|
||||
is WalletSingleCurrencyState.Locked -> state.copy(isBottomSheetShow = false)
|
||||
}
|
||||
}
|
||||
|
||||
fun getStateWithTokenActionBottomSheet(tokenActions: TokenActionsState): WalletState {
|
||||
return getStateWithOpenWalletBottomSheet(
|
||||
content = ActionsBottomSheetConfig(actions = tokenActionsProvider.provideActions(tokenActions)),
|
||||
)
|
||||
}
|
||||
|
||||
fun getLoadingTxHistoryState(
|
||||
itemsCountEither: Either<TxHistoryStateError, Int>,
|
||||
pendingTransactions: Set<TxHistoryItem>,
|
||||
): WalletState {
|
||||
return loadingTransactionsStateConverter.convert(
|
||||
WalletLoadingTxHistoryConverter.WalletLoadingTxHistoryModel(
|
||||
historyLoadingState = itemsCountEither,
|
||||
pendingTransactions = pendingTransactions,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fun getLoadedTxHistoryState(
|
||||
txHistoryEither: Either<TxHistoryListError, Flow<PagingData<TxHistoryItem>>>,
|
||||
): WalletState {
|
||||
return loadedTxHistoryConverter.convert(txHistoryEither)
|
||||
}
|
||||
|
||||
fun getLockedState(): WalletState = lockedConverter.convert(Unit)
|
||||
|
||||
fun getSingleCurrencyLoadedBalanceState(
|
||||
maybeCryptoCurrencyStatus: Either<CurrencyStatusError, CryptoCurrencyStatus>,
|
||||
): WalletState {
|
||||
return singleCurrencyLoadedBalanceConverter.convert(maybeCryptoCurrencyStatus)
|
||||
}
|
||||
|
||||
fun getSingleCurrencyManageButtonsState(actionsState: TokenActionsState): WalletState {
|
||||
return cryptoCurrencyActionsConverter.convert(value = actionsState)
|
||||
}
|
||||
|
||||
fun getStateByCurrencyStatusError(error: CurrencyStatusError): WalletState {
|
||||
return currencyStatusErrorConverter.convert(error)
|
||||
}
|
||||
|
||||
fun getHiddenBalanceState(isBalanceHidden: Boolean): WalletState {
|
||||
return hiddenStateConverter.convert(isBalanceHidden)
|
||||
}
|
||||
|
||||
fun getStateAndTriggerEvent(
|
||||
state: WalletState,
|
||||
event: WalletEvent,
|
||||
setUiState: (WalletState) -> Unit,
|
||||
): WalletState {
|
||||
return when (state) {
|
||||
is WalletState.ContentState -> state.copySealed(
|
||||
event = triggeredEvent(
|
||||
data = event,
|
||||
onConsume = {
|
||||
val currentState = currentStateProvider()
|
||||
if (currentState is WalletState.ContentState) {
|
||||
setUiState(currentState.copySealed(event = consumedEvent()))
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
is WalletState.Initial -> state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletImageResolver
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.getCardsCount
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletsListConfig
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
internal class WalletUpdateCardCountConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val currentWalletProvider: Provider<UserWallet>,
|
||||
) : Converter<Unit, WalletState> {
|
||||
|
||||
override fun convert(value: Unit): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletState.ContentState -> {
|
||||
state.copySealed(
|
||||
walletsListConfig = state.walletsListConfig.refreshCardCount(),
|
||||
)
|
||||
}
|
||||
is WalletState.Initial -> state
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletsListConfig.refreshCardCount(): WalletsListConfig {
|
||||
val selectedWallet = currentWalletProvider()
|
||||
return copy(
|
||||
wallets = wallets
|
||||
.mapIndexed { index, walletCard ->
|
||||
if (index == selectedWalletIndex) {
|
||||
when (walletCard) {
|
||||
is WalletCardState.Content -> walletCard.copy(
|
||||
additionalInfo = WalletAdditionalInfoFactory.resolve(wallet = selectedWallet),
|
||||
imageResId = WalletImageResolver.resolve(userWallet = selectedWallet),
|
||||
cardCount = selectedWallet.getCardsCount(),
|
||||
)
|
||||
else -> walletCard
|
||||
}
|
||||
} else {
|
||||
walletCard
|
||||
}
|
||||
}
|
||||
.toImmutableList(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletImageResolver
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletsUpdateActionResolver.Action.UnlockWallet as UnlockWalletAction
|
||||
|
||||
/**
|
||||
* Converter that responds on wallets unlocking action. Returns [WalletState] with unlocked wallets.
|
||||
*
|
||||
* @property currentStateProvider current ui state provider
|
||||
* @property clickIntents screen click intents
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class WalletsUnlockStateConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<UnlockWalletAction, WalletState> {
|
||||
|
||||
override fun convert(value: UnlockWalletAction): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletMultiCurrencyState.Locked -> state.toMultiCurrencyContentState(value)
|
||||
is WalletSingleCurrencyState.Locked -> state.toSingleCurrencyContentState(value)
|
||||
is WalletState.Initial,
|
||||
is WalletMultiCurrencyState.Content,
|
||||
is WalletSingleCurrencyState.Content,
|
||||
-> state
|
||||
}
|
||||
}
|
||||
|
||||
private fun WalletMultiCurrencyState.Locked.toMultiCurrencyContentState(action: UnlockWalletAction): WalletState {
|
||||
return WalletMultiCurrencyState.Content(
|
||||
onBackClick = onBackClick,
|
||||
topBarConfig = topBarConfig.updateCallback(),
|
||||
walletsListConfig = walletsListConfig.unlockWallets(action),
|
||||
pullToRefreshConfig = pullToRefreshConfig.stopRefreshing(),
|
||||
tokensListState = WalletTokensListState.Loading(),
|
||||
notifications = persistentListOf(),
|
||||
bottomSheetConfig = null,
|
||||
onManageTokensClick = clickIntents::onManageTokensClick,
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletSingleCurrencyState.Locked.toSingleCurrencyContentState(action: UnlockWalletAction): WalletState {
|
||||
return WalletSingleCurrencyState.Content(
|
||||
onBackClick = onBackClick,
|
||||
topBarConfig = topBarConfig.updateCallback(),
|
||||
walletsListConfig = walletsListConfig.unlockWallets(action),
|
||||
pullToRefreshConfig = pullToRefreshConfig.stopRefreshing(),
|
||||
notifications = persistentListOf(),
|
||||
bottomSheetConfig = null,
|
||||
buttons = buttons,
|
||||
marketPriceBlockState = MarketPriceBlockState.Loading(
|
||||
currencySymbol = action.selectedWallet.getPrimaryCurrencyName(),
|
||||
),
|
||||
txHistoryState = TxHistoryState.Content(
|
||||
contentItems = MutableStateFlow(
|
||||
value = TxHistoryState.getDefaultLoadingTransactions(clickIntents::onExploreClick),
|
||||
),
|
||||
),
|
||||
isBalanceHidden = isBalanceHidden,
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletTopBarConfig.updateCallback(): WalletTopBarConfig {
|
||||
return copy(onDetailsClick = clickIntents::onDetailsClick)
|
||||
}
|
||||
|
||||
private fun WalletsListConfig.unlockWallets(action: UnlockWalletAction): WalletsListConfig {
|
||||
return this.copy(
|
||||
selectedWalletIndex = action.selectedWalletIndex,
|
||||
wallets = wallets.unlockWallets(action),
|
||||
)
|
||||
}
|
||||
|
||||
private fun List<WalletCardState>.unlockWallets(action: UnlockWalletAction): ImmutableList<WalletCardState> {
|
||||
return this
|
||||
.map { prevWallet ->
|
||||
if (prevWallet is WalletCardState.LockedContent && action.isUnlockedWallet(prevWallet.id)) {
|
||||
prevWallet.mapToLoadingWalletCardState(
|
||||
userWallet = action.getUnlockWallet(prevWallet.id),
|
||||
)
|
||||
} else {
|
||||
prevWallet
|
||||
}
|
||||
}
|
||||
.toImmutableList()
|
||||
}
|
||||
|
||||
private fun UnlockWalletAction.isUnlockedWallet(walletId: UserWalletId): Boolean {
|
||||
return unlockedWallets.any { it.walletId == walletId }
|
||||
}
|
||||
|
||||
private fun UnlockWalletAction.getUnlockWallet(walletId: UserWalletId): UserWallet {
|
||||
return unlockedWallets.firstOrNull { it.walletId == walletId }
|
||||
?: error("Unlocked wallet with id $walletId not found")
|
||||
}
|
||||
|
||||
private fun WalletCardState.mapToLoadingWalletCardState(userWallet: UserWallet): WalletCardState {
|
||||
return WalletCardState.Loading(
|
||||
id = id,
|
||||
title = title,
|
||||
imageResId = WalletImageResolver.resolve(userWallet = userWallet),
|
||||
onRenameClick = onRenameClick,
|
||||
onDeleteClick = onDeleteClick,
|
||||
)
|
||||
}
|
||||
|
||||
private fun WalletPullToRefreshConfig.stopRefreshing(): WalletPullToRefreshConfig {
|
||||
return copy(isRefreshing = false)
|
||||
}
|
||||
|
||||
private fun UserWallet.getPrimaryCurrencyName(): String {
|
||||
return scanResponse.cardTypesResolver.getBlockchain().currency
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import arrow.core.Either
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.domain.common.CardTypesResolver
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.domain.txhistory.models.TxHistoryListError
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/**
|
||||
* Converter from loaded tx history to [TxHistoryState]
|
||||
*
|
||||
* @property currentStateProvider current state provider
|
||||
* @property currentCardTypeResolverProvider current card type resolver provider
|
||||
* @property clickIntents screen click intents
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class WalletLoadedTxHistoryConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val currentCardTypeResolverProvider: Provider<CardTypesResolver>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<Either<TxHistoryListError, Flow<PagingData<TxHistoryItem>>>, WalletState> {
|
||||
|
||||
private val walletTxHistoryItemFlowConverter by lazy {
|
||||
WalletTxHistoryItemFlowConverter(
|
||||
currentStateProvider = currentStateProvider,
|
||||
blockchain = currentCardTypeResolverProvider().getBlockchain(),
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
override fun convert(value: Either<TxHistoryListError, Flow<PagingData<TxHistoryItem>>>): WalletState {
|
||||
return value.fold(ifLeft = ::convertError, ifRight = ::convert)
|
||||
}
|
||||
|
||||
private fun convertError(error: TxHistoryListError): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletSingleCurrencyState.Content -> {
|
||||
state.copy(
|
||||
txHistoryState = when (error) {
|
||||
is TxHistoryListError.DataError -> {
|
||||
TxHistoryState.Error(
|
||||
onReloadClick = clickIntents::onReloadClick,
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
is WalletMultiCurrencyState.Content,
|
||||
is WalletMultiCurrencyState.Locked,
|
||||
is WalletSingleCurrencyState.Locked,
|
||||
is WalletState.Initial,
|
||||
-> state
|
||||
}
|
||||
}
|
||||
|
||||
private fun convert(items: Flow<PagingData<TxHistoryItem>>): WalletState {
|
||||
return when (val state = currentStateProvider()) {
|
||||
is WalletSingleCurrencyState.Content -> {
|
||||
return state.copy(
|
||||
txHistoryState = walletTxHistoryItemFlowConverter.convert(value = items) ?: state.txHistoryState,
|
||||
)
|
||||
}
|
||||
is WalletMultiCurrencyState.Content,
|
||||
is WalletMultiCurrencyState.Locked,
|
||||
is WalletSingleCurrencyState.Locked,
|
||||
is WalletState.Initial,
|
||||
-> state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import arrow.core.Either
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState.*
|
||||
import com.tangem.domain.common.CardTypesResolver
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.domain.txhistory.models.TxHistoryStateError
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
|
||||
/**
|
||||
* Converter from loading tx history state to [WalletSingleCurrencyState.Content]
|
||||
*
|
||||
* @property currentStateProvider current state provider
|
||||
* @property clickIntents screen click intents
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class WalletLoadingTxHistoryConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val currentCardTypeResolverProvider: Provider<CardTypesResolver>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<WalletLoadingTxHistoryConverter.WalletLoadingTxHistoryModel, WalletState> {
|
||||
|
||||
private val txHistoryItemConverter by lazy {
|
||||
val blockchain = currentCardTypeResolverProvider().getBlockchain()
|
||||
WalletTxHistoryTransactionStateConverter(
|
||||
symbol = blockchain.currency,
|
||||
decimals = blockchain.decimals(),
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
override fun convert(value: WalletLoadingTxHistoryModel): WalletState {
|
||||
return value.historyLoadingState.fold(
|
||||
ifLeft = { convertError(it, value.pendingTransactions) },
|
||||
ifRight = ::convertRight,
|
||||
)
|
||||
}
|
||||
|
||||
private fun convertError(error: TxHistoryStateError, pendingTransactions: Set<TxHistoryItem>): WalletState {
|
||||
val state = currentStateProvider()
|
||||
|
||||
return if (state is WalletSingleCurrencyState.Content) {
|
||||
state.copy(
|
||||
txHistoryState = when (error) {
|
||||
is TxHistoryStateError.EmptyTxHistories -> Empty(onExploreClick = clickIntents::onExploreClick)
|
||||
is TxHistoryStateError.DataError -> Error(
|
||||
onReloadClick = clickIntents::onReloadClick,
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
)
|
||||
is TxHistoryStateError.TxHistoryNotImplemented -> {
|
||||
NotSupported(
|
||||
pendingTransactions = txHistoryItemConverter.convertList(pendingTransactions)
|
||||
.toImmutableList(),
|
||||
onExploreClick = clickIntents::onExploreClick,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
} else {
|
||||
state
|
||||
}
|
||||
}
|
||||
|
||||
private fun convertRight(value: Int): WalletState {
|
||||
val state = currentStateProvider()
|
||||
val singleCurrencyContentState = state as? WalletSingleCurrencyState.Content ?: return state
|
||||
return if (singleCurrencyContentState.txHistoryState is Content) {
|
||||
singleCurrencyContentState.txHistoryState.contentItems.update {
|
||||
PagingData.from(data = createLoadingItems(value))
|
||||
}
|
||||
state
|
||||
} else {
|
||||
val txHistoryContent = Content(
|
||||
contentItems = MutableStateFlow(
|
||||
value = PagingData.from(data = createLoadingItems(value)),
|
||||
),
|
||||
)
|
||||
state.copy(txHistoryState = txHistoryContent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createLoadingItems(size: Int): List<TxHistoryItemState> {
|
||||
return buildList {
|
||||
add(TxHistoryItemState.Title(onExploreClick = clickIntents::onExploreClick))
|
||||
(1..size).forEach {
|
||||
add(TxHistoryItemState.Transaction(state = TransactionState.Loading(it.toString())))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class WalletLoadingTxHistoryModel(
|
||||
val historyLoadingState: Either<TxHistoryStateError, Int>,
|
||||
val pendingTransactions: Set<TxHistoryItem>,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory
|
||||
|
||||
import android.text.format.DateUtils
|
||||
import androidx.paging.*
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState.TxHistoryItemState
|
||||
import com.tangem.core.ui.utils.DateTimeFormatters
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.extensions.isToday
|
||||
import com.tangem.utils.extensions.isYesterday
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* Convert from [Flow] of [TxHistoryItem] to [TxHistoryState]
|
||||
*
|
||||
* @property currentStateProvider current state provider
|
||||
* @property blockchain blockchain of transactions history
|
||||
* @property clickIntents screen click intents
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class WalletTxHistoryItemFlowConverter(
|
||||
private val currentStateProvider: Provider<WalletState>,
|
||||
private val blockchain: Blockchain,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<Flow<PagingData<TxHistoryItem>>, TxHistoryState?> {
|
||||
|
||||
private val txHistoryItemConverter by lazy {
|
||||
WalletTxHistoryTransactionStateConverter(
|
||||
symbol = blockchain.currency,
|
||||
decimals = blockchain.decimals(),
|
||||
clickIntents = clickIntents,
|
||||
)
|
||||
}
|
||||
|
||||
override fun convert(value: Flow<PagingData<TxHistoryItem>>): TxHistoryState? {
|
||||
val state = currentStateProvider() as? WalletSingleCurrencyState ?: return null
|
||||
val txHistoryContent = state.txHistoryState as? TxHistoryState.Content
|
||||
?: TxHistoryState.Content(contentItems = MutableStateFlow(PagingData.empty()))
|
||||
|
||||
// FIXME: TxHistoryRepository should send loading transactions
|
||||
// [REDACTED_JIRA]
|
||||
value
|
||||
.onEach { txHistoryStatePagingData ->
|
||||
txHistoryContent.contentItems.update {
|
||||
txHistoryStatePagingData
|
||||
.map<TxHistoryItem, TxHistoryItemState> { item ->
|
||||
// [createTransactionState] returns timestamp without formatting
|
||||
TxHistoryItemState.Transaction(state = createTransactionState(item))
|
||||
}
|
||||
.insertHeaderItem(
|
||||
terminalSeparatorType = TerminalSeparatorType.SOURCE_COMPLETE,
|
||||
item = TxHistoryItemState.Title(clickIntents::onExploreClick),
|
||||
)
|
||||
.insertGroupTitle()
|
||||
}
|
||||
}
|
||||
.launchIn(CoroutineScope(Dispatchers.IO))
|
||||
|
||||
return txHistoryContent
|
||||
}
|
||||
|
||||
private fun createTransactionState(item: TxHistoryItem): TransactionState {
|
||||
return txHistoryItemConverter.convert(value = item)
|
||||
}
|
||||
|
||||
private fun PagingData<TxHistoryItemState>.insertGroupTitle(): PagingData<TxHistoryItemState> {
|
||||
return insertSeparators(terminalSeparatorType = TerminalSeparatorType.SOURCE_COMPLETE) { before, after ->
|
||||
// Use raw timestamp to get date
|
||||
|
||||
// If [afterDate] is the first transaction in the flow, add the group title
|
||||
val afterDate = after.getTimestamp()?.toDateFormat() ?: return@insertSeparators null
|
||||
if (before is TxHistoryItemState.Title) {
|
||||
return@insertSeparators TxHistoryItemState.GroupTitle(
|
||||
title = afterDate,
|
||||
itemKey = UUID.randomUUID().toString(),
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
* If [beforeDate] is not equals to [afterDate], then [afterDate] is first transaction in
|
||||
* the new group
|
||||
*/
|
||||
val beforeDate = before.getTimestamp()?.toDateFormat() ?: return@insertSeparators null
|
||||
return@insertSeparators if (beforeDate != afterDate) {
|
||||
TxHistoryItemState.GroupTitle(title = afterDate, itemKey = UUID.randomUUID().toString())
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun TxHistoryItemState?.getTimestamp(): Long? {
|
||||
return if (this is TxHistoryItemState.Transaction && this.state is TransactionState.Content) {
|
||||
val txContent = this.state as TransactionState.Content
|
||||
txContent.timestamp
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If [this] timestamp is today or yesterday, returns relative date,
|
||||
* otherwise returns formatting date.
|
||||
*/
|
||||
private fun Long.toDateFormat(): String {
|
||||
val localDate = DateTime(this, DateTimeZone.getDefault())
|
||||
return if (localDate.isToday() || localDate.isYesterday()) {
|
||||
DateUtils.getRelativeTimeSpanString(
|
||||
this,
|
||||
DateTime.now().millis,
|
||||
DateUtils.DAY_IN_MILLIS,
|
||||
DateUtils.FORMAT_ABBREV_RELATIVE,
|
||||
).toString()
|
||||
} else {
|
||||
DateTimeFormatters.formatDate(date = localDate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory
|
||||
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.utils.toTimeFormat
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.toBriefAddressFormat
|
||||
import com.tangem.utils.toFormattedCurrencyString
|
||||
|
||||
internal class WalletTxHistoryTransactionStateConverter(
|
||||
private val symbol: String,
|
||||
private val decimals: Int,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<TxHistoryItem, TransactionState> {
|
||||
|
||||
override fun convert(value: TxHistoryItem): TransactionState {
|
||||
return createTransactionStateItem(item = value)
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
private fun createTransactionStateItem(item: TxHistoryItem): TransactionState {
|
||||
return TransactionState.Content(
|
||||
txHash = item.txHash,
|
||||
amount = item.getAmount(),
|
||||
time = item.timestampInMillis.toTimeFormat(),
|
||||
status = item.status.tiUiStatus(),
|
||||
direction = item.extractDirection(),
|
||||
iconRes = item.extractIcon(),
|
||||
title = item.extractTitle(),
|
||||
subtitle = item.extractSubtitle(),
|
||||
timestamp = item.timestampInMillis,
|
||||
onClick = { clickIntents.onTransactionClick(item.txHash) },
|
||||
)
|
||||
}
|
||||
|
||||
private fun TxHistoryItem.extractIcon(): Int = if (status == TxHistoryItem.TransactionStatus.Failed) {
|
||||
R.drawable.ic_close_24
|
||||
} else {
|
||||
when (type) {
|
||||
is TxHistoryItem.TransactionType.Approve -> R.drawable.ic_doc_24
|
||||
is TxHistoryItem.TransactionType.Operation,
|
||||
is TxHistoryItem.TransactionType.Swap,
|
||||
is TxHistoryItem.TransactionType.Transfer,
|
||||
is TxHistoryItem.TransactionType.UnknownOperation,
|
||||
-> if (isOutgoing) R.drawable.ic_arrow_up_24 else R.drawable.ic_arrow_down_24
|
||||
}
|
||||
}
|
||||
|
||||
private fun TxHistoryItem.extractTitle(): TextReference = when (val type = type) {
|
||||
is TxHistoryItem.TransactionType.Approve -> resourceReference(R.string.common_approval)
|
||||
is TxHistoryItem.TransactionType.Operation -> stringReference(type.name)
|
||||
is TxHistoryItem.TransactionType.Swap -> resourceReference(R.string.common_swap)
|
||||
is TxHistoryItem.TransactionType.Transfer -> resourceReference(R.string.common_transfer)
|
||||
is TxHistoryItem.TransactionType.UnknownOperation -> resourceReference(R.string.transaction_history_operation)
|
||||
}
|
||||
|
||||
private fun TxHistoryItem.extractSubtitle(): TextReference =
|
||||
when (val interactionAddress = interactionAddressType) {
|
||||
is TxHistoryItem.InteractionAddressType.Contract -> resourceReference(
|
||||
id = R.string.transaction_history_contract_address,
|
||||
formatArgs = wrappedList(interactionAddress.address.toBriefAddressFormat()),
|
||||
)
|
||||
is TxHistoryItem.InteractionAddressType.Multiple -> resourceReference(
|
||||
id = if (isOutgoing) {
|
||||
R.string.transaction_history_transaction_to_address
|
||||
} else {
|
||||
R.string.transaction_history_transaction_from_address
|
||||
},
|
||||
formatArgs = wrappedList(resourceReference(R.string.transaction_history_multiple_addresses)),
|
||||
)
|
||||
is TxHistoryItem.InteractionAddressType.User -> resourceReference(
|
||||
id = if (isOutgoing) {
|
||||
R.string.transaction_history_transaction_to_address
|
||||
} else {
|
||||
R.string.transaction_history_transaction_from_address
|
||||
},
|
||||
formatArgs = wrappedList(interactionAddress.address.toBriefAddressFormat()),
|
||||
)
|
||||
}
|
||||
|
||||
private fun TxHistoryItem.extractDirection() =
|
||||
if (isOutgoing) TransactionState.Content.Direction.OUTGOING else TransactionState.Content.Direction.INCOMING
|
||||
|
||||
private fun TxHistoryItem.TransactionStatus.tiUiStatus() = when (this) {
|
||||
TxHistoryItem.TransactionStatus.Confirmed -> TransactionState.Content.Status.Confirmed
|
||||
TxHistoryItem.TransactionStatus.Failed -> TransactionState.Content.Status.Failed
|
||||
TxHistoryItem.TransactionStatus.Unconfirmed -> TransactionState.Content.Status.Unconfirmed
|
||||
}
|
||||
|
||||
private fun TxHistoryItem.getAmount(): String {
|
||||
val prefix = when (status) {
|
||||
TxHistoryItem.TransactionStatus.Failed -> ""
|
||||
else -> if (isOutgoing) "-" else "+"
|
||||
}
|
||||
return prefix + amount.toFormattedCurrencyString(currency = symbol, decimals = decimals)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
internal data class DepositButtonState(
|
||||
val isEnabled: Boolean,
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
internal data class ManageTokensButtonConfig(val onClick: () -> Unit)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
/**
|
||||
* Wallet screen top bar config
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import com.tangem.core.ui.event.StateEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTopBarConfig
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
internal data class WalletScreenState(
|
||||
|
|
@ -1,17 +1,13 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletPullToRefreshConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.holder.LockedTxHistoryStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.holder.LockedWalletStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.holder.TxHistoryStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.holder.WalletStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.holder.LockedTxHistoryStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.holder.LockedWalletStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.holder.TxHistoryStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.holder.WalletStateHolder
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.components
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
/**
|
||||
* Wallet screen top bar config
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model.holder
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model.holder
|
||||
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletBottomSheetConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletPullToRefreshConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletBottomSheetConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletPullToRefreshConfig
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.model.holder
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.model.holder
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.utils.WalletLoadingStateFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletLoadingStateFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
internal class AddWalletTransformer(
|
||||
private val userWallet: UserWallet,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
|
||||
internal class CloseBottomSheetTransformer(userWalletId: UserWalletId) : WalletStateTransformer(userWalletId) {
|
||||
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
@ -1,16 +1,12 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletImageResolver
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTopBarConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.utils.WalletLoadingStateFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.utils.createStateByWalletType
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.*
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletLoadingStateFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.utils.createStateByWalletType
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
|
@ -19,7 +15,7 @@ internal class InitializeWalletsTransformer(
|
|||
private val selectedWalletIndex: Int,
|
||||
private val selectedWallet: UserWallet,
|
||||
private val wallets: List<UserWallet>,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy { WalletLoadingStateFactory(clickIntents = clickIntents) }
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
|
||||
internal class OpenBottomSheetTransformer(
|
||||
userWalletId: UserWalletId,
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.utils.WalletLoadingStateFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletLoadingStateFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
/**
|
||||
|
|
@ -11,7 +11,7 @@ import kotlinx.collections.immutable.persistentListOf
|
|||
*/
|
||||
internal class ReinitializeWalletTransformer(
|
||||
private val userWallet: UserWallet,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy { WalletLoadingStateFactory(clickIntents = clickIntents) }
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import timber.log.Timber
|
||||
|
||||
internal class RenameWalletTransformer(
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.core.ui.event.triggeredEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
import com.tangem.utils.Provider
|
||||
|
||||
internal class ScrollToWalletTransformer(
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.core.ui.event.triggeredEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
|
||||
internal class SendEventTransformer(
|
||||
private val event: WalletEvent,
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import arrow.core.Either
|
||||
import arrow.core.getOrElse
|
||||
|
|
@ -7,18 +7,18 @@ import com.tangem.core.ui.utils.BigDecimalFormatter
|
|||
import com.tangem.domain.visa.model.VisaCurrency
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.getCardsCount
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletAdditionalInfo
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.BalancesAndLimitsBlockState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.BalancesAndLimitsBlockState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletAdditionalInfo
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.Days
|
||||
|
||||
internal class SetBalancesAndLimitsTransformer(
|
||||
private val userWallet: UserWallet,
|
||||
private val maybeVisaCurrency: Either<Throwable, VisaCurrency>,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletStateTransformer(userWallet.walletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.tokens.model.TokenActionsState
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletManageButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import timber.log.Timber
|
||||
|
|
@ -13,7 +13,7 @@ import timber.log.Timber
|
|||
internal class SetCryptoCurrencyActionsTransformer(
|
||||
private val tokenActionsState: TokenActionsState,
|
||||
private val userWallet: UserWallet,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletStateTransformer(userWallet.walletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter.SingleWalletCardStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter.SingleWalletMarketPriceConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.converter.SingleWalletCardStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.converter.SingleWalletMarketPriceConverter
|
||||
import timber.log.Timber
|
||||
|
||||
internal class SetPrimaryCurrencyTransformer(
|
||||
|
|
@ -1,12 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletManageButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletPullToRefreshConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.BalancesAndLimitsBlockState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.DepositButtonState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.*
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.mutate
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.tokens.error.TokenListError
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListState
|
||||
import timber.log.Timber
|
||||
|
||||
internal class SetTokenListErrorTransformer(
|
||||
|
|
@ -1,23 +1,23 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.ManageTokensButtonConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter.MultiWalletCardStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter.TokenListStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.ManageTokensButtonConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.converter.MultiWalletCardStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.converter.TokenListStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import timber.log.Timber
|
||||
|
||||
internal class SetTokenListTransformer(
|
||||
private val tokenList: TokenList,
|
||||
private val userWallet: UserWallet,
|
||||
private val appCurrency: AppCurrency,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletStateTransformer(userWallet.walletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.domain.txhistory.models.TxHistoryStateError
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter.TxHistoryItemStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.converter.TxHistoryItemStateConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ internal class SetTxHistoryCountErrorTransformer(
|
|||
private val userWallet: UserWallet,
|
||||
private val error: TxHistoryStateError,
|
||||
private val pendingTransactions: Set<TxHistoryItem>,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletStateTransformer(userWallet.walletId) {
|
||||
|
||||
private val txHistoryItemConverter by lazy {
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import timber.log.Timber
|
||||
|
|
@ -13,7 +13,7 @@ import timber.log.Timber
|
|||
internal class SetTxHistoryCountTransformer(
|
||||
userWalletId: UserWalletId,
|
||||
private val transactionsCount: Int,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletStateTransformer(userWalletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.domain.txhistory.models.TxHistoryListError
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import timber.log.Timber
|
||||
|
||||
internal class SetTxHistoryItemsErrorTransformer(
|
||||
userWalletId: UserWalletId,
|
||||
private val error: TxHistoryListError,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletStateTransformer(userWalletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter.TxHistoryItemFlowConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.converter.TxHistoryItemFlowConverter
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import timber.log.Timber
|
||||
|
||||
internal class SetTxHistoryItemsTransformer(
|
||||
userWallet: UserWallet,
|
||||
private val flow: Flow<PagingData<TransactionState>>,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletStateTransformer(userWallet.walletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTopBarConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.utils.WalletLoadingStateFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTopBarConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletLoadingStateFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import timber.log.Timber
|
||||
|
||||
internal class UnlockWalletTransformer(
|
||||
private val unlockedWallets: List<UserWallet>,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy { WalletLoadingStateFactory(clickIntents = clickIntents) }
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
|
||||
internal class UpdateBalanceHidingModeTransformer(
|
||||
private val isHidingMode: Boolean,
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletImageResolver
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.getCardsCount
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import timber.log.Timber
|
||||
|
||||
internal class UpdateWalletCardsCountTransformer(
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
|
||||
internal interface WalletScreenStateTransformer {
|
||||
|
||||
fun transform(prevState: WalletScreenState): WalletScreenState
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletScreenState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.core.ui.utils.DateTimeFormatters
|
||||
import com.tangem.domain.visa.model.VisaCurrency
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletAlertState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.BalancesAndLimitsBottomSheetConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.utils.WalletEventSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.BalancesAndLimitsBottomSheetConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletAlertState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletEventSender
|
||||
import com.tangem.utils.converter.Converter
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
|
|
@ -6,7 +6,7 @@ import com.tangem.domain.tokens.model.TokenList
|
|||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.getCardsCount
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletCardState
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
internal class MultiWalletCardStateConverter(
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
|
|
@ -7,7 +7,7 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
|||
import com.tangem.domain.tokens.model.TokenActionsState
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.TokenActionButtonConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.TokenActionButtonConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletCurrencyActionsClickIntentsImplementor
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.isNullOrZero
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
|
|
@ -6,7 +6,7 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
|||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.getCardsCount
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletCardState
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
internal class SingleWalletCardStateConverter(
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeState
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import com.tangem.core.ui.components.currency.tokenicon.converter.CryptoCurrencyToIconStateConverter
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeType
|
||||
|
|
@ -6,14 +6,14 @@ import com.tangem.core.ui.utils.BigDecimalFormatter
|
|||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenItemState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import java.math.BigDecimal
|
||||
|
||||
internal class TokenItemStateConverter(
|
||||
private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<CryptoCurrencyStatus, TokenItemState> {
|
||||
|
||||
private val iconStateConverter by lazy(::CryptoCurrencyToIconStateConverter)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
|
|
@ -7,21 +7,21 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
|||
import com.tangem.domain.tokens.model.NetworkGroup
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletTokensListState.TokensListItemState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListState.TokensListItemState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.mutate
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.model.WalletTokensListState.OrganizeTokensButtonConfig as WalletOrganizeTokensButtonConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListState.OrganizeTokensButtonConfig as WalletOrganizeTokensButtonConfig
|
||||
|
||||
internal class TokenListStateConverter(
|
||||
private val tokenList: TokenList,
|
||||
private val selectedWallet: UserWallet,
|
||||
private val appCurrency: AppCurrency,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<WalletTokensListState, WalletTokensListState> {
|
||||
|
||||
private val tokenStatusConverter = TokenItemStateConverter(
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import androidx.paging.*
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState.TxHistoryItemState
|
||||
import com.tangem.core.ui.utils.toDateFormat
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import com.tangem.utils.converter.Converter
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -16,7 +16,7 @@ private val scope = CoroutineScope(Dispatchers.IO)
|
|||
|
||||
internal class TxHistoryItemFlowConverter(
|
||||
private val currentState: TxHistoryState,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<Flow<PagingData<TransactionState>>, TxHistoryState?> {
|
||||
|
||||
override fun convert(value: Flow<PagingData<TransactionState>>): TxHistoryState {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter
|
||||
package com.tangem.feature.wallet.presentation.wallet.state.transformers.converter
|
||||
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -8,7 +8,7 @@ import com.tangem.core.ui.extensions.wrappedList
|
|||
import com.tangem.core.ui.utils.toTimeFormat
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.toBriefAddressFormat
|
||||
import com.tangem.utils.toFormattedCurrencyString
|
||||
|
|
@ -16,7 +16,7 @@ import com.tangem.utils.toFormattedCurrencyString
|
|||
internal class TxHistoryItemStateConverter(
|
||||
private val symbol: String,
|
||||
private val decimals: Int,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
) : Converter<TxHistoryItem, TransactionState> {
|
||||
|
||||
override fun convert(value: TxHistoryItem): TransactionState {
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue