From 0f5d1ee8e80a63d10937d18a13d89bf2f056425b Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 24 Oct 2023 16:53:06 +0800 Subject: [PATCH] Updated on 2026-08-14 --- .../model/warnings/CryptoCurrencyWarning.kt | 5 ++--- .../domain/tokens/GetCurrencyWarningsUseCase.kt | 5 ++--- .../router/DefaultTokenDetailsRouter.kt | 17 +++++++++++++++++ .../router/InnerTokenDetailsRouter.kt | 4 ++++ .../components/TokenDetailsNotification.kt | 16 ++++++++-------- .../TokenDetailsNotificationConverter.kt | 2 +- .../viewmodels/TokenDetailsClickIntents.kt | 3 +++ .../viewmodels/TokenDetailsViewModel.kt | 5 +++++ 8 files changed, 42 insertions(+), 15 deletions(-) diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt index 2149361962..f6c14d8482 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt @@ -11,9 +11,8 @@ sealed class CryptoCurrencyWarning { ) : CryptoCurrencyWarning() data class BalanceNotEnoughForFee( - val currency: CryptoCurrency, - val blockchainFullName: String, - val blockchainSymbol: String, + val tokenCurrency: CryptoCurrency, + val coinCurrency: CryptoCurrency, ) : CryptoCurrencyWarning() object SomeNetworksUnreachable : CryptoCurrencyWarning() diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt index f1b1b4c948..edbb60bc92 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt @@ -94,9 +94,8 @@ class GetCurrencyWarningsUseCase( if (!tokenStatus.value.amount.isZero() && coinStatus.value.amount.isZero()) { add( CryptoCurrencyWarning.BalanceNotEnoughForFee( - currency = tokenStatus.currency, - blockchainFullName = coinStatus.currency.name, - blockchainSymbol = coinStatus.currency.symbol, + tokenCurrency = tokenStatus.currency, + coinCurrency = coinStatus.currency, ), ) } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/DefaultTokenDetailsRouter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/DefaultTokenDetailsRouter.kt index ef23464cb0..00693c486c 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/DefaultTokenDetailsRouter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/DefaultTokenDetailsRouter.kt @@ -1,9 +1,14 @@ 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.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, @@ -18,4 +23,16 @@ internal class DefaultTokenDetailsRouter( override fun openUrl(url: String) { reduxNavController.navigate(NavigationAction.OpenUrl(url = url)) } + + 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, + ), + ), + ) + } } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/InnerTokenDetailsRouter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/InnerTokenDetailsRouter.kt index 718ceb5821..0c870f833a 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/InnerTokenDetailsRouter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/router/InnerTokenDetailsRouter.kt @@ -1,5 +1,7 @@ package com.tangem.feature.tokendetails.presentation.router +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.wallets.models.UserWalletId import com.tangem.features.tokendetails.navigation.TokenDetailsRouter internal interface InnerTokenDetailsRouter : TokenDetailsRouter { @@ -9,4 +11,6 @@ internal interface InnerTokenDetailsRouter : TokenDetailsRouter { /** Open website by [url] */ fun openUrl(url: String) + + fun openTokenDetails(userWalletId: UserWalletId, currency: CryptoCurrency) } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt index c832472ce0..989aa84d9b 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt @@ -50,23 +50,23 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) { ) : Warning( title = TextReference.Res( id = R.string.warning_send_blocked_funds_for_fee_title, - formatArgs = wrappedList(feeInfo.blockchainFullName), + formatArgs = wrappedList(feeInfo.coinCurrency.name), ), subtitle = TextReference.Res( id = R.string.warning_send_blocked_funds_for_fee_message, formatArgs = wrappedList( - feeInfo.currency.name, - feeInfo.blockchainFullName, - feeInfo.currency.name, - feeInfo.blockchainFullName, - feeInfo.blockchainSymbol, + feeInfo.tokenCurrency.name, + feeInfo.coinCurrency.name, + feeInfo.tokenCurrency.name, + feeInfo.coinCurrency.name, + feeInfo.coinCurrency.symbol, ), ), - iconResId = feeInfo.currency.networkIconResId, + iconResId = feeInfo.tokenCurrency.networkIconResId, buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig( text = resourceReference( id = R.string.common_buy_currency, - formatArgs = wrappedList(feeInfo.blockchainSymbol), + formatArgs = wrappedList(feeInfo.coinCurrency.symbol), ), onClick = onBuyClick, ), diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt index 0f34733f00..d9362571ca 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt @@ -27,7 +27,7 @@ internal class TokenDetailsNotificationConverter( return when (warning) { is CryptoCurrencyWarning.BalanceNotEnoughForFee -> TokenDetailsNotification.NetworkFee( feeInfo = warning, - onBuyClick = clickIntents::onBuyClick, + onBuyClick = { clickIntents.onBuyCoinClick(warning.coinCurrency) }, ) is CryptoCurrencyWarning.ExistentialDeposit -> TokenDetailsNotification.ExistentialDeposit( existentialInfo = warning, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsClickIntents.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsClickIntents.kt index be5c08eab8..992915899c 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsClickIntents.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsClickIntents.kt @@ -1,6 +1,7 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels import com.tangem.core.ui.components.bottomsheets.tokenreceive.AddressModel +import com.tangem.domain.tokens.model.CryptoCurrency interface TokenDetailsClickIntents { @@ -24,6 +25,8 @@ interface TokenDetailsClickIntents { fun onBuyClick() + fun onBuyCoinClick(cryptoCurrency: CryptoCurrency) + fun onReloadClick() fun onExploreClick() diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt index d9b9707177..511b802dc1 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt @@ -245,6 +245,11 @@ internal class TokenDetailsViewModel @Inject constructor( } } + override fun onBuyCoinClick(cryptoCurrency: CryptoCurrency) { + analyticsEventsHandler.send(TokenScreenAnalyticsEvent.ButtonBuy(cryptoCurrency.symbol)) + router.openTokenDetails(userWalletId = userWalletId, currency = cryptoCurrency) + } + override fun onReloadClick() { analyticsEventsHandler.send(TokenScreenAnalyticsEvent.ButtonReload(cryptoCurrency.symbol)) uiState = stateFactory.getLoadingTxHistoryState()