Updated on 2026-08-14
This commit is contained in:
parent
10171a3b3e
commit
ecf8e5fc96
19 changed files with 125 additions and 55 deletions
|
|
@ -5,10 +5,4 @@ import androidx.fragment.app.Fragment
|
|||
interface StakingRouter {
|
||||
|
||||
fun getEntryFragment(): Fragment
|
||||
|
||||
companion object {
|
||||
const val CRYPTO_CURRENCY_ID_KEY = "CRYPTO_CURRENCY_ID_KEY"
|
||||
const val USER_WALLET_ID_KEY = "USER_WALLET_ID_KEY"
|
||||
const val YIELD_KEY = "YIELD_KEY"
|
||||
}
|
||||
}
|
||||
|
|
@ -63,6 +63,7 @@ dependencies {
|
|||
|
||||
/** Common */
|
||||
implementation(projects.common.ui)
|
||||
implementation(projects.common.routing)
|
||||
|
||||
/** Libs */
|
||||
implementation(projects.libs.crypto)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.staking.impl.presentation.viewmodel
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
|
@ -7,6 +8,8 @@ import androidx.lifecycle.viewModelScope
|
|||
import arrow.core.getOrElse
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.common.routing.bundle.unbundle
|
||||
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
|
||||
import com.tangem.domain.staking.model.Yield
|
||||
import com.tangem.domain.tokens.GetCryptoCurrencyStatusSyncUseCase
|
||||
|
|
@ -52,14 +55,18 @@ internal class StakingViewModel @Inject constructor(
|
|||
var stakingStateRouter: StakingStateRouter by Delegates.notNull()
|
||||
private set
|
||||
|
||||
private val cryptoCurrencyId: CryptoCurrency.ID = savedStateHandle[StakingRouter.CRYPTO_CURRENCY_ID_KEY]
|
||||
private val cryptoCurrencyId: CryptoCurrency.ID = savedStateHandle.get<Bundle>(
|
||||
AppRoute.Staking.CRYPTO_CURRENCY_ID_KEY,
|
||||
)
|
||||
?.let { it.unbundle(CryptoCurrency.ID.serializer()) }
|
||||
?: error("This screen can't be opened without `CryptoCurrency.ID`")
|
||||
|
||||
private val userWalletId: UserWalletId = savedStateHandle.get<String>(StakingRouter.USER_WALLET_ID_KEY)
|
||||
?.let { stringValue -> UserWalletId(stringValue) }
|
||||
private val userWalletId: UserWalletId = savedStateHandle.get<Bundle>(AppRoute.Staking.USER_WALLET_ID_KEY)
|
||||
?.let { it.unbundle(UserWalletId.serializer()) }
|
||||
?: error("This screen can't be opened without `UserWalletId`")
|
||||
|
||||
private val yield: Yield = savedStateHandle[StakingRouter.YIELD_KEY]
|
||||
private val yield: Yield = savedStateHandle.get<Bundle>(AppRoute.Staking.YIELD_KEY)
|
||||
?.let { it.unbundle(Yield.serializer()) }
|
||||
?: error("This screen can't be opened without `Yield`")
|
||||
|
||||
private var cryptoCurrencyStatus: CryptoCurrencyStatus by Delegates.notNull()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ 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.staking.model.Yield
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.tokendetails.presentation.TokenDetailsFragment
|
||||
|
|
@ -37,4 +38,14 @@ internal class DefaultTokenDetailsRouter(
|
|||
),
|
||||
)
|
||||
}
|
||||
|
||||
override fun openStaking(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency, yield: Yield) {
|
||||
router.push(
|
||||
AppRoute.Staking(
|
||||
userWalletId = userWalletId,
|
||||
cryptoCurrencyId = cryptoCurrency.id,
|
||||
yield = yield,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.feature.tokendetails.presentation.router
|
||||
|
||||
import com.tangem.domain.staking.model.Yield
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.features.tokendetails.navigation.TokenDetailsRouter
|
||||
|
|
@ -16,4 +17,6 @@ internal interface InnerTokenDetailsRouter : TokenDetailsRouter {
|
|||
fun share(text: String)
|
||||
|
||||
fun openTokenDetails(userWalletId: UserWalletId, currency: CryptoCurrency)
|
||||
|
||||
fun openStaking(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency, yield: Yield)
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
|||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.*
|
||||
import androidx.paging.cachedIn
|
||||
import arrow.core.getOrElse
|
||||
|
|
@ -14,8 +13,6 @@ 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
|
||||
import com.tangem.core.navigation.AppScreen
|
||||
import com.tangem.core.navigation.NavigationAction
|
||||
import com.tangem.core.ui.clipboard.ClipboardManager
|
||||
import com.tangem.core.ui.components.bottomsheets.tokenreceive.AddressModel
|
||||
import com.tangem.core.ui.components.bottomsheets.tokenreceive.mapToAddressModels
|
||||
|
|
@ -70,7 +67,6 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDeta
|
|||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.TokenDetailsStateFactory
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.exchange.ExchangeStatusBottomSheetConfig
|
||||
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.lib.crypto.BlockchainUtils.isBitcoin
|
||||
|
|
@ -448,16 +444,7 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
val yield = getYieldUseCase.invoke(cryptoCurrency.id, cryptoCurrency.symbol).getOrNull()
|
||||
yield ?: error("Staking is unavailable")
|
||||
|
||||
reduxStateHolder.dispatch(
|
||||
action = NavigationAction.NavigateTo(
|
||||
screen = AppScreen.Staking,
|
||||
bundle = bundleOf(
|
||||
StakingRouter.USER_WALLET_ID_KEY to userWalletId.stringValue,
|
||||
StakingRouter.CRYPTO_CURRENCY_ID_KEY to cryptoCurrency.id,
|
||||
StakingRouter.YIELD_KEY to yield,
|
||||
),
|
||||
),
|
||||
)
|
||||
router.openStaking(userWalletId, cryptoCurrency, yield)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue