Updated on 2026-08-14
This commit is contained in:
parent
21ef61585b
commit
154de76c6d
37 changed files with 695 additions and 989 deletions
|
|
@ -25,6 +25,7 @@ dependencies {
|
|||
implementation(projects.common.routing)
|
||||
|
||||
/* Project - Domain */
|
||||
implementation(projects.domain.legacy)
|
||||
implementation(projects.domain.wallets)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.feature.walletsettings.component.preview
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.tangem.core.decompose.navigation.DummyRouter
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.walletsettings.component.WalletSettingsComponent
|
||||
import com.tangem.feature.walletsettings.entity.WalletSettingsUM
|
||||
import com.tangem.feature.walletsettings.ui.WalletSettingsScreen
|
||||
|
|
@ -15,7 +16,9 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent {
|
|||
items = ItemsBuilder(
|
||||
router = DummyRouter(),
|
||||
).buildItems(
|
||||
walletName = "My wallet",
|
||||
userWalletId = UserWalletId("011"),
|
||||
userWalletName = "My Wallet",
|
||||
isReferralAvailable = true,
|
||||
renameWallet = {},
|
||||
forgetWallet = {},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.tangem.core.decompose.navigation.Router
|
|||
import com.tangem.core.decompose.ui.UiMessageSender
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.message.SnackbarMessage
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.domain.wallets.usecase.DeleteWalletUseCase
|
||||
|
|
@ -75,7 +76,9 @@ internal class WalletSettingsModel @Inject constructor(
|
|||
userWallet: UserWallet,
|
||||
dialogNavigation: SlotNavigation<DialogConfig>,
|
||||
): PersistentList<WalletSettingsItemUM> = itemsBuilder.buildItems(
|
||||
walletName = userWallet.name,
|
||||
userWalletId = userWallet.walletId,
|
||||
userWalletName = userWallet.name,
|
||||
isReferralAvailable = userWallet.cardTypesResolver.isTangemWallet(),
|
||||
renameWallet = { openRenameWalletDialog(userWallet, dialogNavigation) },
|
||||
forgetWallet = { forgetWallet(userWallet.walletId) },
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ import com.tangem.core.decompose.navigation.Router
|
|||
import com.tangem.core.ui.components.block.model.BlockUM
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.walletsettings.entity.WalletSettingsItemUM
|
||||
import com.tangem.feature.walletsettings.impl.R
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import javax.inject.Inject
|
||||
|
||||
@ComponentScoped
|
||||
|
|
@ -16,9 +19,15 @@ internal class ItemsBuilder @Inject constructor(
|
|||
private val router: Router,
|
||||
) {
|
||||
|
||||
fun buildItems(walletName: String, forgetWallet: () -> Unit, renameWallet: () -> Unit) = persistentListOf(
|
||||
buildNameItem(walletName, renameWallet),
|
||||
buildCardItem(),
|
||||
fun buildItems(
|
||||
userWalletId: UserWalletId,
|
||||
userWalletName: String,
|
||||
isReferralAvailable: Boolean,
|
||||
forgetWallet: () -> Unit,
|
||||
renameWallet: () -> Unit,
|
||||
): PersistentList<WalletSettingsItemUM> = persistentListOf(
|
||||
buildNameItem(userWalletName, renameWallet),
|
||||
buildCardItem(userWalletId, isReferralAvailable),
|
||||
buildForgetItem(forgetWallet),
|
||||
)
|
||||
|
||||
|
|
@ -29,37 +38,37 @@ internal class ItemsBuilder @Inject constructor(
|
|||
onClick = renameWallet,
|
||||
)
|
||||
|
||||
private fun buildCardItem() = WalletSettingsItemUM.WithItems(
|
||||
id = "card",
|
||||
blocks = buildCardBlocks(),
|
||||
description = resourceReference(R.string.settings_card_settings_footer),
|
||||
)
|
||||
private fun buildCardItem(userWalletId: UserWalletId, isReferralAvailable: Boolean) =
|
||||
WalletSettingsItemUM.WithItems(
|
||||
id = "card",
|
||||
description = resourceReference(R.string.settings_card_settings_footer),
|
||||
blocks = buildList {
|
||||
BlockUM(
|
||||
text = resourceReference(R.string.card_settings_title),
|
||||
iconRes = R.drawable.ic_card_settings_24,
|
||||
onClick = { router.push(AppRoute.CardSettings(userWalletId)) },
|
||||
).let(::add)
|
||||
|
||||
private fun buildCardBlocks() = persistentListOf(
|
||||
BlockUM(
|
||||
text = resourceReference(R.string.card_settings_title),
|
||||
iconRes = R.drawable.ic_card_settings_24,
|
||||
onClick = { router.push(AppRoute.CardSettings) },
|
||||
),
|
||||
BlockUM(
|
||||
text = resourceReference(R.string.referral_title),
|
||||
iconRes = R.drawable.ic_add_friends_24,
|
||||
onClick = { router.push(AppRoute.ReferralProgram) },
|
||||
),
|
||||
)
|
||||
if (isReferralAvailable) {
|
||||
BlockUM(
|
||||
text = resourceReference(R.string.referral_title),
|
||||
iconRes = R.drawable.ic_add_friends_24,
|
||||
onClick = { router.push(AppRoute.ReferralProgram(userWalletId)) },
|
||||
).let(::add)
|
||||
}
|
||||
}.toImmutableList(),
|
||||
)
|
||||
|
||||
private fun buildForgetItem(forgetWallet: () -> Unit) = WalletSettingsItemUM.WithItems(
|
||||
id = "forget",
|
||||
blocks = buildForgetBlocks(forgetWallet),
|
||||
description = resourceReference(R.string.settings_forget_wallet_footer),
|
||||
)
|
||||
|
||||
private fun buildForgetBlocks(forgetWallet: () -> Unit) = persistentListOf(
|
||||
BlockUM(
|
||||
text = resourceReference(R.string.settings_forget_wallet),
|
||||
iconRes = R.drawable.ic_card_foget_24,
|
||||
onClick = forgetWallet,
|
||||
accentType = BlockUM.AccentType.WARNING,
|
||||
blocks = persistentListOf(
|
||||
BlockUM(
|
||||
text = resourceReference(R.string.settings_forget_wallet),
|
||||
iconRes = R.drawable.ic_card_foget_24,
|
||||
onClick = forgetWallet,
|
||||
accentType = BlockUM.AccentType.WARNING,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue