Updated on 2026-08-14
This commit is contained in:
parent
c6800df974
commit
d463e03d7d
7 changed files with 40 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletImageResolver
|
||||
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
|
||||
|
|
@ -9,10 +10,14 @@ import kotlinx.collections.immutable.toImmutableList
|
|||
internal class AddWalletTransformer(
|
||||
private val userWallet: UserWallet,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy {
|
||||
WalletLoadingStateFactory(clickIntents = clickIntents)
|
||||
WalletLoadingStateFactory(
|
||||
clickIntents = clickIntents,
|
||||
walletImageResolver = walletImageResolver,
|
||||
)
|
||||
}
|
||||
|
||||
override fun transform(prevState: WalletScreenState): WalletScreenState {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,12 @@ internal class InitializeWalletsTransformer(
|
|||
private val selectedWalletIndex: Int,
|
||||
private val wallets: List<UserWallet>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy { WalletLoadingStateFactory(clickIntents = clickIntents) }
|
||||
private val walletLoadingStateFactory by lazy {
|
||||
WalletLoadingStateFactory(clickIntents = clickIntents, walletImageResolver = walletImageResolver)
|
||||
}
|
||||
|
||||
override fun transform(prevState: WalletScreenState): WalletScreenState {
|
||||
return prevState.copy(
|
||||
|
|
@ -78,7 +81,7 @@ internal class InitializeWalletsTransformer(
|
|||
id = walletId,
|
||||
title = name,
|
||||
additionalInfo = WalletAdditionalInfoFactory.resolve(wallet = this),
|
||||
imageResId = WalletImageResolver.resolve(userWallet = this),
|
||||
imageResId = walletImageResolver.resolve(userWallet = this),
|
||||
onRenameClick = clickIntents::onRenameBeforeConfirmationClick,
|
||||
onDeleteClick = clickIntents::onDeleteBeforeConfirmationClick,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ 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.domain.WalletImageResolver
|
||||
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
|
||||
|
|
@ -20,9 +21,12 @@ internal class ReinitializeWalletTransformer(
|
|||
private val prevWalletId: UserWalletId,
|
||||
private val newUserWallet: UserWallet,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy { WalletLoadingStateFactory(clickIntents = clickIntents) }
|
||||
private val walletLoadingStateFactory by lazy {
|
||||
WalletLoadingStateFactory(clickIntents = clickIntents, walletImageResolver = walletImageResolver)
|
||||
}
|
||||
|
||||
override fun transform(prevState: WalletScreenState): WalletScreenState {
|
||||
return prevState.copy(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ 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.domain.WalletImageResolver
|
||||
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.utils.WalletLoadingStateFactory
|
||||
|
|
@ -12,9 +13,12 @@ import timber.log.Timber
|
|||
internal class UnlockWalletTransformer(
|
||||
private val unlockedWallets: List<UserWallet>,
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy { WalletLoadingStateFactory(clickIntents = clickIntents) }
|
||||
private val walletLoadingStateFactory by lazy {
|
||||
WalletLoadingStateFactory(clickIntents = clickIntents, walletImageResolver = walletImageResolver)
|
||||
}
|
||||
|
||||
override fun transform(prevState: WalletScreenState): WalletScreenState {
|
||||
return prevState.copy(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import timber.log.Timber
|
|||
|
||||
internal class UpdateWalletCardsCountTransformer(
|
||||
private val userWallet: UserWallet,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
) : WalletStateTransformer(userWallet.walletId) {
|
||||
|
||||
override fun transform(prevState: WalletState): WalletState {
|
||||
|
|
@ -37,7 +38,7 @@ internal class UpdateWalletCardsCountTransformer(
|
|||
return when (this) {
|
||||
is WalletCardState.Content -> copy(
|
||||
additionalInfo = WalletAdditionalInfoFactory.resolve(wallet = userWallet),
|
||||
imageResId = WalletImageResolver.resolve(userWallet = userWallet),
|
||||
imageResId = walletImageResolver.resolve(userWallet = userWallet),
|
||||
cardCount = userWallet.getCardsCount(),
|
||||
)
|
||||
else -> this
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
*
|
||||
* @property clickIntents click intents
|
||||
*/
|
||||
internal class WalletLoadingStateFactory(private val clickIntents: WalletClickIntents) {
|
||||
internal class WalletLoadingStateFactory(
|
||||
private val clickIntents: WalletClickIntents,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
) {
|
||||
|
||||
fun create(userWallet: UserWallet): WalletState {
|
||||
return userWallet.createStateByWalletType(
|
||||
|
|
@ -81,7 +84,7 @@ internal class WalletLoadingStateFactory(private val clickIntents: WalletClickIn
|
|||
id = walletId,
|
||||
title = name,
|
||||
additionalInfo = if (isMultiCurrency) WalletAdditionalInfoFactory.resolve(wallet = this) else null,
|
||||
imageResId = WalletImageResolver.resolve(userWallet = this),
|
||||
imageResId = walletImageResolver.resolve(userWallet = this),
|
||||
onRenameClick = clickIntents::onRenameBeforeConfirmationClick,
|
||||
onDeleteClick = clickIntents::onDeleteBeforeConfirmationClick,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import com.tangem.feature.wallet.presentation.deeplink.WalletDeepLinksHandler
|
|||
import com.tangem.feature.wallet.presentation.router.InnerWalletRouter
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.SelectedWalletAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletImageResolver
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletNameMigrationUseCase
|
||||
import com.tangem.feature.wallet.presentation.wallet.loaders.WalletScreenContentLoader
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
|
|
@ -69,6 +70,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
private val shouldAskPermissionUseCase: ShouldAskPermissionUseCase,
|
||||
private val pushNotificationsFeatureToggles: PushNotificationsFeatureToggles,
|
||||
private val marketsFeatureToggles: MarketsFeatureToggles,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
analyticsEventsHandler: AnalyticsEventHandler,
|
||||
) : ViewModel() {
|
||||
|
||||
|
|
@ -270,7 +272,12 @@ internal class WalletViewModel @Inject constructor(
|
|||
coroutineScope = viewModelScope,
|
||||
)
|
||||
|
||||
stateHolder.update(transformer = UpdateWalletCardsCountTransformer(action.selectedWallet))
|
||||
stateHolder.update(
|
||||
transformer = UpdateWalletCardsCountTransformer(
|
||||
userWallet = action.selectedWallet,
|
||||
walletImageResolver = walletImageResolver,
|
||||
),
|
||||
)
|
||||
}
|
||||
is WalletsUpdateActionResolver.Action.UpdateWalletName -> {
|
||||
stateHolder.update(transformer = RenameWalletTransformer(action.selectedWalletId, action.name))
|
||||
|
|
@ -293,6 +300,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
selectedWalletIndex = action.selectedWalletIndex,
|
||||
wallets = action.wallets,
|
||||
clickIntents = clickIntents,
|
||||
walletImageResolver = walletImageResolver,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -325,6 +333,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
prevWalletId = action.prevWalletId,
|
||||
newUserWallet = action.selectedWallet,
|
||||
clickIntents = clickIntents,
|
||||
walletImageResolver = walletImageResolver,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -340,6 +349,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
AddWalletTransformer(
|
||||
userWallet = action.selectedWallet,
|
||||
clickIntents = clickIntents,
|
||||
walletImageResolver = walletImageResolver,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -389,6 +399,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
transformer = UnlockWalletTransformer(
|
||||
unlockedWallets = action.unlockedWallets,
|
||||
clickIntents = clickIntents,
|
||||
walletImageResolver = walletImageResolver,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue