From d7f086e1d992e54ad3393e2f18730703c7cd5c59 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 9 Feb 2024 13:40:19 +0100 Subject: [PATCH] Updated on 2026-08-14 --- .../state/AddCustomTokenState.kt | 2 +- .../state/AddCustomTokenWarning.kt | 2 +- .../state/ButtonState.kt | 2 +- .../state/ChooseDerivationState.kt | 2 +- .../state/ChooseNetworkState.kt | 2 +- .../state/CustomTokenData.kt | 2 +- .../state/Derivation.kt | 2 +- .../state/EnterCustomDerivationState.kt | 2 +- .../state/TextFieldState.kt | 2 +- .../factory/AddCustomTokenStateFactory.kt} | 10 ++-- ...stomTokenStateToCryptoCurrencyConverter.kt | 8 +-- ...ntractAddressToCustomTokenDataConverter.kt | 10 ++-- .../FoundTokenToCustomTokenDataConverter.kt | 10 ++-- .../NetworkToNetworkItemStateConverter.kt | 2 +- .../previewdata/AddCustomTokenPreviewData.kt | 4 +- .../ChooseDerivationPreviewData.kt | 6 +-- .../ChooseNetworkCustomPreviewData.kt | 4 +- .../ui/AddCustomTokenScreen.kt} | 16 +++--- .../ui/ChooseDerivationScreen.kt | 6 +-- .../ui/ChooseNetworkCustomScreen.kt | 6 +-- .../ui/CustomDerivationDialog.kt | 4 +- .../ui/CustomTokenChooseWalletScreen.kt} | 2 +- .../ui/TokenTextField.kt | 4 +- .../viewmodels/AddCustomTokenClickIntents.kt} | 6 +-- .../viewmodels/AddCustomTokenViewModel.kt} | 37 ++++++++------ .../viewmodels/ManageTokensViewModel.kt | 2 +- .../router/DefaultManageTokensRouter.kt | 49 ++++++++++--------- .../router/InnerManageTokensRouter.kt | 14 ++++-- .../presentation/router/ManageTokensRoute.kt | 10 ++-- 29 files changed, 119 insertions(+), 109 deletions(-) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/AddCustomTokenState.kt (91%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/AddCustomTokenWarning.kt (94%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/ButtonState.kt (58%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/ChooseDerivationState.kt (86%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/ChooseNetworkState.kt (85%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/CustomTokenData.kt (87%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/Derivation.kt (74%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/EnterCustomDerivationState.kt (80%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/TextFieldState.kt (93%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens/state/factory/CustomTokensStateFactory.kt => addcustomtoken/state/factory/AddCustomTokenStateFactory.kt} (97%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/factory/AddCustomTokenStateToCryptoCurrencyConverter.kt (87%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/factory/ContractAddressToCustomTokenDataConverter.kt (77%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/factory/FoundTokenToCustomTokenDataConverter.kt (78%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/factory/NetworkToNetworkItemStateConverter.kt (91%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/previewdata/AddCustomTokenPreviewData.kt (92%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/previewdata/ChooseDerivationPreviewData.kt (83%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/state/previewdata/ChooseNetworkCustomPreviewData.kt (85%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens/ui/CustomTokensScreen.kt => addcustomtoken/ui/AddCustomTokenScreen.kt} (93%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/ui/ChooseDerivationScreen.kt (94%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/ui/ChooseNetworkCustomScreen.kt (93%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/ui/CustomDerivationDialog.kt (90%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens/ui/CustomTokensChooseWalletScreen.kt => addcustomtoken/ui/CustomTokenChooseWalletScreen.kt} (91%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens => addcustomtoken}/ui/TokenTextField.kt (94%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens/viewmodels/CustomTokensClickIntents.kt => addcustomtoken/viewmodels/AddCustomTokenClickIntents.kt} (83%) rename features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/{customtokens/viewmodels/CustomTokensViewModel.kt => addcustomtoken/viewmodels/AddCustomTokenViewModel.kt} (93%) diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/AddCustomTokenState.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/AddCustomTokenState.kt similarity index 91% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/AddCustomTokenState.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/AddCustomTokenState.kt index 5c37331d11..0eafc00654 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/AddCustomTokenState.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/AddCustomTokenState.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state import com.tangem.core.ui.event.StateEvent import com.tangem.core.ui.event.consumedEvent diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/AddCustomTokenWarning.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/AddCustomTokenWarning.kt similarity index 94% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/AddCustomTokenWarning.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/AddCustomTokenWarning.kt index fdca691ce8..690178c20d 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/AddCustomTokenWarning.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/AddCustomTokenWarning.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resourceReference diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ButtonState.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ButtonState.kt similarity index 58% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ButtonState.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ButtonState.kt index 0b1412cc0b..42b515ea20 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ButtonState.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ButtonState.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state internal data class ButtonState( val isEnabled: Boolean, diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ChooseDerivationState.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ChooseDerivationState.kt similarity index 86% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ChooseDerivationState.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ChooseDerivationState.kt index c9bb1eefc4..047fae161d 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ChooseDerivationState.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ChooseDerivationState.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state import kotlinx.collections.immutable.ImmutableList diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ChooseNetworkState.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ChooseNetworkState.kt similarity index 85% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ChooseNetworkState.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ChooseNetworkState.kt index 1a09c93ec3..56b993010b 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/ChooseNetworkState.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/ChooseNetworkState.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state import com.tangem.managetokens.presentation.common.state.NetworkItemState import kotlinx.collections.immutable.ImmutableList diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/CustomTokenData.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/CustomTokenData.kt similarity index 87% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/CustomTokenData.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/CustomTokenData.kt index a586ec848a..ec93de1d4c 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/CustomTokenData.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/CustomTokenData.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state internal data class CustomTokenData( val contractAddressTextField: TextFieldState, diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/Derivation.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/Derivation.kt similarity index 74% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/Derivation.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/Derivation.kt index cb06fa67b7..69f41a5f08 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/Derivation.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/Derivation.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state internal data class Derivation( val networkName: String, diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/EnterCustomDerivationState.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/EnterCustomDerivationState.kt similarity index 80% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/EnterCustomDerivationState.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/EnterCustomDerivationState.kt index aefe21b295..3b6ca1c57a 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/EnterCustomDerivationState.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/EnterCustomDerivationState.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state internal data class EnterCustomDerivationState( val value: String, diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/TextFieldState.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/TextFieldState.kt similarity index 93% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/TextFieldState.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/TextFieldState.kt index 3014818228..2e7f2b1168 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/TextFieldState.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/TextFieldState.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state +package com.tangem.managetokens.presentation.addcustomtoken.state internal sealed class TextFieldState { object Loading : TextFieldState() diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/CustomTokensStateFactory.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/AddCustomTokenStateFactory.kt similarity index 97% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/CustomTokensStateFactory.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/AddCustomTokenStateFactory.kt index f32d3f3e88..6e51737162 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/CustomTokensStateFactory.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/AddCustomTokenStateFactory.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state.factory +package com.tangem.managetokens.presentation.addcustomtoken.state.factory import com.tangem.core.ui.event.consumedEvent import com.tangem.core.ui.event.triggeredEvent @@ -7,17 +7,17 @@ import com.tangem.domain.tokens.model.Network import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.models.UserWalletId import com.tangem.managetokens.presentation.common.state.* -import com.tangem.managetokens.presentation.customtokens.state.* -import com.tangem.managetokens.presentation.customtokens.viewmodels.CustomTokensClickIntents +import com.tangem.managetokens.presentation.addcustomtoken.state.* +import com.tangem.managetokens.presentation.addcustomtoken.viewmodels.AddCustomTokenClickIntents import com.tangem.utils.Provider import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentSetOf import kotlinx.collections.immutable.toPersistentList import kotlinx.collections.immutable.toPersistentSet -internal class CustomTokensStateFactory( +internal class AddCustomTokenStateFactory( private val currentStateProvider: Provider, - private val clickIntents: CustomTokensClickIntents, + private val clickIntents: AddCustomTokenClickIntents, ) { fun getInitialState(): AddCustomTokenState { diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/AddCustomTokenStateToCryptoCurrencyConverter.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/AddCustomTokenStateToCryptoCurrencyConverter.kt similarity index 87% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/AddCustomTokenStateToCryptoCurrencyConverter.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/AddCustomTokenStateToCryptoCurrencyConverter.kt index 15e17fc927..e6e1b2f84e 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/AddCustomTokenStateToCryptoCurrencyConverter.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/AddCustomTokenStateToCryptoCurrencyConverter.kt @@ -1,11 +1,11 @@ -package com.tangem.managetokens.presentation.customtokens.state.factory +package com.tangem.managetokens.presentation.addcustomtoken.state.factory import com.tangem.data.tokens.utils.CryptoCurrencyFactory import com.tangem.domain.common.DerivationStyleProvider import com.tangem.domain.tokens.model.CryptoCurrency -import com.tangem.managetokens.presentation.customtokens.state.AddCustomTokenState -import com.tangem.managetokens.presentation.customtokens.state.CustomTokenData -import com.tangem.managetokens.presentation.customtokens.state.TextFieldState +import com.tangem.managetokens.presentation.addcustomtoken.state.AddCustomTokenState +import com.tangem.managetokens.presentation.addcustomtoken.state.CustomTokenData +import com.tangem.managetokens.presentation.addcustomtoken.state.TextFieldState import com.tangem.utils.converter.Converter internal class AddCustomTokenStateToCryptoCurrencyConverter( diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/ContractAddressToCustomTokenDataConverter.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/ContractAddressToCustomTokenDataConverter.kt similarity index 77% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/ContractAddressToCustomTokenDataConverter.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/ContractAddressToCustomTokenDataConverter.kt index 422f3c4f4b..eb0897d370 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/ContractAddressToCustomTokenDataConverter.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/ContractAddressToCustomTokenDataConverter.kt @@ -1,12 +1,12 @@ -package com.tangem.managetokens.presentation.customtokens.state.factory +package com.tangem.managetokens.presentation.addcustomtoken.state.factory -import com.tangem.managetokens.presentation.customtokens.state.CustomTokenData -import com.tangem.managetokens.presentation.customtokens.state.TextFieldState -import com.tangem.managetokens.presentation.customtokens.viewmodels.CustomTokensClickIntents +import com.tangem.managetokens.presentation.addcustomtoken.state.CustomTokenData +import com.tangem.managetokens.presentation.addcustomtoken.state.TextFieldState +import com.tangem.managetokens.presentation.addcustomtoken.viewmodels.AddCustomTokenClickIntents import com.tangem.utils.converter.Converter internal class ContractAddressToCustomTokenDataConverter( - private val clickIntents: CustomTokensClickIntents, + private val clickIntents: AddCustomTokenClickIntents, ) : Converter { override fun convert(value: String): CustomTokenData { return CustomTokenData( diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/FoundTokenToCustomTokenDataConverter.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/FoundTokenToCustomTokenDataConverter.kt similarity index 78% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/FoundTokenToCustomTokenDataConverter.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/FoundTokenToCustomTokenDataConverter.kt index 3aa06bdd9f..65921700dc 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/FoundTokenToCustomTokenDataConverter.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/FoundTokenToCustomTokenDataConverter.kt @@ -1,13 +1,13 @@ -package com.tangem.managetokens.presentation.customtokens.state.factory +package com.tangem.managetokens.presentation.addcustomtoken.state.factory import com.tangem.domain.tokens.model.FoundToken -import com.tangem.managetokens.presentation.customtokens.state.CustomTokenData -import com.tangem.managetokens.presentation.customtokens.state.TextFieldState -import com.tangem.managetokens.presentation.customtokens.viewmodels.CustomTokensClickIntents +import com.tangem.managetokens.presentation.addcustomtoken.state.CustomTokenData +import com.tangem.managetokens.presentation.addcustomtoken.state.TextFieldState +import com.tangem.managetokens.presentation.addcustomtoken.viewmodels.AddCustomTokenClickIntents import com.tangem.utils.converter.Converter internal class FoundTokenToCustomTokenDataConverter( - private val clickIntents: CustomTokensClickIntents, + private val clickIntents: AddCustomTokenClickIntents, ) : Converter { override fun convert(value: FoundToken): CustomTokenData { return CustomTokenData( diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/NetworkToNetworkItemStateConverter.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/NetworkToNetworkItemStateConverter.kt similarity index 91% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/NetworkToNetworkItemStateConverter.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/NetworkToNetworkItemStateConverter.kt index dee07b42c5..74b4eda971 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/factory/NetworkToNetworkItemStateConverter.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/factory/NetworkToNetworkItemStateConverter.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.state.factory +package com.tangem.managetokens.presentation.addcustomtoken.state.factory import com.tangem.core.ui.extensions.getActiveIconResByNetworkId import com.tangem.domain.tokens.model.Network diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/AddCustomTokenPreviewData.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/AddCustomTokenPreviewData.kt similarity index 92% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/AddCustomTokenPreviewData.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/AddCustomTokenPreviewData.kt index 9be15589aa..96e7bf7379 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/AddCustomTokenPreviewData.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/AddCustomTokenPreviewData.kt @@ -1,8 +1,8 @@ -package com.tangem.managetokens.presentation.customtokens.state.previewdata +package com.tangem.managetokens.presentation.addcustomtoken.state.previewdata import com.tangem.managetokens.presentation.common.state.ChooseWalletState import com.tangem.managetokens.presentation.common.state.WalletState -import com.tangem.managetokens.presentation.customtokens.state.* +import com.tangem.managetokens.presentation.addcustomtoken.state.* import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentSetOf diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/ChooseDerivationPreviewData.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/ChooseDerivationPreviewData.kt similarity index 83% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/ChooseDerivationPreviewData.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/ChooseDerivationPreviewData.kt index 2bb35400d2..c4cfd15483 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/ChooseDerivationPreviewData.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/ChooseDerivationPreviewData.kt @@ -1,7 +1,7 @@ -package com.tangem.managetokens.presentation.customtokens.state.previewdata +package com.tangem.managetokens.presentation.addcustomtoken.state.previewdata -import com.tangem.managetokens.presentation.customtokens.state.ChooseDerivationState -import com.tangem.managetokens.presentation.customtokens.state.Derivation +import com.tangem.managetokens.presentation.addcustomtoken.state.ChooseDerivationState +import com.tangem.managetokens.presentation.addcustomtoken.state.Derivation import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/ChooseNetworkCustomPreviewData.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/ChooseNetworkCustomPreviewData.kt similarity index 85% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/ChooseNetworkCustomPreviewData.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/ChooseNetworkCustomPreviewData.kt index 5618ce7fb4..08987dbadf 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/state/previewdata/ChooseNetworkCustomPreviewData.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/state/previewdata/ChooseNetworkCustomPreviewData.kt @@ -1,8 +1,8 @@ -package com.tangem.managetokens.presentation.customtokens.state.previewdata +package com.tangem.managetokens.presentation.addcustomtoken.state.previewdata import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.state.NetworkItemState -import com.tangem.managetokens.presentation.customtokens.state.ChooseNetworkState +import com.tangem.managetokens.presentation.addcustomtoken.state.ChooseNetworkState import kotlinx.collections.immutable.persistentListOf internal object ChooseNetworkCustomPreviewData { diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomTokensScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/AddCustomTokenScreen.kt similarity index 93% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomTokensScreen.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/AddCustomTokenScreen.kt index ce244c3e85..d3291937f0 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomTokensScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/AddCustomTokenScreen.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.ui +package com.tangem.managetokens.presentation.addcustomtoken.ui import androidx.compose.foundation.background import androidx.compose.foundation.layout.* @@ -27,13 +27,13 @@ import com.tangem.managetokens.presentation.common.ui.ChooseWalletBottomSheetCon import com.tangem.managetokens.presentation.common.ui.EventEffect import com.tangem.managetokens.presentation.common.ui.components.Alert import com.tangem.managetokens.presentation.common.ui.components.SimpleSelectionBlock -import com.tangem.managetokens.presentation.customtokens.state.AddCustomTokenState -import com.tangem.managetokens.presentation.customtokens.state.CustomTokenData -import com.tangem.managetokens.presentation.customtokens.state.TextFieldState -import com.tangem.managetokens.presentation.customtokens.state.previewdata.AddCustomTokenPreviewData +import com.tangem.managetokens.presentation.addcustomtoken.state.AddCustomTokenState +import com.tangem.managetokens.presentation.addcustomtoken.state.CustomTokenData +import com.tangem.managetokens.presentation.addcustomtoken.state.TextFieldState +import com.tangem.managetokens.presentation.addcustomtoken.state.previewdata.AddCustomTokenPreviewData @Composable -internal fun CustomTokensScreen(state: AddCustomTokenState, modifier: Modifier = Modifier) { +internal fun AddCustomTokenScreen(state: AddCustomTokenState, modifier: Modifier = Modifier) { var alertState by remember { mutableStateOf(value = null) } EventEffect( @@ -250,7 +250,7 @@ private fun TokenTextFieldTitle(state: TextFieldState?, title: String) { @Composable private fun Preview_ChooseDerivationScreen_Light() { TangemTheme(isDark = false) { - CustomTokensScreen(state = AddCustomTokenPreviewData.state) + AddCustomTokenScreen(state = AddCustomTokenPreviewData.state) } } @@ -258,6 +258,6 @@ private fun Preview_ChooseDerivationScreen_Light() { @Composable private fun Preview_ChooseDerivationScreen_Dark() { TangemTheme(isDark = true) { - CustomTokensScreen(state = AddCustomTokenPreviewData.state) + AddCustomTokenScreen(state = AddCustomTokenPreviewData.state) } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/ChooseDerivationScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseDerivationScreen.kt similarity index 94% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/ChooseDerivationScreen.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseDerivationScreen.kt index 625ff06edd..3422e1cf8e 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/ChooseDerivationScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseDerivationScreen.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.ui +package com.tangem.managetokens.presentation.addcustomtoken.ui import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -16,8 +16,8 @@ import com.tangem.core.ui.decorations.roundedShapeItemDecoration import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.ui.components.SimpleSelectionBlock -import com.tangem.managetokens.presentation.customtokens.state.ChooseDerivationState -import com.tangem.managetokens.presentation.customtokens.state.previewdata.ChooseDerivationPreviewData +import com.tangem.managetokens.presentation.addcustomtoken.state.ChooseDerivationState +import com.tangem.managetokens.presentation.addcustomtoken.state.previewdata.ChooseDerivationPreviewData @Composable internal fun ChooseDerivationScreen(state: ChooseDerivationState, modifier: Modifier = Modifier) { diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/ChooseNetworkCustomScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseNetworkCustomScreen.kt similarity index 93% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/ChooseNetworkCustomScreen.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseNetworkCustomScreen.kt index c18fac8a6b..4ee903652e 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/ChooseNetworkCustomScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/ChooseNetworkCustomScreen.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.ui +package com.tangem.managetokens.presentation.addcustomtoken.ui import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -16,8 +16,8 @@ import com.tangem.core.ui.decorations.roundedShapeItemDecoration import com.tangem.core.ui.res.TangemTheme import com.tangem.features.managetokens.impl.R import com.tangem.managetokens.presentation.common.ui.components.NetworkItem -import com.tangem.managetokens.presentation.customtokens.state.ChooseNetworkState -import com.tangem.managetokens.presentation.customtokens.state.previewdata.ChooseNetworkCustomPreviewData +import com.tangem.managetokens.presentation.addcustomtoken.state.ChooseNetworkState +import com.tangem.managetokens.presentation.addcustomtoken.state.previewdata.ChooseNetworkCustomPreviewData @Composable internal fun ChooseNetworkCustomScreen(state: ChooseNetworkState, modifier: Modifier = Modifier) { diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomDerivationDialog.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/CustomDerivationDialog.kt similarity index 90% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomDerivationDialog.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/CustomDerivationDialog.kt index db9a76365f..969d7f61fb 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomDerivationDialog.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/CustomDerivationDialog.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.ui +package com.tangem.managetokens.presentation.addcustomtoken.ui import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource @@ -6,7 +6,7 @@ import com.tangem.core.ui.components.AdditionalTextInputDialogParams import com.tangem.core.ui.components.DialogButton import com.tangem.core.ui.components.TextInputDialog import com.tangem.features.managetokens.impl.R -import com.tangem.managetokens.presentation.customtokens.state.EnterCustomDerivationState +import com.tangem.managetokens.presentation.addcustomtoken.state.EnterCustomDerivationState @Composable internal fun CustomDerivationDialog(state: EnterCustomDerivationState) { diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomTokensChooseWalletScreen.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/CustomTokenChooseWalletScreen.kt similarity index 91% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomTokensChooseWalletScreen.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/CustomTokenChooseWalletScreen.kt index 358d2d6841..3b8eb7c2af 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/CustomTokensChooseWalletScreen.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/CustomTokenChooseWalletScreen.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.ui +package com.tangem.managetokens.presentation.addcustomtoken.ui import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.navigationBarsPadding diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/TokenTextField.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/TokenTextField.kt similarity index 94% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/TokenTextField.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/TokenTextField.kt index e5b7eef118..d794ab5890 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/ui/TokenTextField.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/ui/TokenTextField.kt @@ -1,4 +1,4 @@ -package com.tangem.managetokens.presentation.customtokens.ui +package com.tangem.managetokens.presentation.addcustomtoken.ui import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth @@ -16,7 +16,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import com.tangem.core.ui.res.TangemTheme -import com.tangem.managetokens.presentation.customtokens.state.TextFieldState +import com.tangem.managetokens.presentation.addcustomtoken.state.TextFieldState @Composable internal fun TokenTextField( diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/viewmodels/CustomTokensClickIntents.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/viewmodels/AddCustomTokenClickIntents.kt similarity index 83% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/viewmodels/CustomTokensClickIntents.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/viewmodels/AddCustomTokenClickIntents.kt index 2dd2151beb..5a2e8e299b 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/viewmodels/CustomTokensClickIntents.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/viewmodels/AddCustomTokenClickIntents.kt @@ -1,10 +1,10 @@ -package com.tangem.managetokens.presentation.customtokens.viewmodels +package com.tangem.managetokens.presentation.addcustomtoken.viewmodels import com.tangem.managetokens.presentation.common.state.NetworkItemState -import com.tangem.managetokens.presentation.customtokens.state.Derivation +import com.tangem.managetokens.presentation.addcustomtoken.state.Derivation @Suppress("TooManyFunctions") -internal interface CustomTokensClickIntents { +internal interface AddCustomTokenClickIntents { fun onNetworkSelected(networkItemState: NetworkItemState) diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/viewmodels/CustomTokensViewModel.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/viewmodels/AddCustomTokenViewModel.kt similarity index 93% rename from features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/viewmodels/CustomTokensViewModel.kt rename to features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/viewmodels/AddCustomTokenViewModel.kt index 2ccbd92705..9211b1aaf1 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/customtokens/viewmodels/CustomTokensViewModel.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/addcustomtoken/viewmodels/AddCustomTokenViewModel.kt @@ -1,9 +1,10 @@ -package com.tangem.managetokens.presentation.customtokens.viewmodels +package com.tangem.managetokens.presentation.addcustomtoken.viewmodels import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import arrow.core.getOrElse @@ -23,11 +24,11 @@ import com.tangem.managetokens.presentation.common.analytics.ManageTokens import com.tangem.managetokens.presentation.common.state.AlertState import com.tangem.managetokens.presentation.common.state.Event import com.tangem.managetokens.presentation.common.state.NetworkItemState -import com.tangem.managetokens.presentation.customtokens.state.* -import com.tangem.managetokens.presentation.customtokens.state.factory.AddCustomTokenStateToCryptoCurrencyConverter -import com.tangem.managetokens.presentation.customtokens.state.factory.ContractAddressToCustomTokenDataConverter -import com.tangem.managetokens.presentation.customtokens.state.factory.CustomTokensStateFactory -import com.tangem.managetokens.presentation.customtokens.state.factory.FoundTokenToCustomTokenDataConverter +import com.tangem.managetokens.presentation.addcustomtoken.state.* +import com.tangem.managetokens.presentation.addcustomtoken.state.factory.AddCustomTokenStateToCryptoCurrencyConverter +import com.tangem.managetokens.presentation.addcustomtoken.state.factory.ContractAddressToCustomTokenDataConverter +import com.tangem.managetokens.presentation.addcustomtoken.state.factory.AddCustomTokenStateFactory +import com.tangem.managetokens.presentation.addcustomtoken.state.factory.FoundTokenToCustomTokenDataConverter import com.tangem.managetokens.presentation.router.InnerManageTokensRouter import com.tangem.utils.Provider import com.tangem.utils.coroutines.CoroutineDispatcherProvider @@ -45,7 +46,7 @@ import kotlin.properties.Delegates @Suppress("LongParameterList", "TooManyFunctions", "LargeClass") @HiltViewModel -internal class CustomTokensViewModel @Inject constructor( +internal class AddCustomTokenViewModel @Inject constructor( private val dispatchers: CoroutineDispatcherProvider, private val getWalletsUseCase: GetWalletsUseCase, private val getSelectedWalletSyncUseCase: GetSelectedWalletSyncUseCase, @@ -57,11 +58,11 @@ internal class CustomTokensViewModel @Inject constructor( private val getNetworksSupportedByWallet: GetNetworksSupportedByWallet, private val areTokensSupportedByNetworkUseCase: AreTokensSupportedByNetworkUseCase, private val analyticsEventHandler: AnalyticsEventHandler, -) : ViewModel(), CustomTokensClickIntents, DefaultLifecycleObserver { +) : ViewModel(), AddCustomTokenClickIntents, DefaultLifecycleObserver { private val debouncer = Debouncer() - private val stateFactory = CustomTokensStateFactory( + private val stateFactory = AddCustomTokenStateFactory( currentStateProvider = Provider { uiState }, clickIntents = this, ) @@ -71,7 +72,7 @@ internal class CustomTokensViewModel @Inject constructor( var uiState: AddCustomTokenState by mutableStateOf(stateFactory.getInitialState()) private set - init { + override fun onCreate(owner: LifecycleOwner) { viewModelScope.launch(dispatchers.io) { getWalletsUseCase() .distinctUntilChanged() @@ -91,6 +92,10 @@ internal class CustomTokensViewModel @Inject constructor( } } + override fun onDestroy(owner: LifecycleOwner) { + uiState = stateFactory.getInitialState() + } + private suspend fun selectSuitableWallet(suitableUserWallets: List): UserWalletId? { val selectedWallet = getSelectedWalletSyncUseCase().getOrNull() val selectedWalletId = if (walletSupportsAddingTokens(selectedWallet) && suitableUserWallets.isNotEmpty()) { @@ -134,7 +139,7 @@ internal class CustomTokensViewModel @Inject constructor( } override fun onChooseNetworkClick() { - router.openCustomTokensChooseNetwork() + router.openCustomTokenChooseNetwork() } override fun onCloseChoosingNetworkClick() { @@ -159,7 +164,7 @@ internal class CustomTokensViewModel @Inject constructor( } override fun onChooseWalletClick() { - router.openCustomTokensChooseWallet() + router.openCustomTokenChooseWallet() } override fun onCloseChoosingWalletClick() { @@ -208,7 +213,7 @@ internal class CustomTokensViewModel @Inject constructor( networkId = networkId, ).fold( ifLeft = { - val tokenData = ContractAddressToCustomTokenDataConverter(this@CustomTokensViewModel) + val tokenData = ContractAddressToCustomTokenDataConverter(this@AddCustomTokenViewModel) .convert(contractAddress) val isButtonEnabled = tokenData.isRequiredInformationProvided() @@ -222,9 +227,9 @@ internal class CustomTokensViewModel @Inject constructor( }, ifRight = { token -> val tokenData = if (token != null) { - FoundTokenToCustomTokenDataConverter(this@CustomTokensViewModel).convert(token) + FoundTokenToCustomTokenDataConverter(this@AddCustomTokenViewModel).convert(token) } else { - ContractAddressToCustomTokenDataConverter(this@CustomTokensViewModel).convert( + ContractAddressToCustomTokenDataConverter(this@AddCustomTokenViewModel).convert( contractAddress, ) } @@ -326,7 +331,7 @@ internal class CustomTokensViewModel @Inject constructor( } override fun onChooseDerivationClick() { - router.openCustomTokensChooseDerivation() + router.openCustomTokenChooseDerivation() } override fun onCloseChoosingDerivationClick() { diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/viewmodels/ManageTokensViewModel.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/viewmodels/ManageTokensViewModel.kt index ac7b3cbc5d..a2bb0805e8 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/viewmodels/ManageTokensViewModel.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/managetokens/viewmodels/ManageTokensViewModel.kt @@ -190,7 +190,7 @@ internal class ManageTokensViewModel @Inject constructor( override fun onAddCustomTokensButtonClick() { analyticsEventHandler.send(ManageTokens.ButtonCustomToken) - router.openCustomTokensScreen() + router.openAddCustomTokenScreen() } override fun onSearchQueryChange(query: String) { diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/DefaultManageTokensRouter.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/DefaultManageTokensRouter.kt index dca7527d4b..5a4ec5b232 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/DefaultManageTokensRouter.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/DefaultManageTokensRouter.kt @@ -15,11 +15,11 @@ import com.tangem.core.navigation.NavigationAction import com.tangem.core.navigation.ReduxNavController import com.tangem.managetokens.ManageTokensFragment import com.tangem.managetokens.presentation.common.state.ChooseWalletState -import com.tangem.managetokens.presentation.customtokens.ui.ChooseDerivationScreen -import com.tangem.managetokens.presentation.customtokens.ui.ChooseNetworkCustomScreen -import com.tangem.managetokens.presentation.customtokens.ui.CustomTokensChooseWalletScreen -import com.tangem.managetokens.presentation.customtokens.ui.CustomTokensScreen -import com.tangem.managetokens.presentation.customtokens.viewmodels.CustomTokensViewModel +import com.tangem.managetokens.presentation.addcustomtoken.ui.ChooseDerivationScreen +import com.tangem.managetokens.presentation.addcustomtoken.ui.ChooseNetworkCustomScreen +import com.tangem.managetokens.presentation.addcustomtoken.ui.CustomTokensChooseWalletScreen +import com.tangem.managetokens.presentation.addcustomtoken.ui.AddCustomTokenScreen +import com.tangem.managetokens.presentation.addcustomtoken.viewmodels.AddCustomTokenViewModel import com.tangem.managetokens.presentation.managetokens.ui.ManageTokensScreen import com.tangem.managetokens.presentation.managetokens.viewmodels.ManageTokensViewModel import kotlin.properties.Delegates @@ -46,21 +46,22 @@ internal class DefaultManageTokensRouter( } navigation( - startDestination = ManageTokensRoute.CustomTokens.Main.route, - route = ManageTokensRoute.CustomTokens.route, + startDestination = ManageTokensRoute.AddCustomToken.Main.route, + route = ManageTokensRoute.AddCustomToken.route, ) { composable( - ManageTokensRoute.CustomTokens.Main.route, + ManageTokensRoute.AddCustomToken.Main.route, ) { - val viewModel = hiltViewModel(viewModelStoreOwner).apply { + val viewModel = hiltViewModel(viewModelStoreOwner).apply { router = this@DefaultManageTokensRouter } - CustomTokensScreen(state = viewModel.uiState) + LocalLifecycleOwner.current.lifecycle.addObserver(viewModel) + AddCustomTokenScreen(state = viewModel.uiState) } composable( - ManageTokensRoute.CustomTokens.ChooseNetwork.route, + ManageTokensRoute.AddCustomToken.ChooseNetwork.route, ) { - val viewModel = hiltViewModel(viewModelStoreOwner).apply { + val viewModel = hiltViewModel(viewModelStoreOwner).apply { router = this@DefaultManageTokensRouter } ChooseNetworkCustomScreen( @@ -68,9 +69,9 @@ internal class DefaultManageTokensRouter( ) } composable( - ManageTokensRoute.CustomTokens.ChooseDerivation.route, + ManageTokensRoute.AddCustomToken.ChooseDerivation.route, ) { - val viewModel = hiltViewModel(viewModelStoreOwner).apply { + val viewModel = hiltViewModel(viewModelStoreOwner).apply { router = this@DefaultManageTokensRouter } ChooseDerivationScreen( @@ -78,9 +79,9 @@ internal class DefaultManageTokensRouter( ) } composable( - ManageTokensRoute.CustomTokens.ChooseWallet.route, + ManageTokensRoute.AddCustomToken.ChooseWallet.route, ) { - val viewModel = hiltViewModel(viewModelStoreOwner).apply { + val viewModel = hiltViewModel(viewModelStoreOwner).apply { router = this@DefaultManageTokensRouter } CustomTokensChooseWalletScreen( @@ -103,19 +104,19 @@ internal class DefaultManageTokensRouter( navController.navigate(ManageTokensRoute.ManageTokens.route) } - override fun openCustomTokensScreen() { - navController.navigate(ManageTokensRoute.CustomTokens.route) + override fun openAddCustomTokenScreen() { + navController.navigate(ManageTokensRoute.AddCustomToken.route) } - override fun openCustomTokensChooseNetwork() { - navController.navigate(ManageTokensRoute.CustomTokens.ChooseNetwork.route) + override fun openCustomTokenChooseNetwork() { + navController.navigate(ManageTokensRoute.AddCustomToken.ChooseNetwork.route) } - override fun openCustomTokensChooseDerivation() { - navController.navigate(ManageTokensRoute.CustomTokens.ChooseDerivation.route) + override fun openCustomTokenChooseDerivation() { + navController.navigate(ManageTokensRoute.AddCustomToken.ChooseDerivation.route) } - override fun openCustomTokensChooseWallet() { - navController.navigate(ManageTokensRoute.CustomTokens.ChooseWallet.route) + override fun openCustomTokenChooseWallet() { + navController.navigate(ManageTokensRoute.AddCustomToken.ChooseWallet.route) } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/InnerManageTokensRouter.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/InnerManageTokensRouter.kt index 29d0cd4c9e..4c45b39d4a 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/InnerManageTokensRouter.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/InnerManageTokensRouter.kt @@ -6,6 +6,7 @@ import com.tangem.core.navigation.AppScreen import com.tangem.features.managetokens.navigation.ManageTokensRouter internal interface InnerManageTokensRouter : ManageTokensRouter { + /** * Initialize router **/ @@ -19,12 +20,15 @@ internal interface InnerManageTokensRouter : ManageTokensRouter { /** Open manage tokens screen */ fun openManageTokensScreen() - /** Open custom tokens screen */ - fun openCustomTokensScreen() + /** Open add custom token screen */ + fun openAddCustomTokenScreen() - fun openCustomTokensChooseNetwork() + /** Open custom token choose network screen */ + fun openCustomTokenChooseNetwork() - fun openCustomTokensChooseDerivation() + /** Open custom token choose derivation screen */ + fun openCustomTokenChooseDerivation() - fun openCustomTokensChooseWallet() + /** Open custom token choose wallet screen */ + fun openCustomTokenChooseWallet() } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/ManageTokensRoute.kt b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/ManageTokensRoute.kt index 0e6a358743..705769d5b0 100644 --- a/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/ManageTokensRoute.kt +++ b/features/manage-tokens/impl/src/main/java/com/tangem/managetokens/presentation/router/ManageTokensRoute.kt @@ -10,10 +10,10 @@ internal sealed class ManageTokensRoute(val route: String) { object ManageTokens : ManageTokensRoute(route = "manage_tokens") - object CustomTokens : ManageTokensRoute(route = "manage_tokens/custom_tokens") { - object Main : ManageTokensRoute(CustomTokens.route + "/main") - object ChooseNetwork : ManageTokensRoute(CustomTokens.route + "/choose_network") - object ChooseWallet : ManageTokensRoute(CustomTokens.route + "/choose_wallet") - object ChooseDerivation : ManageTokensRoute(CustomTokens.route + "/choose_derivation") + object AddCustomToken : ManageTokensRoute(route = "manage_tokens/add_custom_token") { + object Main : ManageTokensRoute(AddCustomToken.route + "/main") + object ChooseNetwork : ManageTokensRoute(AddCustomToken.route + "/choose_network") + object ChooseWallet : ManageTokensRoute(AddCustomToken.route + "/choose_wallet") + object ChooseDerivation : ManageTokensRoute(AddCustomToken.route + "/choose_derivation") } } \ No newline at end of file