Updated on 2026-08-14

This commit is contained in:
Tangem 2023-07-24 22:35:58 +08:00
parent e3c0b0b311
commit fcdfe622f9
27 changed files with 384 additions and 54 deletions

View file

@ -0,0 +1,16 @@
package com.tangem.data.card
import com.tangem.data.source.preferences.PreferencesDataSource
import com.tangem.domain.card.repository.CardRepository
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.withContext
internal class DefaultCardRepository(
private val preferencesDataSource: PreferencesDataSource,
private val dispatchers: CoroutineDispatcherProvider,
) : CardRepository {
override suspend fun wasCardScanned(cardId: String): Boolean {
return withContext(dispatchers.io) { preferencesDataSource.usedCardsPrefStorage.wasScanned(cardId) }
}
}

View file

@ -1,9 +1,12 @@
package com.tangem.data.card.di
import com.tangem.data.card.DefaultCardRepository
import com.tangem.data.card.DefaultCardSdkConfigRepository
import com.tangem.data.card.sdk.CardSdkProvider
import com.tangem.data.source.preferences.PreferencesDataSource
import com.tangem.domain.card.repository.CardRepository
import com.tangem.domain.card.repository.CardSdkConfigRepository
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
@ -25,4 +28,13 @@ internal object CardDataModule {
preferencesDataSource = preferencesDataSource,
)
}
@Provides
@Singleton
fun provideCardRepository(
preferencesDataSource: PreferencesDataSource,
dispatchers: CoroutineDispatcherProvider,
): CardRepository {
return DefaultCardRepository(preferencesDataSource = preferencesDataSource, dispatchers = dispatchers)
}
}