Updated on 2026-08-14
This commit is contained in:
parent
a41dd9aace
commit
41fb5d5bcc
55 changed files with 709 additions and 173 deletions
|
|
@ -15,7 +15,7 @@ interface AccountCreateEditComponent : ComposableContentComponent {
|
|||
) : Params
|
||||
|
||||
data class Edit(
|
||||
val account: Account,
|
||||
val account: Account.CryptoPortfolio,
|
||||
) : Params
|
||||
}
|
||||
}
|
||||
|
|
@ -7,5 +7,5 @@ import com.tangem.domain.models.account.Account
|
|||
interface AccountDetailsComponent : ComposableContentComponent {
|
||||
interface Factory : ComponentFactory<Params, AccountDetailsComponent>
|
||||
|
||||
data class Params(val account: Account)
|
||||
data class Params(val account: Account.CryptoPortfolio)
|
||||
}
|
||||
|
|
@ -25,7 +25,6 @@ import com.tangem.domain.account.usecase.GetUnoccupiedAccountIndexUseCase
|
|||
import com.tangem.domain.account.usecase.UpdateCryptoPortfolioUseCase
|
||||
import com.tangem.domain.models.account.CryptoPortfolioIcon
|
||||
import com.tangem.domain.models.account.DerivationIndex
|
||||
import com.tangem.domain.models.account.derivationIndex
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.features.account.AccountCreateEditComponent
|
||||
import com.tangem.features.account.analytics.AccountSettingsAnalyticEvents
|
||||
|
|
@ -73,7 +72,7 @@ internal class AccountCreateEditModel @Inject constructor(
|
|||
when (params) {
|
||||
is AccountCreateEditComponent.Params.Create -> updateDerivationInfo(userWalletId = params.userWalletId)
|
||||
is AccountCreateEditComponent.Params.Edit -> {
|
||||
val derivationIndex = params.account.derivationIndex?.value
|
||||
val derivationIndex = params.account.derivationIndex.value
|
||||
val event = AccountSettingsAnalyticEvents.AccountEditScreenOpened(derivationIndex)
|
||||
analyticsEventHandler.send(event)
|
||||
}
|
||||
|
|
@ -170,7 +169,7 @@ internal class AccountCreateEditModel @Inject constructor(
|
|||
val icon = CryptoPortfolioIconConverter.convertBack(state.account.portfolioIcon)
|
||||
val isNewName = name != params.account.accountName
|
||||
val isNewIcon = icon != params.account.portfolioIcon
|
||||
val derivationIndex = params.account.derivationIndex?.value
|
||||
val derivationIndex = params.account.derivationIndex.value
|
||||
analyticsEventHandler.send(AccountSettingsAnalyticEvents.ButtonSave(name, icon, derivationIndex))
|
||||
|
||||
uiState.value = uiState.value.toggleProgress(showProgress = true)
|
||||
|
|
@ -182,7 +181,7 @@ internal class AccountCreateEditModel @Inject constructor(
|
|||
uiState.value = uiState.value.toggleProgress(showProgress = false)
|
||||
|
||||
result
|
||||
.onLeft { error -> handleEditAccountError(error, params.account.derivationIndex?.value) }
|
||||
.onLeft { error -> handleEditAccountError(error, params.account.derivationIndex.value) }
|
||||
.onRight {
|
||||
showMessage(R.string.account_edit_success_message)
|
||||
router.pop()
|
||||
|
|
|
|||
|
|
@ -14,12 +14,10 @@ import com.tangem.core.ui.extensions.resourceReference
|
|||
import com.tangem.core.ui.message.DialogMessage
|
||||
import com.tangem.core.ui.message.EventMessageAction
|
||||
import com.tangem.core.ui.message.ToastMessage
|
||||
import com.tangem.domain.account.producer.SingleAccountProducer
|
||||
import com.tangem.domain.account.status.usecase.ArchiveCryptoPortfolioUseCase
|
||||
import com.tangem.domain.account.supplier.SingleAccountSupplier
|
||||
import com.tangem.domain.models.PortfolioId
|
||||
import com.tangem.domain.models.account.Account
|
||||
import com.tangem.domain.models.account.derivationIndex
|
||||
import com.tangem.domain.models.wallet.isMultiCurrency
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.features.account.AccountDetailsComponent
|
||||
|
|
@ -54,29 +52,29 @@ internal class AccountDetailsModel @Inject constructor(
|
|||
|
||||
init {
|
||||
analyticsEventHandler.send(AccountSettingsAnalyticEvents.AccountSettingsScreenOpened())
|
||||
singleAccountSupplier(SingleAccountProducer.Params(accountId))
|
||||
singleAccountSupplier.filterCryptoPortfolioAccount(accountId)
|
||||
.onEach { account -> uiState.update { buildUI(account) } }
|
||||
.launchIn(modelScope)
|
||||
}
|
||||
|
||||
private fun onEditAccountClick(account: Account) {
|
||||
private fun onEditAccountClick(account: Account.CryptoPortfolio) {
|
||||
analyticsEventHandler.send(AccountSettingsAnalyticEvents.ButtonEdit())
|
||||
router.push(AppRoute.EditAccount(account))
|
||||
}
|
||||
|
||||
private fun onManageTokensClick(account: Account) {
|
||||
private fun onManageTokensClick(account: Account.CryptoPortfolio) {
|
||||
val route = AppRoute.ManageTokens(
|
||||
source = AppRoute.ManageTokens.Source.ACCOUNT,
|
||||
portfolioId = PortfolioId(account.accountId),
|
||||
)
|
||||
analyticsEventHandler.send(
|
||||
AccountSettingsAnalyticEvents.ButtonManageTokens(account.derivationIndex?.value),
|
||||
AccountSettingsAnalyticEvents.ButtonManageTokens(account.derivationIndex.value),
|
||||
)
|
||||
router.push(route)
|
||||
}
|
||||
|
||||
private fun onArchiveAccountClick() {
|
||||
val accountDerivation = params.account.derivationIndex?.value
|
||||
val accountDerivation = params.account.derivationIndex.value
|
||||
val event = AccountSettingsAnalyticEvents.ButtonArchiveAccount(accountDerivation)
|
||||
analyticsEventHandler.send(event)
|
||||
confirmArchiveDialog()
|
||||
|
|
@ -86,7 +84,7 @@ internal class AccountDetailsModel @Inject constructor(
|
|||
val secondAction = EventMessageAction(
|
||||
title = resourceReference(R.string.common_cancel),
|
||||
onClick = {
|
||||
val accountDerivation = params.account.derivationIndex?.value
|
||||
val accountDerivation = params.account.derivationIndex.value
|
||||
val event = AccountSettingsAnalyticEvents.ButtonCancelAccountArchivation(accountDerivation)
|
||||
analyticsEventHandler.send(event)
|
||||
},
|
||||
|
|
@ -107,7 +105,7 @@ internal class AccountDetailsModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun archiveCryptoPortfolio() = modelScope.launch {
|
||||
val accountDerivation = params.account.derivationIndex?.value
|
||||
val accountDerivation = params.account.derivationIndex.value
|
||||
val event = AccountSettingsAnalyticEvents.ButtonArchiveAccountConfirmation(accountDerivation)
|
||||
analyticsEventHandler.send(event)
|
||||
uiState.update { it.toggleProgress(true) }
|
||||
|
|
@ -128,7 +126,7 @@ internal class AccountDetailsModel @Inject constructor(
|
|||
val event = AccountSettingsAnalyticEvents.AccountError(
|
||||
source = AccountSettingsAnalyticEvents.Source.ARCHIVE,
|
||||
error = error.tag,
|
||||
accountDerivation = params.account.derivationIndex?.value,
|
||||
accountDerivation = params.account.derivationIndex.value,
|
||||
)
|
||||
analyticsEventHandler.send(event)
|
||||
val titleRes: Int
|
||||
|
|
@ -155,16 +153,13 @@ internal class AccountDetailsModel @Inject constructor(
|
|||
messageSender.send(dialogMessage)
|
||||
}
|
||||
|
||||
private fun buildUI(account: Account): AccountDetailsUM {
|
||||
val archiveMode = when (account) {
|
||||
is Account.CryptoPortfolio -> when (account.isMainAccount) {
|
||||
true -> ArchiveMode.None
|
||||
false -> ArchiveMode.Available(
|
||||
onArchiveAccountClick = ::onArchiveAccountClick,
|
||||
isLoading = false,
|
||||
)
|
||||
}
|
||||
is Account.Payment -> TODO("[REDACTED_JIRA]")
|
||||
private fun buildUI(account: Account.CryptoPortfolio): AccountDetailsUM {
|
||||
val archiveMode = when (account.isMainAccount) {
|
||||
true -> ArchiveMode.None
|
||||
false -> ArchiveMode.Available(
|
||||
onArchiveAccountClick = ::onArchiveAccountClick,
|
||||
isLoading = false,
|
||||
)
|
||||
}
|
||||
val isMultiCurrency = getUserWalletUseCase(account.accountId.userWalletId).getOrNull()
|
||||
?.isMultiCurrency == true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue