Updated on 2026-08-14
This commit is contained in:
parent
1a1cce4e70
commit
12146c8981
11 changed files with 51 additions and 12 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package com.tangem.tap.common.url
|
package com.tangem.tap.common.url
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.browser.customtabs.CustomTabColorSchemeParams
|
import androidx.browser.customtabs.CustomTabColorSchemeParams
|
||||||
import androidx.browser.customtabs.CustomTabsIntent
|
import androidx.browser.customtabs.CustomTabsIntent
|
||||||
|
|
@ -34,6 +35,8 @@ internal class CustomTabsUrlOpener : UrlOpener {
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
customTabsIntent.intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
|
||||||
customTabsIntent.launchUrl(context, Uri.parse(url))
|
customTabsIntent.launchUrl(context, Uri.parse(url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,11 +2,13 @@ package com.tangem.core.deeplink.global
|
||||||
|
|
||||||
import com.tangem.core.deeplink.DeepLink
|
import com.tangem.core.deeplink.DeepLink
|
||||||
|
|
||||||
class BuyCurrencyDeepLink(val onReceive: () -> Unit) : DeepLink {
|
class BuyCurrencyDeepLink(val onReceive: (txId: String) -> Unit) : DeepLink {
|
||||||
|
|
||||||
override val uri: String = "tangem://redirect?action=dismissBrowser"
|
override val uri: String = "tangem://redirect?action=dismissBrowser"
|
||||||
|
|
||||||
override fun onReceive(params: Map<String, String>) {
|
override fun onReceive(params: Map<String, String>) {
|
||||||
onReceive()
|
onReceive(
|
||||||
|
params["txId"] ?: return,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -93,5 +93,6 @@ dependencies {
|
||||||
implementation(projects.features.send.api)
|
implementation(projects.features.send.api)
|
||||||
implementation(projects.features.staking.api)
|
implementation(projects.features.staking.api)
|
||||||
implementation(projects.features.markets.api)
|
implementation(projects.features.markets.api)
|
||||||
|
implementation(projects.features.onramp.api)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -48,4 +48,8 @@ internal class DefaultTokenDetailsRouter(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun openOnrampSuccess(txId: String) {
|
||||||
|
router.push(AppRoute.OnrampSuccess(txId))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,4 +19,6 @@ internal interface InnerTokenDetailsRouter : TokenDetailsRouter {
|
||||||
fun openTokenDetails(userWalletId: UserWalletId, currency: CryptoCurrency)
|
fun openTokenDetails(userWalletId: UserWalletId, currency: CryptoCurrency)
|
||||||
|
|
||||||
fun openStaking(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency, yield: Yield)
|
fun openStaking(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency, yield: Yield)
|
||||||
|
|
||||||
|
fun openOnrampSuccess(txId: String)
|
||||||
}
|
}
|
||||||
|
|
@ -66,6 +66,7 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.E
|
||||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.TokenDetailsStateFactory
|
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.TokenDetailsStateFactory
|
||||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.express.ExpressStatusFactory
|
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.express.ExpressStatusFactory
|
||||||
import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express.ExpressStatusBottomSheetConfig
|
import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.express.ExpressStatusBottomSheetConfig
|
||||||
|
import com.tangem.features.onramp.OnrampFeatureToggles
|
||||||
import com.tangem.features.tokendetails.impl.R
|
import com.tangem.features.tokendetails.impl.R
|
||||||
import com.tangem.utils.Provider
|
import com.tangem.utils.Provider
|
||||||
import com.tangem.utils.coroutines.*
|
import com.tangem.utils.coroutines.*
|
||||||
|
|
@ -111,6 +112,7 @@ internal class TokenDetailsViewModel @Inject constructor(
|
||||||
private val vibratorHapticManager: VibratorHapticManager,
|
private val vibratorHapticManager: VibratorHapticManager,
|
||||||
private val clipboardManager: ClipboardManager,
|
private val clipboardManager: ClipboardManager,
|
||||||
expressStatusFactory: ExpressStatusFactory.Factory,
|
expressStatusFactory: ExpressStatusFactory.Factory,
|
||||||
|
private val onrampFeatureToggles: OnrampFeatureToggles,
|
||||||
getUserWalletUseCase: GetUserWalletUseCase,
|
getUserWalletUseCase: GetUserWalletUseCase,
|
||||||
getStakingIntegrationIdUseCase: GetStakingIntegrationIdUseCase,
|
getStakingIntegrationIdUseCase: GetStakingIntegrationIdUseCase,
|
||||||
deepLinksRegistry: DeepLinksRegistry,
|
deepLinksRegistry: DeepLinksRegistry,
|
||||||
|
|
@ -193,9 +195,13 @@ internal class TokenDetailsViewModel @Inject constructor(
|
||||||
userWallet = getUserWalletUseCase(userWalletId).getOrNull() ?: error("UserWallet not found")
|
userWallet = getUserWalletUseCase(userWalletId).getOrNull() ?: error("UserWallet not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onBuyCurrencyDeepLink() {
|
private fun onBuyCurrencyDeepLink(txId: String) {
|
||||||
val currency = cryptoCurrencyStatus?.currency ?: return
|
if (onrampFeatureToggles.isFeatureEnabled) {
|
||||||
analyticsEventsHandler.send(TokenScreenAnalyticsEvent.Bought(currency.symbol))
|
router.openOnrampSuccess(txId)
|
||||||
|
} else {
|
||||||
|
val currency = cryptoCurrencyStatus?.currency ?: return
|
||||||
|
analyticsEventsHandler.send(TokenScreenAnalyticsEvent.Bought(currency.symbol))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(owner: LifecycleOwner) {
|
override fun onCreate(owner: LifecycleOwner) {
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ dependencies {
|
||||||
implementation(projects.features.details.api)
|
implementation(projects.features.details.api)
|
||||||
implementation(projects.features.pushNotifications.api)
|
implementation(projects.features.pushNotifications.api)
|
||||||
implementation(projects.features.markets.api)
|
implementation(projects.features.markets.api)
|
||||||
|
implementation(projects.features.onramp.api)
|
||||||
|
|
||||||
/** Common modules */
|
/** Common modules */
|
||||||
implementation(projects.common.ui)
|
implementation(projects.common.ui)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||||
import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent
|
import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent
|
||||||
import com.tangem.domain.wallets.models.UserWallet
|
import com.tangem.domain.wallets.models.UserWallet
|
||||||
import com.tangem.domain.wallets.models.UserWalletId
|
import com.tangem.domain.wallets.models.UserWalletId
|
||||||
|
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
|
||||||
|
import com.tangem.features.onramp.OnrampFeatureToggles
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.firstOrNull
|
import kotlinx.coroutines.flow.firstOrNull
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
@ -31,6 +33,8 @@ internal class WalletDeepLinksHandler @Inject constructor(
|
||||||
private val getFeePaidCryptoCurrencyStatusSyncUseCase: GetFeePaidCryptoCurrencyStatusSyncUseCase,
|
private val getFeePaidCryptoCurrencyStatusSyncUseCase: GetFeePaidCryptoCurrencyStatusSyncUseCase,
|
||||||
private val getNetworkCoinStatusUseCase: GetNetworkCoinStatusUseCase,
|
private val getNetworkCoinStatusUseCase: GetNetworkCoinStatusUseCase,
|
||||||
private val reduxStateHolder: ReduxStateHolder,
|
private val reduxStateHolder: ReduxStateHolder,
|
||||||
|
private val clickIntents: WalletClickIntents,
|
||||||
|
private val onrampFeatureToggles: OnrampFeatureToggles,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var deepLinksMap = mutableMapOf<UserWalletId, List<DeepLink>>()
|
private var deepLinksMap = mutableMapOf<UserWalletId, List<DeepLink>>()
|
||||||
|
|
@ -58,11 +62,11 @@ internal class WalletDeepLinksHandler @Inject constructor(
|
||||||
|
|
||||||
return buildList {
|
return buildList {
|
||||||
add(sellCurrencyDeepLink)
|
add(sellCurrencyDeepLink)
|
||||||
if (!userWallet.isMultiCurrency) {
|
if (onrampFeatureToggles.isFeatureEnabled || !userWallet.isMultiCurrency) {
|
||||||
add(
|
add(
|
||||||
BuyCurrencyDeepLink(
|
BuyCurrencyDeepLink(
|
||||||
onReceive = {
|
onReceive = { txId ->
|
||||||
scope.launch { onBuyCurrencyDeepLink(userWallet) }
|
scope.launch { onBuyCurrencyDeepLink(txId, userWallet) }
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -102,10 +106,13 @@ internal class WalletDeepLinksHandler @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun onBuyCurrencyDeepLink(userWallet: UserWallet) {
|
private suspend fun onBuyCurrencyDeepLink(txId: String, userWallet: UserWallet) {
|
||||||
val cryptoCurrency = getCryptoCurrencyUseCase(userWallet.walletId).getOrNull() ?: return
|
if (onrampFeatureToggles.isFeatureEnabled) {
|
||||||
|
clickIntents.onOnrampSuccessClick(txId)
|
||||||
analyticsEventHandler.send(TokenScreenAnalyticsEvent.Bought(cryptoCurrency.symbol))
|
} else {
|
||||||
|
val cryptoCurrency = getCryptoCurrencyUseCase(userWallet.walletId).getOrNull() ?: return
|
||||||
|
analyticsEventHandler.send(TokenScreenAnalyticsEvent.Bought(cryptoCurrency.symbol))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun findCryptoCurrencyStatus(
|
private suspend fun findCryptoCurrencyStatus(
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,10 @@ internal class DefaultWalletRouter(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun openOnrampSuccessScreen(txId: String) {
|
||||||
|
router.push(AppRoute.OnrampSuccess(txId))
|
||||||
|
}
|
||||||
|
|
||||||
override fun openUrl(url: String) {
|
override fun openUrl(url: String) {
|
||||||
urlOpener.openUrl(url)
|
urlOpener.openUrl(url)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,9 @@ internal interface InnerWalletRouter : WalletRouter {
|
||||||
/** Open onboarding screen */
|
/** Open onboarding screen */
|
||||||
fun openOnboardingScreen()
|
fun openOnboardingScreen()
|
||||||
|
|
||||||
|
/** Open onramp success screen for [txId] */
|
||||||
|
fun openOnrampSuccessScreen(txId: String)
|
||||||
|
|
||||||
/** Open transaction history website by [url] */
|
/** Open transaction history website by [url] */
|
||||||
fun openUrl(url: String)
|
fun openUrl(url: String)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ internal interface WalletContentClickIntents {
|
||||||
|
|
||||||
fun onOrganizeTokensClick()
|
fun onOrganizeTokensClick()
|
||||||
|
|
||||||
|
fun onOnrampSuccessClick(txId: String)
|
||||||
|
|
||||||
fun onDismissMarketsOnboarding()
|
fun onDismissMarketsOnboarding()
|
||||||
|
|
||||||
fun onTokenItemClick(currencyStatus: CryptoCurrencyStatus)
|
fun onTokenItemClick(currencyStatus: CryptoCurrencyStatus)
|
||||||
|
|
@ -97,6 +99,10 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
|
||||||
router.openOrganizeTokensScreen(userWalletId = stateHolder.getSelectedWalletId())
|
router.openOrganizeTokensScreen(userWalletId = stateHolder.getSelectedWalletId())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onOnrampSuccessClick(txId: String) {
|
||||||
|
router.openOnrampSuccessScreen(txId = txId)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDismissMarketsOnboarding() {
|
override fun onDismissMarketsOnboarding() {
|
||||||
stateHolder.update { it.copy(showMarketsOnboarding = false) }
|
stateHolder.update { it.copy(showMarketsOnboarding = false) }
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue