Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-24 16:53:06 +08:00
parent 1128278084
commit 0f5d1ee8e8
8 changed files with 42 additions and 15 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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