├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── raw │ │ │ │ ├── home.png │ │ │ │ ├── signin.png │ │ │ │ ├── signup.png │ │ │ │ ├── email_sent.jpg │ │ │ │ ├── reset_password.png │ │ │ │ ├── home_after_signin.png │ │ │ │ └── home_after_signup.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable │ │ │ │ ├── ic_error.xml │ │ │ │ ├── ic_mail.xml │ │ │ │ ├── ic_person_grey.xml │ │ │ │ ├── ic_password.xml │ │ │ │ ├── ic_username.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── fragment_home.xml │ │ │ │ ├── fragment_password_reset.xml │ │ │ │ ├── fragment_signin.xml │ │ │ │ └── fragment_signup.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── navigation │ │ │ │ └── nav_graph.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── dev │ │ │ │ └── james │ │ │ │ └── firebasemvvm │ │ │ │ ├── BaseApplication.kt │ │ │ │ ├── repository │ │ │ │ ├── firebase │ │ │ │ │ ├── BaseAuthenticator.kt │ │ │ │ │ └── FirebaseAuthenticator.kt │ │ │ │ ├── BaseAuthRepository.kt │ │ │ │ └── AuthRepository.kt │ │ │ │ ├── di │ │ │ │ └── AppModule.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ ├── ui │ │ │ │ ├── home │ │ │ │ │ └── HomeFragment.kt │ │ │ │ └── authentication │ │ │ │ │ ├── ResetPasswordFragment.kt │ │ │ │ │ ├── SignInFragment.kt │ │ │ │ │ └── SignUpFragment.kt │ │ │ │ └── viewmodels │ │ │ │ └── MainViewModel.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── dev │ │ │ └── james │ │ │ └── firebasemvvm │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── dev │ │ └── james │ │ └── firebasemvvm │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro ├── google-services.json └── build.gradle ├── .idea ├── .gitignore ├── compiler.xml ├── vcs.xml ├── deploymentTargetDropDown.xml ├── gradle.xml └── misc.xml ├── home.png ├── signup.png ├── email_sent.jpg ├── reset_password.png ├── home_after_signin.png ├── home_after_signup.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/home.png -------------------------------------------------------------------------------- /signup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/signup.png -------------------------------------------------------------------------------- /email_sent.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/email_sent.jpg -------------------------------------------------------------------------------- /reset_password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/reset_password.png -------------------------------------------------------------------------------- /home_after_signin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/home_after_signin.png -------------------------------------------------------------------------------- /home_after_signup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/home_after_signup.png -------------------------------------------------------------------------------- /app/src/main/res/raw/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/raw/home.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FirebaseMVVM 3 | -------------------------------------------------------------------------------- /app/src/main/res/raw/signin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/raw/signin.png -------------------------------------------------------------------------------- /app/src/main/res/raw/signup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/raw/signup.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/raw/email_sent.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/raw/email_sent.jpg -------------------------------------------------------------------------------- /app/src/main/res/raw/reset_password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/raw/reset_password.png -------------------------------------------------------------------------------- /app/src/main/res/raw/home_after_signin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/raw/home_after_signin.png -------------------------------------------------------------------------------- /app/src/main/res/raw/home_after_signup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/raw/home_after_signup.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayExtra/FirebaseMVVMApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/dev/james/firebasemvvm/BaseApplication.kt: -------------------------------------------------------------------------------- 1 | package com.dev.james.firebasemvvm 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class BaseApplication : Application() -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Aug 18 16:53:03 EAT 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() // Warning: this repository is going to shut down soon 7 | } 8 | } 9 | rootProject.name = "FirebaseMVVM" 10 | include ':app' 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_error.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_mail.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_person_grey.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/test/java/com/dev/james/firebasemvvm/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.dev.james.firebasemvvm 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_password.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/deploymentTargetDropDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_username.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/dev/james/firebasemvvm/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.dev.james.firebasemvvm 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.dev.james.firebasemvvm", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/dev/james/firebasemvvm/repository/firebase/BaseAuthenticator.kt: -------------------------------------------------------------------------------- 1 | package com.dev.james.firebasemvvm.repository.firebase 2 | 3 | import com.google.firebase.auth.FirebaseUser 4 | 5 | interface BaseAuthenticator { 6 | 7 | //this class will implement all the basic authentication api calls. Using this method of abstraction 8 | //will allow us to implement any type of authentication api may it be 9 | //that you have built your own or Firebase auth sdks. This makes it easy to swap 10 | //in the future because all authentication classes you will use will inherit behaviour from this base class. 11 | //Also in testing it will make it easy to swap your actual sdks with fake ones 12 | 13 | suspend fun signUpWithEmailPassword(email:String , password:String) : FirebaseUser? 14 | 15 | suspend fun signInWithEmailPassword(email: String , password: String):FirebaseUser? 16 | 17 | fun signOut() : FirebaseUser? 18 | 19 | fun getUser() : FirebaseUser? 20 | 21 | suspend fun sendPasswordReset(email :String) 22 | } -------------------------------------------------------------------------------- /app/src/main/java/com/dev/james/firebasemvvm/repository/BaseAuthRepository.kt: -------------------------------------------------------------------------------- 1 | package com.dev.james.firebasemvvm.repository 2 | 3 | import com.google.firebase.auth.FirebaseUser 4 | 5 | interface BaseAuthRepository { 6 | 7 | //this is an interface that will implement all common authentication 8 | //functions. That is sign in , sign up , logout. Taking this approach will allow us 9 | // to rely on abstractions rather than a concrete authentication repository class. This 10 | //will make it easy for us to test and maintain in that whatever form of repository class 11 | //we will use it won't matter since all will inherit from this class. So swapping 12 | //of repositories will be easy. 13 | 14 | suspend fun signInWithEmailPassword(email:String , password:String): FirebaseUser? 15 | 16 | suspend fun signUpWithEmailPassword(email: String , password: String): FirebaseUser? 17 | 18 | fun signOut() : FirebaseUser? 19 | 20 | fun getCurrentUser() : FirebaseUser? 21 | 22 | suspend fun sendResetPassword(email : String) : Boolean 23 | } -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/dev/james/firebasemvvm/repository/AuthRepository.kt: -------------------------------------------------------------------------------- 1 | package com.dev.james.firebasemvvm.repository 2 | 3 | import com.dev.james.firebasemvvm.repository.firebase.BaseAuthenticator 4 | import com.google.firebase.auth.FirebaseUser 5 | import javax.inject.Inject 6 | 7 | class AuthRepository @Inject constructor( 8 | private val authenticator : BaseAuthenticator 9 | ) : BaseAuthRepository { 10 | override suspend fun signInWithEmailPassword(email: String, password: String): FirebaseUser? { 11 | return authenticator.signInWithEmailPassword(email , password) 12 | } 13 | 14 | override suspend fun signUpWithEmailPassword(email: String, password: String): FirebaseUser? { 15 | return authenticator.signUpWithEmailPassword(email , password) 16 | } 17 | 18 | override fun signOut(): FirebaseUser? { 19 | return authenticator.signOut() 20 | } 21 | 22 | override fun getCurrentUser(): FirebaseUser? { 23 | return authenticator.getUser() 24 | } 25 | 26 | override suspend fun sendResetPassword(email: String): Boolean { 27 | authenticator.sendPasswordReset(email) 28 | return true 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/java/com/dev/james/firebasemvvm/repository/firebase/FirebaseAuthenticator.kt: -------------------------------------------------------------------------------- 1 | package com.dev.james.firebasemvvm.repository.firebase 2 | 3 | import com.google.firebase.auth.FirebaseUser 4 | import com.google.firebase.auth.ktx.auth 5 | import com.google.firebase.ktx.Firebase 6 | import kotlinx.coroutines.tasks.await 7 | 8 | class FirebaseAuthenticator : BaseAuthenticator { 9 | override suspend fun signUpWithEmailPassword(email: String, password: String): FirebaseUser? { 10 | Firebase.auth.createUserWithEmailAndPassword(email,password).await() 11 | return Firebase.auth.currentUser 12 | } 13 | 14 | override suspend fun signInWithEmailPassword(email: String, password: String): FirebaseUser? { 15 | Firebase.auth.signInWithEmailAndPassword(email , password).await() 16 | return Firebase.auth.currentUser 17 | } 18 | 19 | override fun signOut(): FirebaseUser? { 20 | Firebase.auth.signOut() 21 | return Firebase.auth.currentUser 22 | } 23 | 24 | override fun getUser(): FirebaseUser? { 25 | return Firebase.auth.currentUser 26 | } 27 | 28 | override suspend fun sendPasswordReset(email: String) { 29 | Firebase.auth.sendPasswordResetEmail(email).await() 30 | } 31 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /app/src/main/java/com/dev/james/firebasemvvm/di/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.dev.james.firebasemvvm.di 2 | 3 | import com.dev.james.firebasemvvm.repository.AuthRepository 4 | import com.dev.james.firebasemvvm.repository.BaseAuthRepository 5 | import com.dev.james.firebasemvvm.repository.firebase.BaseAuthenticator 6 | import com.dev.james.firebasemvvm.repository.firebase.FirebaseAuthenticator 7 | import dagger.Module 8 | import dagger.Provides 9 | import dagger.hilt.InstallIn 10 | import dagger.hilt.components.SingletonComponent 11 | import javax.inject.Singleton 12 | 13 | @Module 14 | @InstallIn(SingletonComponent::class) 15 | object AppModule { 16 | 17 | /**All of our application dependencies shall be provided here*/ 18 | 19 | //this means that anytime we need an authenticator Dagger will provide a Firebase authenticator. 20 | //in future if you want to swap out Firebase authentication for your own custom authenticator 21 | //you will simply come and swap here. 22 | @Singleton 23 | @Provides 24 | fun provideAuthenticator() : BaseAuthenticator{ 25 | return FirebaseAuthenticator() 26 | } 27 | 28 | //this just takes the same idea as the authenticator. If we create another repository class 29 | //we can simply just swap here 30 | @Singleton 31 | @Provides 32 | fun provideRepository( 33 | authenticator : BaseAuthenticator 34 | ) : BaseAuthRepository { 35 | return AuthRepository(authenticator) 36 | } 37 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 21 | 22 |