AppModule
This commit is contained in:
@@ -1,57 +1,29 @@
|
||||
package `in`.sminnovations.attendanceapp.di
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.preferences.core.Preferences
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import com.google.firebase.firestore.FirebaseFirestore
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import `in`.sminnovations.attendanceapp.screens.home.data.CheckInCheckOutDataStore
|
||||
import `in`.sminnovations.attendanceapp.screens.login.data.LoginDataStore
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
object AppModule {
|
||||
|
||||
private val Context.dataStore by preferencesDataStore(name = "employee_data")
|
||||
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAppContext(@ApplicationContext context: Context): Context {
|
||||
return context
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideLoginDataStore(@ApplicationContext context: Context): LoginDataStore {
|
||||
return LoginDataStore(context)
|
||||
}
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideCheckInCheckOutDataStore(@ApplicationContext context: Context): CheckInCheckOutDataStore {
|
||||
return CheckInCheckOutDataStore(context)
|
||||
}
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideFirebase(): FirebaseFirestore {
|
||||
return FirebaseFirestore.getInstance()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideEmployeeDataStore(@ApplicationContext context: Context): DataStore<Preferences> {
|
||||
return context.dataStore
|
||||
}
|
||||
|
||||
// fun provideFirebase(): FirebaseFirestore {
|
||||
// return FirebaseFirestore.getInstance()
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user