Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-24 17:26:15 +05:00
parent 0bc27fd8c3
commit 5b65e1957c
3 changed files with 81 additions and 30 deletions

View file

@ -0,0 +1,6 @@
package com.tangem.feature.wallet.child.wallet.model;
public enum WalletActivationBannerType {
Attention,
Warning,
}

View file

@ -3,14 +3,23 @@ package com.tangem.feature.wallet.child.wallet.model.intents
import android.os.Build
import arrow.core.getOrElse
import com.tangem.common.TangemBlogUrlBuilder
import com.tangem.common.routing.AppRoute
import com.tangem.common.routing.AppRoute.*
import com.tangem.common.routing.AppRouter
import com.tangem.common.ui.notifications.NotificationId
import com.tangem.core.analytics.api.AnalyticsEventHandler
import com.tangem.core.analytics.models.AnalyticsParam
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.decompose.ui.UiMessageSender
import com.tangem.core.navigation.url.UrlOpener
import com.tangem.core.ui.components.bottomsheets.message.MessageBottomSheetUMV2
import com.tangem.core.ui.components.bottomsheets.message.icon
import com.tangem.core.ui.components.bottomsheets.message.infoBlock
import com.tangem.core.ui.components.bottomsheets.message.onClick
import com.tangem.core.ui.components.bottomsheets.message.primaryButton
import com.tangem.core.ui.components.bottomsheets.message.secondaryButton
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.message.bottomSheetMessage
import com.tangem.domain.wallets.usecase.DerivePublicKeysUseCase
import com.tangem.domain.card.SetCardWasScannedUseCase
import com.tangem.domain.core.wallets.UserWalletsListRepository
import com.tangem.domain.feedback.GetWalletMetaInfoUseCase
@ -35,10 +44,10 @@ import com.tangem.domain.staking.multi.MultiYieldBalanceFetcher
import com.tangem.domain.tokens.model.analytics.TokenSwapPromoAnalyticsEvent
import com.tangem.domain.wallets.legacy.UserWalletsListManager.Lockable.UnlockType
import com.tangem.domain.wallets.models.UnlockWalletsError
import com.tangem.domain.wallets.usecase.DerivePublicKeysUseCase
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
import com.tangem.domain.wallets.usecase.SeedPhraseNotificationUseCase
import com.tangem.domain.wallets.usecase.UnlockWalletsUseCase
import com.tangem.feature.wallet.child.wallet.model.WalletActivationBannerType
import com.tangem.feature.wallet.impl.R
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.Basic
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.MainScreen
@ -98,11 +107,11 @@ internal interface WalletWarningsClickIntents {
fun onSeedPhraseSecondNotificationReject()
fun onFinishWalletActivationClick()
fun onAllowPermissions()
fun onDenyPermissions()
fun onFinishWalletActivationClick(type: WalletActivationBannerType)
}
@Suppress("LargeClass", "LongParameterList", "TooManyFunctions")
@ -134,8 +143,35 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
private val setShouldShowNotificationUseCase: SetShouldShowNotificationUseCase,
private val notificationsRepository: NotificationsRepository,
private val permissionRepository: PermissionRepository,
private val messageSender: UiMessageSender,
) : BaseWalletClickIntents(), WalletWarningsClickIntents {
private val finalizeWalletSetupAlertBS
get() = bottomSheetMessage {
infoBlock {
icon(R.drawable.img_knight_shield_32) {
type = MessageBottomSheetUMV2.Icon.Type.Warning
backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.SameAsTint
}
title = resourceReference(R.string.hw_activation_need_title)
body = resourceReference(R.string.hw_activation_need_description)
}
secondaryButton {
text = resourceReference(R.string.common_later)
onClick {
closeBs()
}
}
primaryButton {
text = resourceReference(R.string.hw_activation_need_backup)
onClick {
val userWallet = getSelectedUserWallet() ?: return@onClick
appRouter.push(WalletActivation(userWallet.walletId))
closeBs()
}
}
}
override fun onAddBackupCardClick() {
analyticsEventHandler.send(MainScreen.NoticeBackupYourWalletTapped)
@ -316,7 +352,7 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
when (promoId) {
PromoId.Referral -> {
analyticsEventHandler.send(MainScreen.ReferralPromoButtonParticipate)
appRouter.push(AppRoute.ReferralProgram(userWalletId = userWallet.walletId))
appRouter.push(ReferralProgram(userWalletId = userWallet.walletId))
}
PromoId.Sepa -> {
analyticsEventHandler.send(
@ -328,7 +364,7 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
)
cryptoCurrency ?: return
appRouter.push(
AppRoute.Onramp(
Onramp(
userWalletId = userWallet.walletId,
currency = cryptoCurrency,
source = OnrampSource.SEPA_BANNER,
@ -430,9 +466,16 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
}
}
override fun onFinishWalletActivationClick() {
val userWallet = getSelectedUserWallet() ?: return
appRouter.push(AppRoute.WalletActivation(userWallet.walletId))
override fun onFinishWalletActivationClick(type: WalletActivationBannerType) {
when (type) {
WalletActivationBannerType.Attention -> {
val userWallet = getSelectedUserWallet() ?: return
appRouter.push(WalletActivation(userWallet.walletId))
}
WalletActivationBannerType.Warning -> {
messageSender.send(finalizeWalletSetupAlertBS)
}
}
}
override fun onAllowPermissions() {

View file

@ -30,6 +30,7 @@ import com.tangem.domain.tokens.error.TokenListError
import com.tangem.domain.wallets.models.SeedPhraseNotificationsStatus
import com.tangem.domain.wallets.usecase.IsNeedToBackupUseCase
import com.tangem.domain.wallets.usecase.SeedPhraseNotificationUseCase
import com.tangem.feature.wallet.child.wallet.model.WalletActivationBannerType
import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents
import com.tangem.feature.wallet.impl.R
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification
@ -364,6 +365,14 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
)
}
private fun TokenList?.getFinishWalletActivationType(): WalletActivationBannerType {
return if ((this?.totalFiatBalance as? TotalFiatBalance.Loaded)?.amount?.isPositive() == true) {
WalletActivationBannerType.Warning
} else {
WalletActivationBannerType.Attention
}
}
private fun MutableList<WalletNotification>.addFinishWalletActivationNotification(
userWallet: UserWallet,
maybeTokenList: Lce<TokenListError, TokenList>,
@ -373,35 +382,28 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
val shouldShowFinishActivation = !userWallet.backedUp
val iconTint = maybeTokenList.fold(
ifLoading = {
if ((it?.totalFiatBalance as? TotalFiatBalance.Loaded)?.amount?.isPositive() == true) {
IconTint.Warning
} else {
IconTint.Attention
}
},
ifContent = {
if ((it.totalFiatBalance as? TotalFiatBalance.Loaded)?.amount?.isPositive() == true) {
IconTint.Warning
} else {
IconTint.Attention
}
},
ifError = { IconTint.Attention },
val type = maybeTokenList.fold(
ifLoading = { it.getFinishWalletActivationType() },
ifContent = { it.getFinishWalletActivationType() },
ifError = { WalletActivationBannerType.Attention },
)
val tint = when (type) {
WalletActivationBannerType.Attention -> IconTint.Attention
WalletActivationBannerType.Warning -> IconTint.Warning
}
addIf(
element = WalletNotification.FinishWalletActivation(
iconTint = iconTint,
buttonsState = when (iconTint) {
IconTint.Warning -> ButtonsState.PrimaryButtonConfig(
iconTint = tint,
buttonsState = when (type) {
WalletActivationBannerType.Warning -> ButtonsState.PrimaryButtonConfig(
text = resourceReference(R.string.hw_activation_need_finish),
onClick = clickIntents::onFinishWalletActivationClick,
onClick = { clickIntents.onFinishWalletActivationClick(type) },
)
else -> ButtonsState.SecondaryButtonConfig(
text = resourceReference(R.string.hw_activation_need_finish),
onClick = clickIntents::onFinishWalletActivationClick,
onClick = { clickIntents.onFinishWalletActivationClick(type) },
)
},
),