Updated on 2026-08-14
This commit is contained in:
parent
36fabffe3a
commit
c8da4e40e1
3 changed files with 10 additions and 3 deletions
|
|
@ -1,9 +1,15 @@
|
|||
package com.tangem.utils
|
||||
|
||||
import java.math.BigDecimal
|
||||
|
||||
inline fun <reified T : Enum<T>> safeValueOf(type: String, default: T): T {
|
||||
return try {
|
||||
java.lang.Enum.valueOf(T::class.java, type)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
default
|
||||
}
|
||||
}
|
||||
|
||||
fun BigDecimal?.isNullOrZero(): Boolean {
|
||||
return this == null || this.compareTo(BigDecimal.ZERO) == 0
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import com.tangem.domain.tokens.model.TokenActionsState
|
|||
import com.tangem.domain.tokens.repository.MarketCryptoCurrencyRepository
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.isNullOrZero
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
|
|
@ -70,7 +71,7 @@ class GetCryptoCurrencyActionsUseCase(
|
|||
}
|
||||
|
||||
// send
|
||||
if (cryptoCurrencyStatus.value.amount?.signum() == 0) {
|
||||
if (cryptoCurrencyStatus.value.amount.isNullOrZero()) {
|
||||
disabledList.add(TokenActionsState.ActionState.Send(false))
|
||||
} else {
|
||||
activeList.add(TokenActionsState.ActionState.Send(true))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.factory
|
||||
|
||||
import com.tangem.common.extensions.isZero
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
|
|
@ -9,6 +8,7 @@ import com.tangem.feature.wallet.impl.R
|
|||
import com.tangem.feature.wallet.presentation.common.state.TokenItemState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.TokenActionButtonConfig
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
import com.tangem.utils.isNullOrZero
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ internal class TokenActionsProvider(private val clickIntents: WalletClickIntents
|
|||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
): TokenActionButtonConfig? {
|
||||
if (actionsState is TokenActionsState.ActionState.Send &&
|
||||
cryptoCurrencyStatus.value.amount?.isZero() == true
|
||||
cryptoCurrencyStatus.value.amount.isNullOrZero()
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue