Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-26 11:05:09 +05:00
parent 0dcf1ed23c
commit 0f0196ca94
5 changed files with 30 additions and 2 deletions

View file

@ -4,4 +4,5 @@ enum class TokenAction {
Receive,
Send,
Swap,
Info,
}

View file

@ -79,4 +79,6 @@ interface TokenDetailsClickIntents {
fun onConfirmDisposeExpressStatus()
fun onDisposeExpressStatus()
fun onYieldInfoClick()
}

View file

@ -8,6 +8,7 @@ import com.arkivanov.decompose.router.slot.activate
import com.arkivanov.decompose.router.slot.dismiss
import com.tangem.blockchain.common.address.AddressType
import com.tangem.common.routing.AppRoute
import com.tangem.common.routing.AppRoute.*
import com.tangem.common.routing.AppRouter
import com.tangem.common.ui.bottomsheet.receive.AddressModel
import com.tangem.common.ui.bottomsheet.receive.mapToAddressModels
@ -1028,6 +1029,15 @@ internal class TokenDetailsModel @Inject constructor(
internalUiState.value = stateFactory.getStateWithClosedBottomSheet()
}
override fun onYieldInfoClick() {
bottomSheetNavigation.activate(
configuration = TokenDetailsBottomSheetConfig.YieldSupplyWarning(
cryptoCurrency = cryptoCurrency,
tokenAction = TokenAction.Info,
),
)
}
private fun handleUnavailabilityReason(unavailabilityReason: ScenarioUnavailabilityReason): Boolean {
if (unavailabilityReason == ScenarioUnavailabilityReason.None) return false
@ -1161,7 +1171,9 @@ internal class TokenDetailsModel @Inject constructor(
override fun onYieldSupplyWarningAcknowledged(tokenAction: TokenAction) {
bottomSheetNavigation.dismiss()
modelScope.launch {
saveViewedYieldSupplyWarningUseCase(cryptoCurrency.name)
if(tokenAction != TokenAction.Info) {
saveViewedYieldSupplyWarningUseCase(cryptoCurrency.name)
}
if (tokenAction == TokenAction.Receive) {
saveViewedTokenReceiveWarningUseCase(cryptoCurrency.name)
}
@ -1169,12 +1181,13 @@ internal class TokenDetailsModel @Inject constructor(
TokenAction.Receive -> navigateToReceive()
TokenAction.Send -> sendCurrency()
TokenAction.Swap -> appRouter.push(
AppRoute.Swap(
Swap(
currencyFrom = cryptoCurrency,
userWalletId = userWalletId,
screenSource = AnalyticsParam.ScreensSources.Token.value,
),
)
TokenAction.Info -> Unit
}
}
}

View file

@ -16,8 +16,10 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDeta
import com.tangem.feature.tokendetails.presentation.tokendetails.state.BalanceType
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsBalanceBlockState
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsYieldSupplyState
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification
import com.tangem.feature.tokendetails.presentation.tokendetails.state.utils.getBalance
import com.tangem.features.yield.supply.api.YieldSupplyFeatureToggles
import com.tangem.utils.Provider
import com.tangem.utils.StringsSigns.DASH_SIGN
import com.tangem.utils.converter.Converter
@ -29,6 +31,7 @@ internal class TokenDetailsLoadedBalanceConverter(
private val currentStateProvider: Provider<TokenDetailsState>,
private val appCurrencyProvider: Provider<AppCurrency>,
private val clickIntents: TokenDetailsClickIntents,
private val yieldSupplyFeatureToggles: YieldSupplyFeatureToggles,
) : Converter<Either<CurrencyStatusError, CryptoCurrencyStatus>, TokenDetailsState> {
override fun convert(value: Either<CurrencyStatusError, CryptoCurrencyStatus>): TokenDetailsState {
@ -100,6 +103,14 @@ internal class TokenDetailsLoadedBalanceConverter(
selectedBalanceType = currentState.selectedBalanceType,
isBalanceSelectorEnabled = isBalanceSelectorEnabled,
isBalanceFlickering = status.value.isFlickering(),
yieldSupplyState =
if (yieldSupplyFeatureToggles.isYieldSupplyFeatureEnabled &&
status.value.yieldSupplyStatus?.isActive == true
) {
TokenDetailsYieldSupplyState.Active(clickIntents::onYieldInfoClick)
} else {
TokenDetailsYieldSupplyState.Empty
},
)
is CryptoCurrencyStatus.Loading -> TokenDetailsBalanceBlockState.Loading(
actionButtons = currentState.actionButtons,

View file

@ -70,6 +70,7 @@ internal class TokenDetailsStateFactory(
currentStateProvider = currentStateProvider,
appCurrencyProvider = appCurrencyProvider,
clickIntents = clickIntents,
yieldSupplyFeatureToggles = yieldSupplyFeatureToggles,
)
}