diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index a6a6b012a1..759c235612 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -787,6 +787,8 @@ The Koinos network requires Mana for network fees. You have %1$s/%2$s Mana Mana level Add & Manage + Deposit crypto or buy with card to get started + Add funds to start earning and trading To begin tracking your crypto assets and transactions, add tokens Manage tokens Scan QR code to send funds or connect to an app diff --git a/core/ui/src/main/res/drawable/ic_coins_swap_24.xml b/core/ui/src/main/res/drawable/ic_coins_swap_24.xml new file mode 100644 index 0000000000..b4d4394952 --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_coins_swap_24.xml @@ -0,0 +1,13 @@ + + + + diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt index b73b5ec3cc..952cf4764d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt @@ -13,6 +13,7 @@ import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase import com.tangem.domain.wallets.usecase.SelectWalletUseCase import com.tangem.domain.yield.supply.usecase.YieldSupplyApyUpdateUseCase import com.tangem.feature.wallet.presentation.router.InnerWalletRouter +import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent import com.tangem.feature.wallet.presentation.wallet.domain.OnrampStatusFactory import com.tangem.feature.wallet.presentation.wallet.domain.WalletContentFetcher import com.tangem.feature.wallet.presentation.wallet.domain.unwrap @@ -123,6 +124,11 @@ internal class WalletClickIntents @Inject constructor( router.openAddFunds(userWalletId) } + fun onAddFundsPromoClick(userWalletId: UserWalletId) { + analyticsEventHandler.send(WalletScreenAnalyticsEvent.MainScreen.ButtonAddFundsPromo()) + router.openAddFunds(userWalletId) + } + private fun refreshMultiCurrencyContent(showRefreshState: Boolean) { val userWallet = getSelectedWalletSyncUseCase.unwrap() ?: return diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/WalletScreenAnalyticsEvent.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/WalletScreenAnalyticsEvent.kt index f98e930174..3ca0302f7d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/WalletScreenAnalyticsEvent.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/WalletScreenAnalyticsEvent.kt @@ -103,6 +103,10 @@ sealed class WalletScreenAnalyticsEvent { class BackupError : MainScreen(event = "Notice - Backup Error") + class NoticeAddFunds : MainScreen(event = "Notice - Add Funds") + + class ButtonAddFundsPromo : MainScreen(event = "Button - Add Funds Promo") + class NotePromo : MainScreen(event = "Notice - Note Promo") class NotePromoButton : MainScreen(event = "Note Promo Button") 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 1d2faad058..d46b074520 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 @@ -131,6 +131,7 @@ internal class WalletWarningsAnalyticsSender @Inject constructor( ) } is WalletNotificationUM.PushNotifications -> PushBanner() + is WalletNotificationUM.AddFunds -> NoticeAddFunds() is WalletNotificationUM.UnlockWallets, is WalletNotificationUM.NoAccount, is WalletNotificationUM.LowSignatures, 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 a33dcd20ed..a64fca5c8c 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 @@ -64,9 +64,17 @@ internal class GetWalletNotificationsFactory @Inject constructor( .filterIsInstance() .firstOrNull() + val isAddFundsBannerShown = isAddFundsBannerVisible(totalFiatBalance) + buildList { addUsedOutdatedDataNotification(totalFiatBalance) + addAddFundsBanner( + isVisible = isAddFundsBannerShown, + userWallet = userWallet, + clickIntents = clickIntents, + ) + addCriticalNotifications(userWallet, clickIntents) addFinishWalletActivationNotification( @@ -87,7 +95,7 @@ internal class GetWalletNotificationsFactory @Inject constructor( userWallet = userWallet, cardTypesResolver = cardTypesResolver, flattenCurrencies = flattenCurrencies, - isNeedToBackup = isNeedToBackup, + isNeedToBackup = isNeedToBackup && !isAddFundsBannerShown, clickIntents = clickIntents, ) @@ -109,6 +117,24 @@ internal class GetWalletNotificationsFactory @Inject constructor( ) } + private fun isAddFundsBannerVisible(totalFiatBalance: TotalFiatBalance): Boolean { + 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 = WalletNotificationUM.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/state/model/WalletNotificationUM.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotificationUM.kt index 5a0df5c3ec..f9e4fd87d8 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotificationUM.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotificationUM.kt @@ -11,6 +11,8 @@ import com.tangem.core.ui.extensions.* import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.wallet.impl.R import kotlinx.collections.immutable.persistentListOf +import com.tangem.core.res.R as CoreResR +import com.tangem.core.ui.R as CoreUiR /** * Wallet notification types @@ -342,6 +344,27 @@ internal sealed class WalletNotificationUM(val messageUM: TangemMessageUM, val t // endregion // region Promo + data class AddFunds(val onClick: () -> Unit) : WalletNotificationUM( + messageUM = TangemMessageUM( + id = "AddFundsPromoNotification", + title = resourceReference(id = CoreResR.string.main_add_funds_promo_title), + subtitle = resourceReference(id = CoreResR.string.main_add_funds_promo_description), + iconUM = TangemIconUM.Icon( + iconRes = CoreUiR.drawable.ic_coins_swap_24, + tintReference = { TangemTheme.colors2.graphic.status.accent }, + ), + messageEffect = TangemMessageEffect.None, + buttonsUM = persistentListOf( + TangemMessageButtonUM( + text = resourceReference(id = CoreResR.string.common_add_funds), + type = TangemButtonType.Secondary, + onClick = onClick, + ), + ), + ), + type = WalletNotificationType.Promo, + ) + data class NoteMigration(val onClick: () -> Unit) : WalletNotificationUM( messageUM = TangemMessageUM( id = "NoteMigrationNotification",