Updated on 2026-08-14
This commit is contained in:
commit
b9eef04cba
3 changed files with 39 additions and 20 deletions
|
|
@ -22,10 +22,15 @@ import androidx.constraintlayout.compose.ConstraintLayout
|
|||
import androidx.constraintlayout.compose.Dimension
|
||||
import androidx.constraintlayout.compose.Visibility
|
||||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.SecondaryButtonIconStart
|
||||
import com.tangem.core.ui.components.buttons.common.TangemButton
|
||||
import com.tangem.core.ui.components.buttons.common.TangemButtonColors
|
||||
import com.tangem.core.ui.components.buttons.common.TangemButtonIconPosition
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.res.LocalIsInDarkTheme
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Dark6
|
||||
import com.tangem.core.ui.res.TangemColorPalette.Light4
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
||||
/**
|
||||
|
|
@ -113,10 +118,19 @@ fun NotificationWithBackground(config: NotificationConfig, modifier: Modifier =
|
|||
config.onCloseClick?.invoke()
|
||||
},
|
||||
)
|
||||
SecondaryButtonIconStart(
|
||||
val isDarkMode = LocalIsInDarkTheme.current
|
||||
TangemButton(
|
||||
text = button?.text?.resolveReference().orEmpty(),
|
||||
iconResId = button?.iconResId ?: R.drawable.ic_exchange_vertical_24,
|
||||
icon = TangemButtonIconPosition.Start(button?.iconResId ?: R.drawable.ic_exchange_vertical_24),
|
||||
onClick = button?.onClick ?: {},
|
||||
colors = TangemButtonColors(
|
||||
backgroundColor = if (isDarkMode) Light4 else TangemTheme.colors.button.secondary,
|
||||
contentColor = Dark6,
|
||||
disabledBackgroundColor = TangemTheme.colors.button.disabled,
|
||||
disabledContentColor = TangemTheme.colors.text.disabled,
|
||||
),
|
||||
enabled = true,
|
||||
showProgress = false,
|
||||
modifier = Modifier.constrainAs(buttonRef) {
|
||||
start.linkTo(parent.start, spacing12)
|
||||
end.linkTo(parent.end, spacing12)
|
||||
|
|
@ -135,7 +149,7 @@ fun NotificationWithBackground(config: NotificationConfig, modifier: Modifier =
|
|||
//region preview
|
||||
@Preview
|
||||
@Composable
|
||||
private fun NotificationWithBackgroundPreview(
|
||||
private fun NotificationWithBackgroundPreview_Light(
|
||||
@PreviewParameter(NotificationWithBackgroundPreviewProvider::class) config: NotificationConfig,
|
||||
) {
|
||||
TangemTheme {
|
||||
|
|
@ -143,6 +157,16 @@ private fun NotificationWithBackgroundPreview(
|
|||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun NotificationWithBackgroundPreview_Dark(
|
||||
@PreviewParameter(NotificationWithBackgroundPreviewProvider::class) config: NotificationConfig,
|
||||
) {
|
||||
TangemTheme(isDark = true) {
|
||||
NotificationWithBackground(config = config)
|
||||
}
|
||||
}
|
||||
|
||||
private class NotificationWithBackgroundPreviewProvider : PreviewParameterProvider<NotificationConfig> {
|
||||
override val values: Sequence<NotificationConfig>
|
||||
get() = sequenceOf(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.domain.tokens
|
||||
|
||||
import com.tangem.domain.common.CardTypesResolver
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.exchange.RampStateManager
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
|
|
@ -12,7 +11,6 @@ import com.tangem.domain.tokens.repository.MarketCryptoCurrencyRepository
|
|||
import com.tangem.domain.tokens.repository.NetworksRepository
|
||||
import com.tangem.domain.tokens.repository.QuotesRepository
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.isNullOrZero
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
|
|
@ -53,10 +51,9 @@ class GetCryptoCurrencyActionsUseCase(
|
|||
|
||||
val flow = networkFlow.mapLatest { maybeCoinStatus ->
|
||||
createTokenActionsState(
|
||||
userWalletId = userWallet.walletId,
|
||||
userWallet = userWallet,
|
||||
coinStatus = maybeCoinStatus.getOrNull(),
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
cardTypesResolver = userWallet.scanResponse.cardTypesResolver,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -65,19 +62,17 @@ class GetCryptoCurrencyActionsUseCase(
|
|||
}
|
||||
|
||||
private suspend fun createTokenActionsState(
|
||||
userWalletId: UserWalletId,
|
||||
userWallet: UserWallet,
|
||||
coinStatus: CryptoCurrencyStatus?,
|
||||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
): TokenActionsState {
|
||||
return TokenActionsState(
|
||||
walletId = userWalletId,
|
||||
walletId = userWallet.walletId,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
states = createListOfActions(
|
||||
userWalletId,
|
||||
userWallet,
|
||||
coinStatus,
|
||||
cryptoCurrencyStatus,
|
||||
cardTypesResolver,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -87,10 +82,9 @@ class GetCryptoCurrencyActionsUseCase(
|
|||
* Actions priority: [Buy Send Receive Sell Swap]
|
||||
*/
|
||||
private suspend fun createListOfActions(
|
||||
userWalletId: UserWalletId,
|
||||
userWallet: UserWallet,
|
||||
coinStatus: CryptoCurrencyStatus?,
|
||||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
): List<TokenActionsState.ActionState> {
|
||||
val cryptoCurrency = cryptoCurrencyStatus.currency
|
||||
if (cryptoCurrencyStatus.value is CryptoCurrencyStatus.MissedDerivation) {
|
||||
|
|
@ -116,10 +110,9 @@ class GetCryptoCurrencyActionsUseCase(
|
|||
activeList.add(TokenActionsState.ActionState.Send(true))
|
||||
}
|
||||
|
||||
val isMulticurrencyWallet = cardTypesResolver.isTangemWallet() || cardTypesResolver.isWallet2()
|
||||
// swap
|
||||
if (isMulticurrencyWallet) {
|
||||
if (marketCryptoCurrencyRepository.isExchangeable(userWalletId, cryptoCurrency)) {
|
||||
if (userWallet.isMultiCurrency) {
|
||||
if (marketCryptoCurrencyRepository.isExchangeable(userWallet.walletId, cryptoCurrency)) {
|
||||
activeList.add(TokenActionsState.ActionState.Swap(true))
|
||||
} else {
|
||||
disabledList.add(TokenActionsState.ActionState.Swap(false))
|
||||
|
|
|
|||
|
|
@ -577,10 +577,12 @@ internal class SwapViewModel @Inject constructor(
|
|||
tokenDataState.toGroup
|
||||
}
|
||||
val available = group.available.filter {
|
||||
it.currencyStatus.currency.name.contains(searchQuery, ignoreCase = true)
|
||||
it.currencyStatus.currency.name.contains(searchQuery, ignoreCase = true) ||
|
||||
it.currencyStatus.currency.symbol.contains(searchQuery, ignoreCase = true)
|
||||
}
|
||||
val unavailable = group.unavailable.filter {
|
||||
it.currencyStatus.currency.name.contains(searchQuery, ignoreCase = true)
|
||||
it.currencyStatus.currency.name.contains(searchQuery, ignoreCase = true) ||
|
||||
it.currencyStatus.currency.symbol.contains(searchQuery, ignoreCase = true)
|
||||
}
|
||||
val filteredTokenDataState = if (isOrderReversed) {
|
||||
tokenDataState.copy(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue