AppModule
This commit is contained in:
@@ -1,57 +1,29 @@
|
|||||||
package `in`.sminnovations.attendanceapp.di
|
package `in`.sminnovations.attendanceapp.di
|
||||||
|
|
||||||
import android.content.Context
|
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 com.google.firebase.firestore.FirebaseFirestore
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import dagger.hilt.components.SingletonComponent
|
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
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
object AppModule {
|
object AppModule {
|
||||||
|
|
||||||
private val Context.dataStore by preferencesDataStore(name = "employee_data")
|
|
||||||
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideAppContext(@ApplicationContext context: Context): Context {
|
fun provideAppContext(@ApplicationContext context: Context): Context {
|
||||||
return 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
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideFirebase(): FirebaseFirestore {
|
fun provideFirebase(): FirebaseFirestore {
|
||||||
return FirebaseFirestore.getInstance()
|
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