Updated on 2026-08-14
This commit is contained in:
parent
c703edde8e
commit
8e77f5b2d3
15 changed files with 27 additions and 141 deletions
|
|
@ -396,26 +396,6 @@ internal object WalletsDomainModule {
|
|||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesIsUpgradeWalletNotificationEnabledUseCase(
|
||||
walletsRepository: WalletsRepository,
|
||||
): IsUpgradeWalletNotificationEnabledUseCase {
|
||||
return IsUpgradeWalletNotificationEnabledUseCase(
|
||||
walletsRepository = walletsRepository,
|
||||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesDismissUpgradeWalletNotificationUseCase(
|
||||
walletsRepository: WalletsRepository,
|
||||
): DismissUpgradeWalletNotificationUseCase {
|
||||
return DismissUpgradeWalletNotificationUseCase(
|
||||
walletsRepository = walletsRepository,
|
||||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesUnlockHotWalletContextualUseCase(
|
||||
|
|
|
|||
|
|
@ -50,9 +50,6 @@ internal class DefaultWalletsRepository(
|
|||
private val moshi: com.squareup.moshi.Moshi,
|
||||
) : WalletsRepository {
|
||||
|
||||
private val upgradeWalletNotificationDisabled: MutableStateFlow<Set<UserWalletId>> =
|
||||
MutableStateFlow(mutableSetOf())
|
||||
|
||||
@Deprecated("Hot wallet feature makes app always save user wallets. Do not use this method")
|
||||
override suspend fun shouldSaveUserWalletsSync(): Boolean {
|
||||
return appPreferencesStore.getSyncOrDefault(key = PreferencesKeys.SAVE_USER_WALLETS_KEY, default = false)
|
||||
|
|
@ -339,16 +336,6 @@ internal class DefaultWalletsRepository(
|
|||
}
|
||||
}
|
||||
|
||||
override fun isUpgradeWalletNotificationEnabled(userWalletId: UserWalletId): Flow<Boolean> {
|
||||
return upgradeWalletNotificationDisabled.map {
|
||||
it.contains(userWalletId)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun dismissUpgradeWalletNotification(userWalletId: UserWalletId) {
|
||||
upgradeWalletNotificationDisabled.update { it.plus(userWalletId) }
|
||||
}
|
||||
|
||||
override suspend fun setWalletName(walletId: UserWalletId, walletName: String) = withContext(dispatchers.io) {
|
||||
val userWallet = userWalletsStore.getSyncOrNull(key = walletId)
|
||||
|
||||
|
|
|
|||
|
|
@ -60,10 +60,6 @@ interface WalletsRepository {
|
|||
|
||||
suspend fun setNotificationsEnabled(userWalletId: UserWalletId, isEnabled: Boolean)
|
||||
|
||||
fun isUpgradeWalletNotificationEnabled(userWalletId: UserWalletId): Flow<Boolean>
|
||||
|
||||
suspend fun dismissUpgradeWalletNotification(userWalletId: UserWalletId)
|
||||
|
||||
@Throws
|
||||
suspend fun setWalletName(walletId: UserWalletId, walletName: String)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
package com.tangem.domain.wallets.usecase
|
||||
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.wallets.repository.WalletsRepository
|
||||
|
||||
class DismissUpgradeWalletNotificationUseCase(
|
||||
private val walletsRepository: WalletsRepository,
|
||||
) {
|
||||
suspend operator fun invoke(userWalletId: UserWalletId) {
|
||||
walletsRepository.dismissUpgradeWalletNotification(userWalletId)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package com.tangem.domain.wallets.usecase
|
||||
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.wallets.repository.WalletsRepository
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
class IsUpgradeWalletNotificationEnabledUseCase(
|
||||
private val walletsRepository: WalletsRepository,
|
||||
) {
|
||||
operator fun invoke(userWalletId: UserWalletId): Flow<Boolean> {
|
||||
return walletsRepository.isUpgradeWalletNotificationEnabled(userWalletId)
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ internal fun AccessCode(
|
|||
) {
|
||||
PinTextField(
|
||||
length = state.accessCodeLength,
|
||||
isPasswordVisual = state.isConfirmMode,
|
||||
isPasswordVisual = true,
|
||||
value = state.accessCode,
|
||||
pinTextColor = state.accessCodeColor,
|
||||
onValueChange = state.onAccessCodeChange,
|
||||
|
|
|
|||
|
|
@ -38,31 +38,19 @@ internal class ForgetWalletModel @Inject constructor(
|
|||
field = MutableStateFlow(
|
||||
ForgetWalletUM(
|
||||
onBackClick = { router.pop() },
|
||||
firstCheckboxChecked = false,
|
||||
secondCheckboxChecked = false,
|
||||
onFirstCheckboxClick = ::onFirstCheckboxClick,
|
||||
onSecondCheckboxClick = ::onSecondCheckboxClick,
|
||||
isCheckboxChecked = false,
|
||||
onCheckboxClick = ::onCheckboxClick,
|
||||
onForgetWalletClick = ::onForgetWalletClick,
|
||||
isForgetButtonEnabled = false,
|
||||
),
|
||||
)
|
||||
|
||||
private fun onFirstCheckboxClick() {
|
||||
uiState.update {
|
||||
val newValue = !it.firstCheckboxChecked
|
||||
it.copy(
|
||||
firstCheckboxChecked = newValue,
|
||||
isForgetButtonEnabled = newValue && it.secondCheckboxChecked,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSecondCheckboxClick() {
|
||||
uiState.update {
|
||||
val newValue = !it.secondCheckboxChecked
|
||||
it.copy(
|
||||
secondCheckboxChecked = newValue,
|
||||
isForgetButtonEnabled = it.firstCheckboxChecked && newValue,
|
||||
private fun onCheckboxClick() {
|
||||
uiState.update { currentState ->
|
||||
val newValue = !currentState.isCheckboxChecked
|
||||
currentState.copy(
|
||||
isCheckboxChecked = newValue,
|
||||
isForgetButtonEnabled = newValue,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@ package com.tangem.features.hotwallet.forgetwallet.entity
|
|||
|
||||
internal data class ForgetWalletUM(
|
||||
val onBackClick: () -> Unit,
|
||||
val firstCheckboxChecked: Boolean,
|
||||
val secondCheckboxChecked: Boolean,
|
||||
val onFirstCheckboxClick: () -> Unit,
|
||||
val onSecondCheckboxClick: () -> Unit,
|
||||
val isCheckboxChecked: Boolean,
|
||||
val onCheckboxClick: () -> Unit,
|
||||
val onForgetWalletClick: () -> Unit,
|
||||
val isForgetButtonEnabled: Boolean,
|
||||
)
|
||||
|
|
@ -70,15 +70,8 @@ internal fun ForgetWalletContent(state: ForgetWalletUM, modifier: Modifier = Mod
|
|||
Spacer(modifier = Modifier.height(48.dp))
|
||||
CheckboxItem(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
checked = state.firstCheckboxChecked,
|
||||
onCheckedChange = state.onFirstCheckboxClick,
|
||||
text = stringResourceSafe(R.string.hw_remove_wallet_warning_device),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
CheckboxItem(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
checked = state.secondCheckboxChecked,
|
||||
onCheckedChange = state.onSecondCheckboxClick,
|
||||
checked = state.isCheckboxChecked,
|
||||
onCheckedChange = state.onCheckboxClick,
|
||||
text = stringResourceSafe(R.string.hw_remove_wallet_warning_access),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
|
|
@ -142,10 +135,8 @@ private fun PreviewForgetWalletContent() {
|
|||
ForgetWalletContent(
|
||||
state = ForgetWalletUM(
|
||||
onBackClick = {},
|
||||
firstCheckboxChecked = true,
|
||||
secondCheckboxChecked = false,
|
||||
onFirstCheckboxClick = {},
|
||||
onSecondCheckboxClick = {},
|
||||
isCheckboxChecked = false,
|
||||
onCheckboxClick = {},
|
||||
onForgetWalletClick = {},
|
||||
isForgetButtonEnabled = false,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -65,9 +65,7 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent {
|
|||
onNotificationsDescriptionClick = {},
|
||||
isNotificationsPermissionGranted = false,
|
||||
onAccessCodeClick = {},
|
||||
walletUpgradeDismissed = false,
|
||||
onUpgradeWalletClick = {},
|
||||
onDismissUpgradeWalletClick = {},
|
||||
onBackupClick = {},
|
||||
onCardSettingsClick = {},
|
||||
accountsUM = previewAccounts(),
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ internal sealed class WalletSettingsItemUM {
|
|||
val title: TextReference,
|
||||
val description: TextReference,
|
||||
val onClick: () -> Unit,
|
||||
val onDismissClick: () -> Unit,
|
||||
) : WalletSettingsItemUM()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,6 @@ internal class WalletSettingsModel @Inject constructor(
|
|||
private val settingsManager: SettingsManager,
|
||||
private val permissionsRepository: PermissionRepository,
|
||||
private val notificationsRepository: NotificationsRepository,
|
||||
private val isUpgradeWalletNotificationEnabledUseCase: IsUpgradeWalletNotificationEnabledUseCase,
|
||||
private val dismissUpgradeWalletNotificationUseCase: DismissUpgradeWalletNotificationUseCase,
|
||||
private val unlockHotWalletContextualUseCase: UnlockHotWalletContextualUseCase,
|
||||
private val accountsFeatureToggles: AccountsFeatureToggles,
|
||||
private val isAccountsModeEnabledUseCase: IsAccountsModeEnabledUseCase,
|
||||
|
|
@ -140,10 +138,9 @@ internal class WalletSettingsModel @Inject constructor(
|
|||
flow2 = getWalletNotificationsEnabledUseCase(params.userWalletId)
|
||||
.distinctUntilChanged()
|
||||
.conflate(),
|
||||
flow3 = isUpgradeWalletNotificationEnabledUseCase(params.userWalletId),
|
||||
flow4 = walletCardItemDelegate.cardItemFlow(wallet),
|
||||
flow5 = accountItemsDelegate.loadAccount(wallet),
|
||||
) { nftEnabled, notificationsEnabled, isUpgradeNotificationEnabled, cardItem, accountList ->
|
||||
flow3 = walletCardItemDelegate.cardItemFlow(wallet),
|
||||
flow4 = accountItemsDelegate.loadAccount(wallet),
|
||||
) { nftEnabled, notificationsEnabled, cardItem, accountList ->
|
||||
val isWalletBackedUp = when (wallet) {
|
||||
is UserWallet.Hot -> wallet.backedUp
|
||||
is UserWallet.Cold -> true
|
||||
|
|
@ -156,7 +153,6 @@ internal class WalletSettingsModel @Inject constructor(
|
|||
isNFTEnabled = nftEnabled,
|
||||
isNotificationsEnabled = notificationsEnabled,
|
||||
isNotificationsPermissionGranted = isNotificationsPermissionGranted(),
|
||||
isUpgradeNotificationEnabled = isUpgradeNotificationEnabled,
|
||||
accountList = accountList,
|
||||
),
|
||||
accountReorderUM = AccountReorderUM(
|
||||
|
|
@ -197,7 +193,6 @@ internal class WalletSettingsModel @Inject constructor(
|
|||
isNFTEnabled: Boolean,
|
||||
isNotificationsEnabled: Boolean,
|
||||
isNotificationsPermissionGranted: Boolean,
|
||||
isUpgradeNotificationEnabled: Boolean,
|
||||
accountList: List<WalletSettingsAccountsUM>,
|
||||
): PersistentList<WalletSettingsItemUM> {
|
||||
val isAccountsFeatureEnabled = accountsFeatureToggles.isFeatureEnabled
|
||||
|
|
@ -254,9 +249,7 @@ internal class WalletSettingsModel @Inject constructor(
|
|||
onCheckedNotificationsChanged = ::onCheckedNotificationsChange,
|
||||
onNotificationsDescriptionClick = ::onNotificationsDescriptionClick,
|
||||
onAccessCodeClick = { onAccessCodeClick(userWallet) },
|
||||
walletUpgradeDismissed = isUpgradeNotificationEnabled,
|
||||
onUpgradeWalletClick = { onUpgradeWalletClick() },
|
||||
onDismissUpgradeWalletClick = ::onDismissUpgradeWalletClick,
|
||||
onBackupClick = ::onBackupClick,
|
||||
onCardSettingsClick = ::onCardSettingsClick,
|
||||
accountsUM = accountList,
|
||||
|
|
@ -411,12 +404,6 @@ internal class WalletSettingsModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun onDismissUpgradeWalletClick() {
|
||||
modelScope.launch {
|
||||
dismissUpgradeWalletNotificationUseCase.invoke(params.userWalletId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onBackupClick() {
|
||||
analyticsEventHandler.send(WalletSettingsAnalyticEvents.ButtonBackup())
|
||||
router.push(AppRoute.WalletBackup(params.userWalletId))
|
||||
|
|
|
|||
|
|
@ -281,7 +281,6 @@ private fun UpgradeWalletBlock(model: WalletSettingsItemUM.UpgradeWallet, modifi
|
|||
iconResId = R.drawable.ic_hardware_backup_36,
|
||||
iconSize = 36.dp,
|
||||
onClick = model.onClick,
|
||||
onCloseClick = model.onDismissClick,
|
||||
shouldShowArrowIcon = false,
|
||||
),
|
||||
modifier = modifier,
|
||||
|
|
@ -493,7 +492,6 @@ private fun Preview_WalletSettingsScreen1() {
|
|||
title = stringReference("Upgrade wallet with a hardware backup"),
|
||||
description = stringReference("Keep your crypto safe with Tangem’s best-in-class hardware wallet."),
|
||||
onClick = {},
|
||||
onDismissClick = {},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ internal class ItemsBuilder @Inject constructor() {
|
|||
onReferralClick: () -> Unit,
|
||||
onManageTokensClick: () -> Unit,
|
||||
onAccessCodeClick: () -> Unit,
|
||||
walletUpgradeDismissed: Boolean,
|
||||
onUpgradeWalletClick: () -> Unit,
|
||||
onDismissUpgradeWalletClick: () -> Unit,
|
||||
onBackupClick: () -> Unit,
|
||||
onCardSettingsClick: () -> Unit,
|
||||
): PersistentList<WalletSettingsItemUM> = persistentListOf<WalletSettingsItemUM>()
|
||||
|
|
@ -48,9 +46,7 @@ internal class ItemsBuilder @Inject constructor() {
|
|||
.addAll(
|
||||
buildUpgradeWalletItem(
|
||||
userWallet = userWallet,
|
||||
walletUpgradeDismissed = walletUpgradeDismissed,
|
||||
onUpgradeWalletClick = onUpgradeWalletClick,
|
||||
onDismissUpgradeWalletClick = onDismissUpgradeWalletClick,
|
||||
),
|
||||
)
|
||||
.addAll(buildAccessCodeItem(userWallet, onAccessCodeClick))
|
||||
|
|
@ -122,24 +118,17 @@ internal class ItemsBuilder @Inject constructor() {
|
|||
|
||||
private fun buildUpgradeWalletItem(
|
||||
userWallet: UserWallet,
|
||||
walletUpgradeDismissed: Boolean,
|
||||
onUpgradeWalletClick: () -> Unit,
|
||||
onDismissUpgradeWalletClick: () -> Unit,
|
||||
): List<WalletSettingsItemUM> = when (userWallet) {
|
||||
is UserWallet.Cold -> emptyList()
|
||||
is UserWallet.Hot -> if (!walletUpgradeDismissed) {
|
||||
listOf(
|
||||
is UserWallet.Hot -> listOf(
|
||||
WalletSettingsItemUM.UpgradeWallet(
|
||||
id = "upgrade_wallet",
|
||||
title = resourceReference(id = R.string.hw_upgrade_to_cold_banner_title),
|
||||
description = resourceReference(id = R.string.hw_upgrade_to_cold_banner_description),
|
||||
onClick = onUpgradeWalletClick,
|
||||
onDismissClick = onDismissUpgradeWalletClick,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildNotificationsPermissionItem() = WalletSettingsItemUM.NotificationPermission(
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ internal fun AnimatedContentScope.WelcomeSelectWallet(state: WelcomeUM.SelectWal
|
|||
BottomFade(modifier = Modifier.align(Alignment.BottomCenter))
|
||||
|
||||
if (state.showUnlockWithBiometricButton) {
|
||||
SecondaryButton(
|
||||
PrimaryButton(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.fillMaxWidth()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue