Updated on 2026-08-14
This commit is contained in:
parent
99d32963b5
commit
a73dfc58af
4 changed files with 62 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<AccountStatus.Payment>()
|
||||
.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<WalletNotification>.addAddFundsBanner(
|
||||
isVisible: Boolean,
|
||||
userWallet: UserWallet,
|
||||
clickIntents: WalletClickIntents,
|
||||
) {
|
||||
addIf(
|
||||
element = WalletNotification.AddFunds(
|
||||
onClick = { clickIntents.onAddFundsPromoClick(userWallet.walletId) },
|
||||
),
|
||||
condition = isVisible,
|
||||
)
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addCriticalNotifications(
|
||||
userWallet: UserWallet,
|
||||
clickIntents: WalletClickIntents,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue