From a73dfc58afe9a096910ef5bd34816b36a655b2c4 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 26 May 2026 20:09:06 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../utils/WalletWarningsAnalyticsSender.kt | 1 + .../domain/GetMultiWalletWarningsFactory.kt | 43 ++++++++++++++++--- .../domain/GetWalletNotificationsFactory.kt | 16 ++++--- .../wallet/state/model/WalletNotification.kt | 15 +++++++ 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletWarningsAnalyticsSender.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletWarningsAnalyticsSender.kt index e72fb5180b..ad44ae8b6b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletWarningsAnalyticsSender.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletWarningsAnalyticsSender.kt @@ -95,6 +95,7 @@ internal class WalletWarningsAnalyticsSender @Inject constructor( ) } is WalletNotification.PushNotifications -> PushBanner() + is WalletNotification.AddFunds -> NoticeAddFunds() is WalletNotification.Warning.TangemPayRefreshNeeded -> null is WalletNotification.Warning.TangemPayUnreachable -> null is WalletNotification.UpgradeHotWalletPromo -> null diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt index ea093c657c..7a5d2caf8c 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt @@ -38,6 +38,7 @@ import com.tangem.feature.wallet.impl.R import com.tangem.feature.wallet.presentation.account.AccountDependencies import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification import com.tangem.features.hotwallet.HotWalletFeatureToggles +import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles import com.tangem.hot.sdk.model.HotWalletId import com.tangem.lib.crypto.BlockchainUtils import com.tangem.utils.extensions.addIf @@ -68,6 +69,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor( private val yieldSupplyGetShouldShowMainPromoUseCase: YieldSupplyGetShouldShowMainPromoUseCase, private val yieldSupplyFeatureToggles: YieldSupplyFeatureToggles, private val designFeatureToggles: DesignFeatureToggles, + private val walletFeatureToggles: WalletFeatureToggles, ) { @Suppress("UNCHECKED_CAST", "MagicNumber", "LongMethod", "CastNullableToNonNullableType") @@ -113,9 +115,17 @@ internal class GetMultiWalletWarningsFactory @Inject constructor( .filterIsInstance() .firstOrNull() + val isAddFundsBannerShown = isAddFundsBannerVisible(accountStatusList.totalFiatBalance) + buildList { addUsedOutdatedDataNotification(accountStatusList.totalFiatBalance) + addAddFundsBanner( + isVisible = isAddFundsBannerShown, + userWallet = userWallet, + clickIntents = clickIntents, + ) + addCriticalNotifications(userWallet, clickIntents) addUpgradeHotWalletPromoNotification( @@ -126,12 +136,14 @@ internal class GetMultiWalletWarningsFactory @Inject constructor( closureTimestamp = closureTimestamp, ) - addFinishWalletActivationNotification( - userWallet = userWallet, - flattenCurrencies = flattenCurrencies, - clickIntents = clickIntents, - shouldAccessCodeSkipped = shouldAccessCodeSkipped, - ) + if (!isAddFundsBannerShown) { + addFinishWalletActivationNotification( + userWallet = userWallet, + flattenCurrencies = flattenCurrencies, + clickIntents = clickIntents, + shouldAccessCodeSkipped = shouldAccessCodeSkipped, + ) + } addInformationalNotifications( userWallet = userWallet, @@ -242,6 +254,25 @@ internal class GetMultiWalletWarningsFactory @Inject constructor( ) } + private fun isAddFundsBannerVisible(totalFiatBalance: TotalFiatBalance): Boolean { + if (!walletFeatureToggles.isAddFundsStage1Enabled) return false + val loaded = totalFiatBalance as? TotalFiatBalance.Loaded ?: return false + return loaded.amount.orZero().signum() == 0 + } + + private fun MutableList.addAddFundsBanner( + isVisible: Boolean, + userWallet: UserWallet, + clickIntents: WalletClickIntents, + ) { + addIf( + element = WalletNotification.AddFunds( + onClick = { clickIntents.onAddFundsPromoClick(userWallet.walletId) }, + ), + condition = isVisible, + ) + } + private fun MutableList.addCriticalNotifications( userWallet: UserWallet, clickIntents: WalletClickIntents, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetWalletNotificationsFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetWalletNotificationsFactory.kt index 4634513e11..2bd65ca2d6 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetWalletNotificationsFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetWalletNotificationsFactory.kt @@ -77,12 +77,14 @@ internal class GetWalletNotificationsFactory @Inject constructor( addCriticalNotifications(userWallet, clickIntents) - addFinishWalletActivationNotification( - userWallet = userWallet, - totalFiatBalance = totalFiatBalance, - clickIntents = clickIntents, - shouldAccessCodeSkipped = shouldAccessCodeSkipped, - ) + if (!isAddFundsBannerShown) { + addFinishWalletActivationNotification( + userWallet = userWallet, + totalFiatBalance = totalFiatBalance, + clickIntents = clickIntents, + shouldAccessCodeSkipped = shouldAccessCodeSkipped, + ) + } addInformationalNotifications( userWallet = userWallet, @@ -95,7 +97,7 @@ internal class GetWalletNotificationsFactory @Inject constructor( userWallet = userWallet, cardTypesResolver = cardTypesResolver, flattenCurrencies = flattenCurrencies, - isNeedToBackup = isNeedToBackup && !isAddFundsBannerShown, + isNeedToBackup = isNeedToBackup, clickIntents = clickIntents, ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotification.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotification.kt index 2b25705935..fca10e657d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotification.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotification.kt @@ -13,6 +13,8 @@ import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.extensions.wrappedList import com.tangem.feature.wallet.child.wallet.model.WalletActivationBannerType import com.tangem.feature.wallet.impl.R +import com.tangem.core.res.R as CoreResR +import com.tangem.core.ui.R as CoreUiR /** * Wallet notification component state @@ -241,6 +243,19 @@ sealed class WalletNotification(val config: NotificationConfig) { ), ) + data class AddFunds(val onClick: () -> Unit) : WalletNotification( + config = NotificationConfig( + title = resourceReference(CoreResR.string.main_add_funds_promo_title), + subtitle = resourceReference(CoreResR.string.main_add_funds_promo_description), + iconResId = CoreUiR.drawable.ic_coins_swap_24, + iconTint = IconTint.Accent, + buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig( + text = resourceReference(CoreResR.string.common_add_funds), + onClick = onClick, + ), + ), + ) + data object UsedOutdatedData : WalletNotification( config = NotificationConfig( subtitle = resourceReference(R.string.warning_some_token_balances_not_updated),