From 1ecacbea51d2adb7d009d6c9701fe24663066bc2 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 24 Apr 2025 19:30:04 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../java/com/tangem/tap/common/extensions/Store.kt | 4 ---- .../tangem/tap/common/redux/global/GlobalAction.kt | 2 -- .../java/com/tangem/tap/features/demo/DemoHelper.kt | 12 ++++++++++-- features/wallet-settings/impl/build.gradle.kts | 1 + .../preview/PreviewWalletSettingsComponent.kt | 1 + .../walletsettings/model/WalletSettingsModel.kt | 13 +++++++++++++ .../feature/walletsettings/utils/ItemsBuilder.kt | 6 +++++- 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/common/extensions/Store.kt b/app/src/main/java/com/tangem/tap/common/extensions/Store.kt index b86d13b6e9..919c21972d 100644 --- a/app/src/main/java/com/tangem/tap/common/extensions/Store.kt +++ b/app/src/main/java/com/tangem/tap/common/extensions/Store.kt @@ -39,10 +39,6 @@ suspend fun Store<*>.dispatchWithMain(action: Action) { } } -fun Store<*>.dispatchNotification(resId: Int) { - dispatchOnMain(GlobalAction.ShowNotification(resId)) -} - suspend fun Store.onUserWalletSelected(userWallet: UserWallet) { state.globalState.tapWalletManager.onWalletSelected(userWallet) } diff --git a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt index 108d722975..1c984ff096 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt @@ -7,7 +7,6 @@ import com.tangem.domain.models.scan.ScanResponse import com.tangem.domain.redux.StateDialog import com.tangem.tap.common.redux.DebugErrorAction import com.tangem.tap.common.redux.ErrorAction -import com.tangem.tap.common.redux.NotificationAction import com.tangem.tap.domain.TapError import com.tangem.tap.features.onboarding.products.wallet.redux.BackupStartedSource import org.rekotlin.Action @@ -15,7 +14,6 @@ import org.rekotlin.Action sealed class GlobalAction : Action { // notifications - data class ShowNotification(override val messageResource: Int) : GlobalAction(), NotificationAction data class ShowErrorNotification(override val error: TapError) : GlobalAction(), ErrorAction data class DebugShowErrorNotification(override val error: TapError) : GlobalAction(), DebugErrorAction diff --git a/app/src/main/java/com/tangem/tap/features/demo/DemoHelper.kt b/app/src/main/java/com/tangem/tap/features/demo/DemoHelper.kt index c8576de418..4895cd65b9 100644 --- a/app/src/main/java/com/tangem/tap/features/demo/DemoHelper.kt +++ b/app/src/main/java/com/tangem/tap/features/demo/DemoHelper.kt @@ -1,11 +1,14 @@ package com.tangem.tap.features.demo +import com.tangem.core.ui.extensions.resourceReference +import com.tangem.core.ui.message.DialogMessage import com.tangem.domain.demo.DemoConfig import com.tangem.domain.models.scan.ScanResponse -import com.tangem.tap.common.extensions.dispatchNotification +import com.tangem.tap.common.extensions.inject import com.tangem.tap.common.redux.AppState import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction import com.tangem.tap.features.onboarding.products.wallet.redux.BackupAction +import com.tangem.tap.proxy.redux.DaggerGraphState import com.tangem.tap.store import com.tangem.wallet.R import org.rekotlin.Action @@ -37,7 +40,12 @@ object DemoHelper { } disabledActionFeatures.firstOrNull { it == action::class.java }?.let { - store.dispatchNotification(R.string.alert_demo_feature_disabled) + val uiMessageSender = store.inject(DaggerGraphState::uiMessageSender) + uiMessageSender.send( + DialogMessage( + message = resourceReference(R.string.alert_demo_feature_disabled), + ), + ) return true } diff --git a/features/wallet-settings/impl/build.gradle.kts b/features/wallet-settings/impl/build.gradle.kts index 0cfc119783..25dc7dd5c6 100644 --- a/features/wallet-settings/impl/build.gradle.kts +++ b/features/wallet-settings/impl/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { implementation(projects.domain.models) implementation(projects.domain.wallets) implementation(projects.domain.wallets.models) + implementation(projects.domain.demo) /* AndroidX */ implementation(deps.androidx.fragment.ktx) diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/preview/PreviewWalletSettingsComponent.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/preview/PreviewWalletSettingsComponent.kt index 4e77769e0d..40383c55b5 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/preview/PreviewWalletSettingsComponent.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/preview/PreviewWalletSettingsComponent.kt @@ -29,6 +29,7 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent { renameWallet = {}, forgetWallet = {}, onLinkMoreCardsClick = {}, + onReferralClick = {}, isManageTokensAvailable = true, ), ) diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt index cc48296697..33f0abba3e 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt @@ -16,6 +16,7 @@ import com.tangem.core.ui.message.DialogMessage import com.tangem.core.ui.message.EventMessageAction import com.tangem.core.ui.message.SnackbarMessage import com.tangem.domain.common.util.cardTypesResolver +import com.tangem.domain.demo.IsDemoCardUseCase import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ScanResponse import com.tangem.domain.redux.LegacyAction @@ -56,6 +57,7 @@ internal class WalletSettingsModel @Inject constructor( private val analyticsContextProxy: AnalyticsContextProxy, private val reduxStateHolder: ReduxStateHolder, private val getShouldSaveUserWalletsSyncUseCase: ShouldSaveUserWalletsSyncUseCase, + private val isDemoCardUseCase: IsDemoCardUseCase, private val walletsRepository: WalletsRepository, private val nftFeatureToggles: NFTFeatureToggles, private val onboardingV2FeatureToggles: OnboardingV2FeatureToggles, @@ -127,6 +129,7 @@ internal class WalletSettingsModel @Inject constructor( onLinkMoreCardsClick = { onLinkMoreCardsClick(scanResponse = userWallet.scanResponse) }, + onReferralClick = { onReferralClick(userWallet) }, ) private fun openRenameWalletDialog(userWallet: UserWallet, dialogNavigation: SlotNavigation) { @@ -188,4 +191,14 @@ internal class WalletSettingsModel @Inject constructor( } } } + + private fun onReferralClick(userWallet: UserWallet) { + if (isDemoCardUseCase(userWallet.cardId)) { + messageSender.send( + DialogMessage(message = resourceReference(R.string.alert_demo_feature_disabled)), + ) + } else { + router.push(AppRoute.ReferralProgram(userWallet.walletId)) + } + } } \ No newline at end of file diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/ItemsBuilder.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/ItemsBuilder.kt index 75fbbc0e4b..39670ae4c1 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/ItemsBuilder.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/ItemsBuilder.kt @@ -37,6 +37,7 @@ internal class ItemsBuilder @Inject constructor( forgetWallet: () -> Unit, renameWallet: () -> Unit, onLinkMoreCardsClick: () -> Unit, + onReferralClick: () -> Unit, ): PersistentList = persistentListOf() .add(buildNameItem(userWalletName, isRenameWalletAvailable, renameWallet)) .run { @@ -53,6 +54,7 @@ internal class ItemsBuilder @Inject constructor( isReferralAvailable = isReferralAvailable, isManageTokensAvailable = isManageTokensAvailable, onLinkMoreCardsClick = onLinkMoreCardsClick, + onReferralClick = onReferralClick, ), ) .add(buildForgetItem(forgetWallet)) @@ -74,12 +76,14 @@ internal class ItemsBuilder @Inject constructor( onCheckedChange = onCheckedNFTChange, ) + @Suppress("LongParameterList") private fun buildCardItem( userWalletId: UserWalletId, isLinkMoreCardsAvailable: Boolean, isReferralAvailable: Boolean, isManageTokensAvailable: Boolean, onLinkMoreCardsClick: () -> Unit, + onReferralClick: () -> Unit, ) = WalletSettingsItemUM.WithItems( id = "card", description = resourceReference(R.string.settings_card_settings_footer), @@ -113,7 +117,7 @@ internal class ItemsBuilder @Inject constructor( BlockUM( text = resourceReference(R.string.details_referral_title), iconRes = R.drawable.ic_add_friends_24, - onClick = { router.push(AppRoute.ReferralProgram(userWalletId)) }, + onClick = onReferralClick, ).let(::add) } }.toImmutableList(),