Updated on 2026-08-14

This commit is contained in:
Tangem 2023-08-22 12:41:19 +01:00
parent f120b184ac
commit 55641cab14
2 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,32 @@
package com.tangem.domain.tokens
import com.tangem.domain.tokens.model.TokenActionsState
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.flow.*
class GetCryptoCurrencyActionsUseCase(
private val dispatchers: CoroutineDispatcherProvider,
) {
operator fun invoke(userWalletId: UserWalletId, tokenId: String): Flow<TokenActionsState> {
return flow {
emit(getMockState(userWalletId, tokenId))
}.flowOn(dispatchers.io)
}
// TODO replace by real data
private fun getMockState(userWalletId: UserWalletId, tokenId: String): TokenActionsState {
return TokenActionsState(
walletId = userWalletId,
tokenId = tokenId,
states = listOf(
TokenActionsState.ActionState.Buy(true),
TokenActionsState.ActionState.Sell(true),
TokenActionsState.ActionState.Receive(true),
TokenActionsState.ActionState.Swap(true),
TokenActionsState.ActionState.Sell(true),
),
)
}
}

View file

@ -0,0 +1,25 @@
package com.tangem.domain.tokens.model
import com.tangem.domain.wallets.models.UserWalletId
data class TokenActionsState(
val walletId: UserWalletId,
val tokenId: String,
val states: List<ActionState>,
) {
sealed class ActionState {
abstract val enabled: Boolean
data class Buy(override val enabled: Boolean) : ActionState()
data class Sell(override val enabled: Boolean) : ActionState()
data class Receive(override val enabled: Boolean) : ActionState()
data class Swap(override val enabled: Boolean) : ActionState()
data class Send(override val enabled: Boolean) : ActionState()
}
}