Updated on 2026-08-14

This commit is contained in:
Tangem 2024-02-09 13:40:19 +01:00
parent cedf6872ac
commit d7f086e1d9
29 changed files with 119 additions and 109 deletions

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -1,4 +1,4 @@
package com.tangem.managetokens.presentation.customtokens.state
package com.tangem.managetokens.presentation.addcustomtoken.state
import kotlinx.collections.immutable.ImmutableList

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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()

View file

@ -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<AddCustomTokenState>,
private val clickIntents: CustomTokensClickIntents,
private val clickIntents: AddCustomTokenClickIntents,
) {
fun getInitialState(): AddCustomTokenState {

View file

@ -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(

View file

@ -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<String, CustomTokenData> {
override fun convert(value: String): CustomTokenData {
return CustomTokenData(

View file

@ -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<FoundToken, CustomTokenData> {
override fun convert(value: FoundToken): CustomTokenData {
return CustomTokenData(

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 {

View file

@ -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<AlertState?>(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)
}
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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

View file

@ -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(

View file

@ -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)

View file

@ -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<UserWallet>): 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() {

View file

@ -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) {

View file

@ -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<CustomTokensViewModel>(viewModelStoreOwner).apply {
val viewModel = hiltViewModel<AddCustomTokenViewModel>(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<CustomTokensViewModel>(viewModelStoreOwner).apply {
val viewModel = hiltViewModel<AddCustomTokenViewModel>(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<CustomTokensViewModel>(viewModelStoreOwner).apply {
val viewModel = hiltViewModel<AddCustomTokenViewModel>(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<CustomTokensViewModel>(viewModelStoreOwner).apply {
val viewModel = hiltViewModel<AddCustomTokenViewModel>(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)
}
}

View file

@ -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()
}

View file

@ -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")
}
}