From 62489993212dfaeb42cc4045c26b27612a6c0d9c Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 30 Sep 2024 18:34:19 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../preview/PreviewWalletSettingsComponent.kt | 1 + .../entity/WalletSettingsItemUM.kt | 1 + .../walletsettings/model/WalletSettingsModel.kt | 8 ++++++-- .../walletsettings/ui/WalletSettingsScreen.kt | 1 + .../walletsettings/utils/ItemsBuilder.kt | 17 ++++++++++------- 5 files changed, 19 insertions(+), 9 deletions(-) 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 5844c0eab0..47d910bafc 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 @@ -22,6 +22,7 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent { userWalletName = "My Wallet", isReferralAvailable = true, isLinkMoreCardsAvailable = true, + isRenameWalletAvailable = false, renameWallet = {}, forgetWallet = {}, onLinkMoreCardsClick = {}, diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/entity/WalletSettingsItemUM.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/entity/WalletSettingsItemUM.kt index 9596f1fa02..ee17e4637b 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/entity/WalletSettingsItemUM.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/entity/WalletSettingsItemUM.kt @@ -20,6 +20,7 @@ internal sealed class WalletSettingsItemUM { override val id: String, val title: TextReference, val text: TextReference, + val isEnabled: Boolean, val onClick: () -> Unit, ) : WalletSettingsItemUM() } \ No newline at end of file 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 bcb2719cec..0927a822e4 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 @@ -25,6 +25,7 @@ import com.tangem.domain.redux.ReduxStateHolder import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.usecase.DeleteWalletUseCase import com.tangem.domain.wallets.usecase.GetUserWalletUseCase +import com.tangem.domain.wallets.usecase.ShouldSaveUserWalletsSyncUseCase import com.tangem.feature.walletsettings.analytics.Settings import com.tangem.feature.walletsettings.component.WalletSettingsComponent import com.tangem.feature.walletsettings.entity.DialogConfig @@ -53,6 +54,7 @@ internal class WalletSettingsModel @Inject constructor( private val analyticsEventHandler: AnalyticsEventHandler, private val analyticsContextProxy: AnalyticsContextProxy, private val reduxStateHolder: ReduxStateHolder, + private val getShouldSaveUserWalletsSyncUseCase: ShouldSaveUserWalletsSyncUseCase, ) : Model() { val params: WalletSettingsComponent.Params = paramsContainer.require() @@ -70,9 +72,9 @@ internal class WalletSettingsModel @Inject constructor( .distinctUntilChanged() .onEach { maybeWallet -> val wallet = maybeWallet.getOrNull() ?: return@onEach - + val isRenameWalletAvailable = getShouldSaveUserWalletsSyncUseCase() state.update { value -> - value.copy(items = buildItems(wallet, dialogNavigation)) + value.copy(items = buildItems(wallet, dialogNavigation, isRenameWalletAvailable)) } } .launchIn(modelScope) @@ -81,12 +83,14 @@ internal class WalletSettingsModel @Inject constructor( private fun buildItems( userWallet: UserWallet, dialogNavigation: SlotNavigation, + isRenameWalletAvailable: Boolean, ): PersistentList = itemsBuilder.buildItems( userWalletId = userWallet.walletId, userWalletName = userWallet.name, isReferralAvailable = userWallet.cardTypesResolver.isTangemWallet(), isLinkMoreCardsAvailable = userWallet.scanResponse.card.backupStatus == CardDTO.BackupStatus.NoBackup, isManageTokensAvailable = userWallet.isMultiCurrency, + isRenameWalletAvailable = isRenameWalletAvailable, renameWallet = { openRenameWalletDialog(userWallet, dialogNavigation) }, forgetWallet = { messageSender.send( diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/ui/WalletSettingsScreen.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/ui/WalletSettingsScreen.kt index e2d06d71c8..f3a06473f2 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/ui/WalletSettingsScreen.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/ui/WalletSettingsScreen.kt @@ -145,6 +145,7 @@ private fun ItemsBlock(model: WalletSettingsItemUM.WithItems, modifier: Modifier private fun TextBlock(model: WalletSettingsItemUM.WithText, modifier: Modifier = Modifier) { BlockCard( modifier = modifier.fillMaxWidth(), + enabled = model.isEnabled, onClick = model.onClick, ) { Column( 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 74ebf2067c..c6b465997b 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 @@ -30,11 +30,12 @@ internal class ItemsBuilder @Inject constructor( isLinkMoreCardsAvailable: Boolean, isReferralAvailable: Boolean, isManageTokensAvailable: Boolean, + isRenameWalletAvailable: Boolean, forgetWallet: () -> Unit, renameWallet: () -> Unit, onLinkMoreCardsClick: () -> Unit, ): PersistentList = persistentListOf( - buildNameItem(userWalletName, renameWallet), + buildNameItem(userWalletName, isRenameWalletAvailable, renameWallet), buildCardItem( userWalletId = userWalletId, isLinkMoreCardsAvailable = isLinkMoreCardsAvailable, @@ -45,12 +46,14 @@ internal class ItemsBuilder @Inject constructor( buildForgetItem(forgetWallet), ) - private fun buildNameItem(walletName: String, renameWallet: () -> Unit) = WalletSettingsItemUM.WithText( - id = "wallet_name", - title = resourceReference(id = R.string.settings_wallet_name_title), - text = stringReference(walletName), - onClick = renameWallet, - ) + private fun buildNameItem(walletName: String, isRenameWalletAvailable: Boolean, renameWallet: () -> Unit) = + WalletSettingsItemUM.WithText( + id = "wallet_name", + title = resourceReference(id = R.string.settings_wallet_name_title), + text = stringReference(walletName), + isEnabled = isRenameWalletAvailable, + onClick = renameWallet, + ) private fun buildCardItem( userWalletId: UserWalletId,