diff --git a/domain/card/src/main/kotlin/com/tangem/domain/card/CardTypesResolver.kt b/domain/card/src/main/kotlin/com/tangem/domain/card/CardTypesResolver.kt
index 625da3f339..ae9c6a0fbc 100644
--- a/domain/card/src/main/kotlin/com/tangem/domain/card/CardTypesResolver.kt
+++ b/domain/card/src/main/kotlin/com/tangem/domain/card/CardTypesResolver.kt
@@ -12,6 +12,7 @@ interface CardTypesResolver {
fun isShibaWallet(): Boolean
+ // 4.12
fun isWhiteWallet(): Boolean
fun isWallet2(): Boolean
diff --git a/domain/wallets/src/main/java/com/tangem/domain/wallets/extension/UserWalletExtensions.kt b/domain/wallets/src/main/java/com/tangem/domain/wallets/extension/UserWalletExtensions.kt
index 74055cd741..1047bb4f03 100644
--- a/domain/wallets/src/main/java/com/tangem/domain/wallets/extension/UserWalletExtensions.kt
+++ b/domain/wallets/src/main/java/com/tangem/domain/wallets/extension/UserWalletExtensions.kt
@@ -3,6 +3,7 @@ package com.tangem.domain.wallets.extension
import com.tangem.blockchain.blockchains.cardano.CardanoUtils
import com.tangem.blockchain.common.Blockchain
import com.tangem.crypto.hdWallet.DerivationPath
+import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.hasDerivation
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.wallets.config.curvesConfig
@@ -25,4 +26,17 @@ fun UserWallet.hasDerivation(blockchain: Blockchain, derivationPath: String): Bo
}
}
}
-}
\ No newline at end of file
+}
+
+/**
+ * Check if accounts are supported for the [UserWallet]
+ */
+val UserWallet.isAccountsSupported
+ get() = when (this) {
+ is UserWallet.Hot -> true
+ is UserWallet.Cold -> {
+ with(this.cardTypesResolver) {
+ isMultiwalletAllowed() && !isWhiteWallet()
+ }
+ }
+ }
\ No newline at end of file
diff --git a/features/wallet-settings/impl/detekt-baseline-debug.xml b/features/wallet-settings/impl/detekt-baseline-debug.xml
index 7eb2a6e84e..aba860e5ef 100644
--- a/features/wallet-settings/impl/detekt-baseline-debug.xml
+++ b/features/wallet-settings/impl/detekt-baseline-debug.xml
@@ -2,26 +2,8 @@
- BooleanPropertyNaming:AccountItemsDelegate.kt$AccountItemsDelegate$val addAccountEnabled = accounts.size < AccountList.MAX_ACCOUNTS_COUNT
- BooleanPropertyNaming:AccountItemsDelegate.kt$AccountItemsDelegate$val showDescription = accounts.size > 1
- BooleanPropertyNaming:WalletSettingsItemUM.kt$WalletSettingsAccountsUM.Footer$val showDescription: Boolean
- BooleanPropertyNaming:WalletSettingsItemUM.kt$WalletSettingsAccountsUM.Footer.AddAccountUM$val addAccountEnabled: Boolean
- BooleanPropertyNaming:WalletSettingsModel.kt$WalletSettingsModel$val accountsFeatureEnabled = accountsFeatureToggles.isFeatureEnabled
- BooleanPropertyNaming:WalletSettingsUM.kt$WalletSettingsUM$val requestPushNotificationsPermission: Boolean = false
- BooleanPropertyNaming:WalletSettingsUM.kt$WalletSettingsUM$val walletUpgradeDismissed: Boolean = false
- MultilineLambdaItParameter:RenameWalletModel.kt$RenameWalletModel${ Timber.e("Unable to rename wallet: $it") showRenameWalletError(error = it, updatedName = newName.text) }
- MultilineLambdaItParameter:RenameWalletModel.kt$RenameWalletModel${ val newName = value.text it.copy( walletNameValue = value, isConfirmEnabled = getConfirmButtonAvailability(newName), error = getErrorOrNull(newName), ) }
- MultilineLambdaItParameter:WalletSettingsModel.kt$WalletSettingsModel${ Timber.e("Unable to delete wallet: $it") messageSender.send( message = SnackbarMessage(resourceReference(R.string.common_unknown_error)), ) return@launch }
- MultilineLambdaItParameter:WalletSettingsModel.kt$WalletSettingsModel${ val id = (it as? WalletSettingsAccountsUM.Account)?.state?.id ?: return@mapNotNull null AccountId.forCryptoPortfolio(userWalletId = params.userWalletId, value = id).getOrNull() }
NonBooleanPropertyPrefixedWithIs:AccountItemsDelegate.kt$AccountItemsDelegate$private val isAccountsModeEnabledUseCase: IsAccountsModeEnabledUseCase
NonBooleanPropertyPrefixedWithIs:WalletSettingsModel.kt$WalletSettingsModel$private val isDemoCardUseCase: IsDemoCardUseCase
NonBooleanPropertyPrefixedWithIs:WalletSettingsModel.kt$WalletSettingsModel$private val isUpgradeWalletNotificationEnabledUseCase: IsUpgradeWalletNotificationEnabledUseCase
- PropertyUsedBeforeDeclaration:NetworksAvailableForNotificationsModel.kt$NetworksAvailableForNotificationsModel$_state
- PropertyUsedBeforeDeclaration:RenameWalletModel.kt$RenameWalletModel$_state
- UnnecessaryLet:AccountItemsDelegate.kt$AccountItemsDelegate$let(::add)
- UnnecessaryLet:ItemsBuilder.kt$ItemsBuilder$let(::add)
- UnnecessaryLet:PreviewWalletSettingsComponent.kt$PreviewWalletSettingsComponent$let(::add)
- UseEmptyCounterpart:Settings.kt$Settings$mapOf()
- UseEmptyCounterpart:WalletSettingsAnalyticEvents.kt$WalletSettingsAnalyticEvents$mapOf()
diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/analytics/Settings.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/analytics/Settings.kt
index 51c265394a..a3e4a8008b 100644
--- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/analytics/Settings.kt
+++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/analytics/Settings.kt
@@ -5,7 +5,7 @@ import com.tangem.core.analytics.models.AnalyticsEvent
internal sealed class Settings(
category: String = "Settings",
event: String,
- params: Map = mapOf(),
+ params: Map = emptyMap(),
) : AnalyticsEvent(category, event, params) {
data object ButtonCreateBackup : Settings(event = "Button - Create Backup")
diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/analytics/WalletSettingsAnalyticEvents.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/analytics/WalletSettingsAnalyticEvents.kt
index 6c2fbd0ee0..37898660f7 100644
--- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/analytics/WalletSettingsAnalyticEvents.kt
+++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/analytics/WalletSettingsAnalyticEvents.kt
@@ -7,7 +7,7 @@ import com.tangem.core.analytics.models.AnalyticsParam.Key.STATUS
internal sealed class WalletSettingsAnalyticEvents(
category: String = "Settings / Wallet",
event: String,
- params: Map = mapOf(),
+ params: Map = emptyMap(),
) : AnalyticsEvent(category, event, params) {
data class NftToggleSwitch(val enabled: AnalyticsParam.OnOffState) : WalletSettingsAnalyticEvents(
diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/DefaultWalletSettingsComponent.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/DefaultWalletSettingsComponent.kt
index 3c054dc1b7..eb842fbdc9 100644
--- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/DefaultWalletSettingsComponent.kt
+++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/DefaultWalletSettingsComponent.kt
@@ -100,7 +100,7 @@ internal class DefaultWalletSettingsComponent @AssistedInject constructor(
permission = PUSH_PERMISSION,
)
- if (state.requestPushNotificationsPermission) {
+ if (state.hasRequestPushNotificationsPermission) {
LaunchedEffect(Unit) {
requestPushPermission()
}
diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/model/NetworksAvailableForNotificationsModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/model/NetworksAvailableForNotificationsModel.kt
index 7d49112604..d9d204d47f 100644
--- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/model/NetworksAvailableForNotificationsModel.kt
+++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/model/NetworksAvailableForNotificationsModel.kt
@@ -19,19 +19,18 @@ internal class NetworksAvailableForNotificationsModel @Inject constructor(
override val dispatchers: CoroutineDispatcherProvider,
) : Model() {
- val state: StateFlow get() = _state
-
- private val _state = MutableStateFlow(
- value = NetworksAvailableForNotificationsUM(
- networks = persistentListOf(),
- isLoading = true,
- ),
- )
+ val state: StateFlow
+ field = MutableStateFlow(
+ value = NetworksAvailableForNotificationsUM(
+ networks = persistentListOf(),
+ isLoading = true,
+ ),
+ )
init {
modelScope.launch {
getNetworksAvailableForNotificationsUseCase().onRight { networks ->
- _state.update {
+ state.update {
it.copy(networks = networks.toImmutableList(), isLoading = false)
}
}
diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/model/RenameWalletModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/model/RenameWalletModel.kt
index ea34279a52..ef51de94a8 100644
--- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/model/RenameWalletModel.kt
+++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/impl/model/RenameWalletModel.kt
@@ -50,27 +50,26 @@ internal class RenameWalletModel @Inject constructor(
private val initialName = params.currentName
private val walletNames by lazy(getWalletNamesUseCase::invoke)
- val state: StateFlow get() = _state
-
- private val _state = MutableStateFlow(
- value = RenameWalletUM(
- walletNameValue = TextFieldValue(text = params.currentName),
- onValueChange = ::onValueChange,
- isConfirmEnabled = false,
- onConfirmClick = ::onConfirmClick,
- error = null,
- ),
- )
+ val state: StateFlow
+ field = MutableStateFlow(
+ value = RenameWalletUM(
+ walletNameValue = TextFieldValue(text = params.currentName),
+ onValueChange = ::onValueChange,
+ isConfirmEnabled = false,
+ onConfirmClick = ::onConfirmClick,
+ error = null,
+ ),
+ )
fun dismiss() {
params.onDismiss()
}
private fun onValueChange(value: TextFieldValue) {
- _state.update {
+ state.update { currentState ->
val newName = value.text
- it.copy(
+ currentState.copy(
walletNameValue = value,
isConfirmEnabled = getConfirmButtonAvailability(newName),
error = getErrorOrNull(newName),
@@ -100,12 +99,12 @@ internal class RenameWalletModel @Inject constructor(
private fun onConfirmClick() {
modelScope.launch {
withContext(NonCancellable) {
- val newName = _state.value.walletNameValue
+ val newName = state.value.walletNameValue
renameWalletUseCase(userWalletId = params.userWalletId, name = newName.text)
- .onLeft {
- Timber.e("Unable to rename wallet: $it")
- showRenameWalletError(error = it, updatedName = newName.text)
+ .onLeft { error ->
+ Timber.e("Unable to rename wallet: $error")
+ showRenameWalletError(error = error, updatedName = newName.text)
}
}
}
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 6b788a5b3e..4c6713f424 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
@@ -74,7 +74,7 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent {
accountsUM = previewAccounts(),
cardItem = previewCardBlock(),
),
- requestPushNotificationsPermission = false,
+ hasRequestPushNotificationsPermission = false,
onPushNotificationPermissionGranted = {},
accountReorderUM = AccountReorderUM(
isDragEnabled = true,
@@ -83,17 +83,17 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent {
),
)
- private fun previewAccounts() = buildList {
+ private fun previewAccounts() = listOf(
WalletSettingsAccountsUM.Header(
id = "accounts_header",
text = resourceReference(R.string.common_accounts),
- ).let(::add)
- add(WalletSettingsAccountsUM.Account(accountItem))
+ ),
+ WalletSettingsAccountsUM.Account(accountItem),
WalletSettingsAccountsUM.Footer(
id = "accounts_footer",
addAccount = AddAccountUM(
title = resourceReference(R.string.account_form_title_create),
- addAccountEnabled = true,
+ isAddAccountEnabled = true,
onAddAccountClick = {},
),
archivedAccounts = BlockUM(
@@ -101,10 +101,10 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent {
iconRes = R.drawable.ic_archive_24,
onClick = {},
),
- showDescription = true,
+ shouldShowDescription = true,
description = resourceReference(R.string.account_reorder_description),
- ).let(::add)
- }
+ ),
+ )
private fun previewCardBlock() = WalletSettingsItemUM.CardBlock(
id = "wallet_name",
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 dd53d06711..668efd566b 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
@@ -74,13 +74,13 @@ internal sealed class WalletSettingsAccountsUM : WalletSettingsItemUM() {
override val id: String,
val addAccount: AddAccountUM,
val archivedAccounts: BlockUM?,
- val showDescription: Boolean,
+ val shouldShowDescription: Boolean,
val description: TextReference,
) : WalletSettingsAccountsUM() {
data class AddAccountUM(
val title: TextReference,
- val addAccountEnabled: Boolean,
+ val isAddAccountEnabled: Boolean,
val onAddAccountClick: () -> Unit,
)
}
diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/entity/WalletSettingsUM.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/entity/WalletSettingsUM.kt
index cb71750ba1..f0b63d53d0 100644
--- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/entity/WalletSettingsUM.kt
+++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/entity/WalletSettingsUM.kt
@@ -7,11 +7,11 @@ import kotlinx.collections.immutable.PersistentList
internal data class WalletSettingsUM(
val popBack: () -> Unit,
val items: PersistentList,
- val requestPushNotificationsPermission: Boolean = false,
+ val hasRequestPushNotificationsPermission: Boolean = false,
val onPushNotificationPermissionGranted: (Boolean) -> Unit,
val accountReorderUM: AccountReorderUM,
val isWalletBackedUp: Boolean = true,
- val walletUpgradeDismissed: Boolean = false,
+ val isWalletUpgradeDismissed: Boolean = false,
)
internal data class AccountReorderUM(
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 830597bcaf..3ae50762c4 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
@@ -98,10 +98,10 @@ internal class WalletSettingsModel @Inject constructor(
value = WalletSettingsUM(
popBack = router::pop,
items = persistentListOf(),
- requestPushNotificationsPermission = false,
+ hasRequestPushNotificationsPermission = false,
onPushNotificationPermissionGranted = ::onPushNotificationPermissionGranted,
isWalletBackedUp = true,
- walletUpgradeDismissed = false,
+ isWalletUpgradeDismissed = false,
accountReorderUM = AccountReorderUM(
isDragEnabled = false,
onMove = ::onAccountReorder,
@@ -124,7 +124,7 @@ internal class WalletSettingsModel @Inject constructor(
.conflate(),
flow3 = isUpgradeWalletNotificationEnabledUseCase(params.userWalletId),
flow4 = walletCardItemDelegate.cardItemFlow(wallet),
- flow5 = accountItemsDelegate.loadAccount(),
+ flow5 = accountItemsDelegate.loadAccount(wallet),
) { nftEnabled, notificationsEnabled, isUpgradeNotificationEnabled, cardItem, accountList ->
val isWalletBackedUp = when (wallet) {
is UserWallet.Hot -> wallet.backedUp
@@ -182,7 +182,7 @@ internal class WalletSettingsModel @Inject constructor(
isUpgradeNotificationEnabled: Boolean,
accountList: List,
): PersistentList {
- val accountsFeatureEnabled = accountsFeatureToggles.isFeatureEnabled
+ val isAccountsFeatureEnabled = accountsFeatureToggles.isFeatureEnabled
val isMultiCurrency = when (userWallet) {
is UserWallet.Cold -> userWallet.isMultiCurrency
is UserWallet.Hot -> true
@@ -198,7 +198,7 @@ internal class WalletSettingsModel @Inject constructor(
is UserWallet.Cold -> userWallet.scanResponse.card.backupStatus == CardDTO.BackupStatus.NoBackup
is UserWallet.Hot -> false
},
- isManageTokensAvailable = if (accountsFeatureEnabled) {
+ isManageTokensAvailable = if (isAccountsFeatureEnabled) {
isMultiCurrency && accountList.count { it is WalletSettingsAccountsUM.Account } == 0
} else {
isMultiCurrency
@@ -221,7 +221,7 @@ internal class WalletSettingsModel @Inject constructor(
router.push(
AppRoute.ManageTokens(
source = Source.SETTINGS,
- portfolioId = if (accountsFeatureEnabled) {
+ portfolioId = if (isAccountsFeatureEnabled) {
PortfolioId(
accountId = AccountId.forMainCryptoPortfolio(userWalletId = userWallet.walletId),
)
@@ -244,8 +244,8 @@ internal class WalletSettingsModel @Inject constructor(
}
private fun forgetWallet() = modelScope.launch {
- val hasUserWallets = deleteWalletUseCase(params.userWalletId).getOrElse {
- Timber.e("Unable to delete wallet: $it")
+ val hasUserWallets = deleteWalletUseCase(params.userWalletId).getOrElse { error ->
+ Timber.e("Unable to delete wallet: $error")
messageSender.send(
message = SnackbarMessage(resourceReference(R.string.common_unknown_error)),
@@ -293,7 +293,7 @@ internal class WalletSettingsModel @Inject constructor(
if (isChecked) {
state.update { value ->
value.copy(
- requestPushNotificationsPermission = true,
+ hasRequestPushNotificationsPermission = true,
)
}
} else {
@@ -315,7 +315,7 @@ internal class WalletSettingsModel @Inject constructor(
analyticsEventHandler.send(PushNotificationAnalyticEvents.PermissionStatus(isGranted))
state.update { value ->
value.copy(
- requestPushNotificationsPermission = false,
+ hasRequestPushNotificationsPermission = false,
)
}
if (isGranted) {
@@ -449,8 +449,8 @@ internal class WalletSettingsModel @Inject constructor(
}
private fun onAccountDragStopped() {
- val accountIds = state.value.items.mapNotNull {
- val id = (it as? WalletSettingsAccountsUM.Account)?.state?.id
+ val accountIds = state.value.items.mapNotNull { itemUM ->
+ val id = (itemUM as? WalletSettingsAccountsUM.Account)?.state?.id
?: return@mapNotNull null
AccountId.forCryptoPortfolio(userWalletId = params.userWalletId, value = id).getOrNull()
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 ebb484971d..3041a0c1c6 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
@@ -393,7 +393,7 @@ private fun AccountsFooter(model: WalletSettingsAccountsUM.Footer, modifier: Mod
}
}
}
- if (!model.showDescription) return
+ if (!model.shouldShowDescription) return
SpacerH8()
Text(
modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing12),
@@ -411,7 +411,7 @@ private fun AddAccountRow(model: WalletSettingsAccountsUM.Footer.AddAccountUM, m
val iconTint: Color
val backgroundColor: Color
val textColor: Color
- if (model.addAccountEnabled) {
+ if (model.isAddAccountEnabled) {
iconTint = TangemTheme.colors.icon.accent
backgroundColor = TangemTheme.colors.icon.accent.copy(alpha = 0.1f)
textColor = TangemTheme.colors.text.accent
diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt
index 8d868805a3..c9458a072e 100644
--- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt
+++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt
@@ -22,7 +22,9 @@ import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
import com.tangem.domain.models.account.Account
import com.tangem.domain.models.account.AccountId
import com.tangem.domain.models.account.AccountStatus
+import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
+import com.tangem.domain.wallets.extension.isAccountsSupported
import com.tangem.feature.walletsettings.component.WalletSettingsComponent
import com.tangem.feature.walletsettings.entity.WalletSettingsAccountsUM
import com.tangem.feature.walletsettings.entity.WalletSettingsAccountsUM.Footer.AddAccountUM
@@ -48,8 +50,8 @@ internal class AccountItemsDelegate @Inject constructor(
private val userWalletId = paramsContainer.require().userWalletId
- fun loadAccount(): Flow> {
- if (!accountsFeatureToggles.isFeatureEnabled) return flowOf(emptyList())
+ fun loadAccount(wallet: UserWallet): Flow> {
+ if (!accountsFeatureToggles.isFeatureEnabled || !wallet.isAccountsSupported) return flowOf(emptyList())
return combine(
flow = singleAccountStatusListSupplier(userWalletId),
@@ -83,26 +85,29 @@ internal class AccountItemsDelegate @Inject constructor(
}
val accounts = accountStatusList.accountStatuses
- WalletSettingsAccountsUM.Header(
+
+ val header = WalletSettingsAccountsUM.Header(
id = "accounts_header",
text = resourceReference(R.string.common_accounts),
- ).let(::add)
+ )
+
+ add(header)
if (isAccountsMode) {
addAll(accounts.map(::mapAccount).applySortingOrder(order = accountsOrder))
}
- val addAccountEnabled = accounts.size < AccountList.MAX_ACCOUNTS_COUNT
- val showDescription = accounts.size > 1
+ val isAddAccountEnabled = accounts.size < AccountList.MAX_ACCOUNTS_COUNT
+ val shouldShowDescription = accounts.size > 1
val isArchivedAccountsEnabled = accountStatusList.accountStatuses.size != accountStatusList.totalAccounts
- WalletSettingsAccountsUM.Footer(
+ val footer = WalletSettingsAccountsUM.Footer(
id = "accounts_footer",
addAccount = AddAccountUM(
title = resourceReference(R.string.account_form_title_create),
- addAccountEnabled = addAccountEnabled,
+ isAddAccountEnabled = isAddAccountEnabled,
onAddAccountClick = {
- if (addAccountEnabled) openAddAccount(userWalletId) else canNotAddAccountDialog()
+ if (isAddAccountEnabled) openAddAccount(userWalletId) else canNotAddAccountDialog()
},
),
archivedAccounts = if (isArchivedAccountsEnabled) {
@@ -114,9 +119,11 @@ internal class AccountItemsDelegate @Inject constructor(
} else {
null
},
- showDescription = showDescription,
+ shouldShowDescription = shouldShowDescription,
description = resourceReference(R.string.account_reorder_description),
- ).let(::add)
+ )
+
+ add(footer)
}
private fun List.applySortingOrder(
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 1b9204152a..9ea22eaee1 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
@@ -181,7 +181,7 @@ internal class ItemsBuilder @Inject constructor(
val isHotWallet = userWallet is UserWallet.Hot
if (isHotWallet) {
val hasBackup = userWallet.backedUp
- BlockUM(
+ val backupBlock = BlockUM(
text = resourceReference(R.string.common_backup),
iconRes = R.drawable.ic_more_cards_24,
onClick = { router.push(AppRoute.WalletBackup(userWalletId)) },
@@ -195,39 +195,49 @@ internal class ItemsBuilder @Inject constructor(
),
)
},
- ).let(::add)
+ )
+
+ add(backupBlock)
}
if (isManageTokensAvailable) {
- BlockUM(
+ val manageTokensBlock = BlockUM(
text = resourceReference(R.string.add_tokens_title),
iconRes = R.drawable.ic_tether_24,
onClick = onManageTokensClick,
- ).let(::add)
+ )
+
+ add(manageTokensBlock)
}
if (isLinkMoreCardsAvailable) {
- BlockUM(
+ val linkMoreCardsBlock = BlockUM(
text = resourceReference(R.string.details_row_title_create_backup),
iconRes = R.drawable.ic_more_cards_24,
onClick = onLinkMoreCardsClick,
- ).let(::add)
+ )
+
+ add(linkMoreCardsBlock)
}
if (!isHotWallet) {
- BlockUM(
+ val deviceSettingsBlock = BlockUM(
text = resourceReference(R.string.card_settings_title),
iconRes = R.drawable.ic_card_settings_24,
onClick = { router.push(AppRoute.CardSettings(userWalletId)) },
- ).let(::add)
+ )
+
+ add(deviceSettingsBlock)
}
if (isReferralAvailable) {
- BlockUM(
+ val referralBlock = BlockUM(
text = resourceReference(R.string.details_referral_title),
iconRes = R.drawable.ic_add_friends_24,
onClick = onReferralClick,
- ).let(::add)
+ )
+
+ add(referralBlock)
}
}.toImmutableList(),
)