Updated on 2026-08-14
This commit is contained in:
commit
4f4e0a19fc
7 changed files with 30 additions and 9 deletions
|
|
@ -39,10 +39,6 @@ suspend fun Store<*>.dispatchWithMain(action: Action) {
|
|||
}
|
||||
}
|
||||
|
||||
fun Store<*>.dispatchNotification(resId: Int) {
|
||||
dispatchOnMain(GlobalAction.ShowNotification(resId))
|
||||
}
|
||||
|
||||
suspend fun Store<AppState>.onUserWalletSelected(userWallet: UserWallet) {
|
||||
state.globalState.tapWalletManager.onWalletSelected(userWallet)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent {
|
|||
renameWallet = {},
|
||||
forgetWallet = {},
|
||||
onLinkMoreCardsClick = {},
|
||||
onReferralClick = {},
|
||||
isManageTokensAvailable = true,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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<DialogConfig>) {
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,7 @@ internal class ItemsBuilder @Inject constructor(
|
|||
forgetWallet: () -> Unit,
|
||||
renameWallet: () -> Unit,
|
||||
onLinkMoreCardsClick: () -> Unit,
|
||||
onReferralClick: () -> Unit,
|
||||
): PersistentList<WalletSettingsItemUM> = persistentListOf<WalletSettingsItemUM>()
|
||||
.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(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue