Updated on 2026-08-14
This commit is contained in:
parent
5ea04db5d8
commit
f895968639
5 changed files with 23 additions and 28 deletions
|
|
@ -5,9 +5,4 @@ import androidx.fragment.app.Fragment
|
|||
interface TokenDetailsRouter {
|
||||
|
||||
fun getEntryFragment(): Fragment
|
||||
|
||||
companion object {
|
||||
const val USER_WALLET_ID_KEY = "token_details_user_wallet_id"
|
||||
const val CRYPTO_CURRENCY_KEY = "token_details_crypto_currency"
|
||||
}
|
||||
}
|
||||
|
|
@ -38,12 +38,14 @@ dependencies {
|
|||
implementation(deps.tangem.card.core)
|
||||
implementation(deps.timber)
|
||||
implementation(deps.lifecycle.compose)
|
||||
implementation(deps.kotlin.serialization)
|
||||
|
||||
/** DI */
|
||||
implementation(deps.hilt.android)
|
||||
kapt(deps.hilt.kapt)
|
||||
|
||||
/** Core modules */
|
||||
implementation(projects.common.routing)
|
||||
implementation(projects.core.navigation)
|
||||
implementation(projects.core.ui)
|
||||
implementation(projects.core.utils)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.feature.tokendetails.di
|
||||
|
||||
import com.tangem.core.navigation.ReduxNavController
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.core.navigation.share.ShareManager
|
||||
import com.tangem.core.navigation.url.UrlOpener
|
||||
import com.tangem.feature.tokendetails.presentation.router.DefaultTokenDetailsRouter
|
||||
|
|
@ -18,10 +18,10 @@ internal object TokenDetailsRouterModule {
|
|||
@Provides
|
||||
@ActivityScoped
|
||||
fun provideTokenDetailsRouter(
|
||||
reduxNavController: ReduxNavController,
|
||||
appRouter: AppRouter,
|
||||
urlOpener: UrlOpener,
|
||||
shareManager: ShareManager,
|
||||
): TokenDetailsRouter {
|
||||
return DefaultTokenDetailsRouter(reduxNavController, urlOpener, shareManager)
|
||||
return DefaultTokenDetailsRouter(appRouter, urlOpener, shareManager)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,16 @@
|
|||
package com.tangem.feature.tokendetails.presentation.router
|
||||
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.tangem.core.navigation.AppScreen
|
||||
import com.tangem.core.navigation.NavigationAction
|
||||
import com.tangem.core.navigation.ReduxNavController
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.core.navigation.share.ShareManager
|
||||
import com.tangem.core.navigation.url.UrlOpener
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.tokendetails.presentation.TokenDetailsFragment
|
||||
import com.tangem.features.tokendetails.navigation.TokenDetailsRouter
|
||||
|
||||
internal class DefaultTokenDetailsRouter(
|
||||
private val reduxNavController: ReduxNavController,
|
||||
private val router: AppRouter,
|
||||
private val urlOpener: UrlOpener,
|
||||
private val shareManager: ShareManager,
|
||||
) : InnerTokenDetailsRouter {
|
||||
|
|
@ -21,7 +18,7 @@ internal class DefaultTokenDetailsRouter(
|
|||
override fun getEntryFragment(): Fragment = TokenDetailsFragment()
|
||||
|
||||
override fun popBackStack() {
|
||||
reduxNavController.navigate(NavigationAction.PopBackTo())
|
||||
router.pop()
|
||||
}
|
||||
|
||||
override fun openUrl(url: String) {
|
||||
|
|
@ -33,13 +30,10 @@ internal class DefaultTokenDetailsRouter(
|
|||
}
|
||||
|
||||
override fun openTokenDetails(userWalletId: UserWalletId, currency: CryptoCurrency) {
|
||||
reduxNavController.navigate(
|
||||
action = NavigationAction.NavigateTo(
|
||||
screen = AppScreen.WalletDetails,
|
||||
bundle = bundleOf(
|
||||
TokenDetailsRouter.USER_WALLET_ID_KEY to userWalletId.stringValue,
|
||||
TokenDetailsRouter.CRYPTO_CURRENCY_KEY to currency,
|
||||
),
|
||||
router.push(
|
||||
AppRoute.CurrencyDetails(
|
||||
userWalletId = userWalletId,
|
||||
currency = currency,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
|
|
@ -8,6 +9,8 @@ import androidx.lifecycle.*
|
|||
import androidx.paging.cachedIn
|
||||
import arrow.core.getOrElse
|
||||
import com.tangem.blockchain.common.address.AddressType
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.common.routing.bundle.unbundle
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.deeplink.DeepLinksRegistry
|
||||
import com.tangem.core.deeplink.global.BuyCurrencyDeepLink
|
||||
|
|
@ -19,8 +22,8 @@ import com.tangem.core.ui.components.bottomsheets.tokenreceive.mapToAddressModel
|
|||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.haptic.HapticManager
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.haptic.HapticManager
|
||||
import com.tangem.datasource.local.swaptx.SwapTransactionStatusStore
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
|
|
@ -70,7 +73,6 @@ import com.tangem.features.staking.api.featuretoggles.StakingFeatureToggles
|
|||
import com.tangem.features.staking.api.navigation.StakingRouter
|
||||
import com.tangem.features.tokendetails.featuretoggles.TokenDetailsFeatureToggles
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
import com.tangem.features.tokendetails.navigation.TokenDetailsRouter
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isBitcoin
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.*
|
||||
|
|
@ -126,12 +128,14 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
savedStateHandle: SavedStateHandle,
|
||||
) : ViewModel(), DefaultLifecycleObserver, TokenDetailsClickIntents {
|
||||
|
||||
private val userWalletId: UserWalletId = savedStateHandle.get<String>(TokenDetailsRouter.USER_WALLET_ID_KEY)
|
||||
?.let { stringValue -> UserWalletId(stringValue) }
|
||||
private val userWalletId: UserWalletId = savedStateHandle.get<Bundle>(AppRoute.CurrencyDetails.USER_WALLET_ID_KEY)
|
||||
?.let { it.unbundle(UserWalletId.serializer()) }
|
||||
?: error("This screen can't open without `UserWalletId`")
|
||||
|
||||
private val cryptoCurrency: CryptoCurrency = savedStateHandle[TokenDetailsRouter.CRYPTO_CURRENCY_KEY]
|
||||
?: error("This screen can't open without `CryptoCurrency`")
|
||||
private val cryptoCurrency: CryptoCurrency =
|
||||
savedStateHandle.get<Bundle>(AppRoute.CurrencyDetails.CRYPTO_CURRENCY_KEY)
|
||||
?.let { it.unbundle(CryptoCurrency.serializer()) }
|
||||
?: error("This screen can't open without `CryptoCurrency`")
|
||||
|
||||
private val userWallet: UserWallet
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue