Skip to content

Commit

Permalink
feat: Implement compose navigation on splash , auth, passcode module (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 committed Aug 21, 2024
1 parent b9bde5f commit 39f9fd4
Show file tree
Hide file tree
Showing 41 changed files with 595 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,5 @@ object Constants {
const val REPORT_TYPE_ITEM = "report_type_item"
const val REPORT_PARAMETER_RESPONSE = "report_parameter_response"
const val LOAN_WITH_ASSOCIATIONS = "loanWithAssociation"
const val PASSCODE_INITIAL_LOGIN = "passcode_initial_login"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ val LightGray = Color(0xFFD3D3D3)
val BluePrimary = Color(0xFF2D5BA8)
val BluePrimaryDark = Color(0xFF9BB1E3)
val BlueSecondary = Color(0xFFD7E2FC)
val LightGreen = Color(0xFF99CC00)
val LightGreen = Color(0xFF99CC00)
val SummerSky = Color(0xFF29B6F6)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.feature.auth.login.presentation
package com.mifos.feature.auth.login

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.feature.auth.login.presentation
package com.mifos.feature.auth.login

/**
* Created by Aditya Gupta on 06/08/23.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.feature.auth.login.presentation
package com.mifos.feature.auth.login

import android.content.Context
import androidx.lifecycle.ViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.mifos.feature.auth.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.mifos.feature.auth.login.LoginScreen

fun NavGraphBuilder.authNavGraph(
navigateHome: () -> Unit,
navigatePasscode: () -> Unit,
updateServerConfig: () -> Unit
) {
navigation(
startDestination = AuthScreens.LoginScreen.route,
route = AuthScreens.LoginScreenRoute.route
) {
loginRoute(
navigatePasscode = navigatePasscode,
navigateHome = navigateHome,
updateServerConfig = updateServerConfig
)
}

}

fun NavGraphBuilder.loginRoute(
navigateHome: () -> Unit,
navigatePasscode: () -> Unit,
updateServerConfig: () -> Unit
) {
composable(
route = AuthScreens.LoginScreen.route
) {
LoginScreen(
homeIntent = navigateHome,
passcodeIntent = navigatePasscode,
onClickToUpdateServerConfig = updateServerConfig
)
}
}

fun NavController.navigateToLogin() {
navigate(AuthScreens.LoginScreen.route)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.mifos.feature.auth.navigation

sealed class AuthScreens(val route: String) {

data object LoginScreenRoute : AuthScreens("login_screen_route")

data object LoginScreen : AuthScreens("login_screen")

}
1 change: 1 addition & 0 deletions feature/passcode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
25 changes: 25 additions & 0 deletions feature/passcode/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.mifos.android.library.jacoco)
}

android {
namespace = "com.mifos.feature.passcode"
}

dependencies {
implementation(projects.core.domain)

//DBFlow dependencies
kapt(libs.dbflow.processor)
implementation(libs.dbflow)
kapt(libs.github.dbflow.processor)
testImplementation(libs.hilt.android.testing)
testImplementation(projects.core.testing)

androidTestImplementation(projects.core.testing)

// passcode dependency
implementation("com.github.openMF.mifos-passcode:compose:1.0.3")
}
Empty file.
21 changes: 21 additions & 0 deletions feature/passcode/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mifos.feature.passcode

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.mifos.feature.passcode.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions feature/passcode/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.mifos.feature.passcode.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import androidx.navigation.navigation
import com.mifos.core.common.utils.Constants
import com.mifos.feature.passcode.passcode.PasscodeScreen

fun NavGraphBuilder.passcodeNavGraph(
navController: NavController
) {
navigation(
startDestination = PasscodeScreens.PasscodeScreen.route,
route = "passcode_screen_route"
) {
passcodeScreenRoute()
}
}

fun NavGraphBuilder.passcodeScreenRoute(

) {
composable(
route = PasscodeScreens.PasscodeScreen.route,
arguments = listOf(
navArgument(
name = Constants.PASSCODE_INITIAL_LOGIN,
builder = { type = NavType.BoolType })
)
) {
PasscodeScreen(

)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.mifos.feature.passcode.navigation

sealed class PasscodeScreens(val route: String) {

data object PasscodeScreen : PasscodeScreens("passcode_screen")

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.mifos.feature.passcode.passcode

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.mifos.core.designsystem.component.MifosScaffold

@Composable
fun PasscodeScreen(
viewmodel: PasscodeViewmodel = hiltViewModel()
) {

val passcodeStatus by viewmodel.passcodeStatus.collectAsStateWithLifecycle()


}

@Composable
fun PasscodeScreen(

) {

MifosScaffold { paddingValues ->
Column(modifier = Modifier.padding(paddingValues)) {
com.mifos.compose.component.PasscodeScreen(
onForgotButton = { },
onSkipButton = { },
onPasscodeConfirm = { },
onPasscodeRejected = { }
)
}
}
}

@Preview
@Composable
private fun PasscodeScreenPreview() {
PasscodeScreen()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mifos.feature.passcode.passcode

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import com.mifos.core.common.utils.Constants
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class PasscodeViewmodel @Inject constructor(
private val savedStateHandle: SavedStateHandle
) : ViewModel() {

val passcodeStatus =
savedStateHandle.getStateFlow(key = Constants.PASSCODE_INITIAL_LOGIN, initialValue = false)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mifos.feature.passcode

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
1 change: 1 addition & 0 deletions feature/splash/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
23 changes: 23 additions & 0 deletions feature/splash/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.mifos.android.library.jacoco)
}

android {
namespace = "com.mifos.feature.splash"
}

dependencies {
implementation(projects.core.domain)

//DBFlow dependencies
kapt(libs.dbflow.processor)
implementation(libs.dbflow)
kapt(libs.github.dbflow.processor)
testImplementation(libs.hilt.android.testing)
testImplementation(projects.core.testing)

androidTestImplementation(projects.core.testing)

}
Empty file.
21 changes: 21 additions & 0 deletions feature/splash/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mifos.feature.splash

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.mifos.feature.splash.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions feature/splash/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Loading

0 comments on commit 39f9fd4

Please sign in to comment.