diff --git a/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/di/DataSourceModule.kt b/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/di/DataSourceModule.kt new file mode 100644 index 00000000..9b2b5f66 --- /dev/null +++ b/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/di/DataSourceModule.kt @@ -0,0 +1,18 @@ +package com.goalpanzi.mission_mate.core.datastore.di + +import com.goalpanzi.mission_mate.core.datastore.datasource.AuthDataSource +import com.goalpanzi.mission_mate.core.datastore.datasource.AuthDataSourceImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent + +@Module +@InstallIn(SingletonComponent::class) +abstract class DataSourceModule { + + @Binds + abstract fun bindAuthDataSource( + authDataSource: AuthDataSourceImpl + ): AuthDataSource +} \ No newline at end of file diff --git a/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/di/DataStoreModule.kt b/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/di/DataStoreModule.kt new file mode 100644 index 00000000..c879f392 --- /dev/null +++ b/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/di/DataStoreModule.kt @@ -0,0 +1,29 @@ +package com.goalpanzi.mission_mate.core.datastore.di + +import android.content.Context +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.preferencesDataStoreFile +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +private const val AUTH_PREFERENCES = "auth_preferences" + +@InstallIn(SingletonComponent::class) +@Module +object DataStoreModule { + @Singleton + @Provides + fun provideAuthPreferencesDataStore( + @ApplicationContext context: Context + ): DataStore { + return PreferenceDataStoreFactory.create( + produceFile = { context.preferencesDataStoreFile(AUTH_PREFERENCES) } + ) + } +} \ No newline at end of file