diff --git a/core/common/src/main/java/com/mifos/core/common/utils/Constants.kt b/core/common/src/main/java/com/mifos/core/common/utils/Constants.kt index c456a11a48e..e8d249f3740 100644 --- a/core/common/src/main/java/com/mifos/core/common/utils/Constants.kt +++ b/core/common/src/main/java/com/mifos/core/common/utils/Constants.kt @@ -79,6 +79,7 @@ object Constants { const val ACTIVATE_CENTER = "activate_center" const val ACTIVATE_GROUP = "activate_group" const val ACTIVATE_TYPE = "activation_type" + const val ACTIVATE_ID = "activation_id" const val INTIAL_LOGIN = "initial_login" const val INDIVIDUAL_SHEET = "collection_sheet" const val DISBURSEMENT_DATE = "disbursement_date" @@ -216,4 +217,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" } \ No newline at end of file diff --git a/core/designsystem/src/main/java/com/mifos/core/designsystem/theme/Color.kt b/core/designsystem/src/main/java/com/mifos/core/designsystem/theme/Color.kt index 8575c31bfed..34932289d9b 100644 --- a/core/designsystem/src/main/java/com/mifos/core/designsystem/theme/Color.kt +++ b/core/designsystem/src/main/java/com/mifos/core/designsystem/theme/Color.kt @@ -9,4 +9,5 @@ val LightGray = Color(0xFFD3D3D3) val BluePrimary = Color(0xFF2D5BA8) val BluePrimaryDark = Color(0xFF9BB1E3) val BlueSecondary = Color(0xFFD7E2FC) -val LightGreen = Color(0xFF99CC00) \ No newline at end of file +val LightGreen = Color(0xFF99CC00) +val SummerSky = Color(0xFF29B6F6) \ No newline at end of file diff --git a/feature/about/src/main/java/com/mifos/feature/about/navigation/AboutScreens.kt b/feature/about/src/main/java/com/mifos/feature/about/navigation/AboutScreens.kt new file mode 100644 index 00000000000..a12e9cf564a --- /dev/null +++ b/feature/about/src/main/java/com/mifos/feature/about/navigation/AboutScreens.kt @@ -0,0 +1,8 @@ +package com.mifos.feature.about.navigation + +/** + * Created by Pronay Sarker on 18/08/2024 (2:42 PM) + */ +sealed class AboutScreens(val route: String) { + data object AboutScreen : AboutScreens(route = "about_screen_route") +} \ No newline at end of file diff --git a/feature/about/src/main/java/com/mifos/feature/about/navigation/AccountNavigation.kt b/feature/about/src/main/java/com/mifos/feature/about/navigation/AccountNavigation.kt index 8ac6aee61ce..90932499b25 100644 --- a/feature/about/src/main/java/com/mifos/feature/about/navigation/AccountNavigation.kt +++ b/feature/about/src/main/java/com/mifos/feature/about/navigation/AccountNavigation.kt @@ -8,18 +8,16 @@ import com.mifos.feature.about.AboutScreen /** * Created by Pronay Sarker on 10/08/2024 (7:56 AM) */ -const val ABOUT_SCREEN_ROUTE = "about_screen_route" - -fun NavController.navigateToAboutScreen() { - this.navigate(ABOUT_SCREEN_ROUTE) -} - fun NavGraphBuilder.aboutScreen( onBackPressed: () -> Unit ) { - composable(ABOUT_SCREEN_ROUTE) { + composable(AboutScreens.AboutScreen.route) { AboutScreen( onBackPressed = onBackPressed ) } -} \ No newline at end of file +} + +fun NavController.navigateToAboutScreen() { + navigate(AboutScreens.AboutScreen.route) +} diff --git a/feature/activate/src/main/java/com/mifos/feature/activate/ActivateScreen.kt b/feature/activate/src/main/java/com/mifos/feature/activate/ActivateScreen.kt index 6c9beba63f6..8ebcbfb5542 100644 --- a/feature/activate/src/main/java/com/mifos/feature/activate/ActivateScreen.kt +++ b/feature/activate/src/main/java/com/mifos/feature/activate/ActivateScreen.kt @@ -52,13 +52,13 @@ import java.util.Locale @Composable fun ActivateScreen( - id: Int, - activateType: String, onBackPressed: () -> Unit ) { val viewModel: ActivateViewModel = hiltViewModel() val state by viewModel.activateUiState.collectAsStateWithLifecycle() + val id by viewModel.id.collectAsStateWithLifecycle() + val activateType by viewModel.activateType.collectAsStateWithLifecycle() ActivateScreen( state = state, diff --git a/feature/activate/src/main/java/com/mifos/feature/activate/ActivateViewModel.kt b/feature/activate/src/main/java/com/mifos/feature/activate/ActivateViewModel.kt index 8e5e802987b..c0a43b26ca7 100644 --- a/feature/activate/src/main/java/com/mifos/feature/activate/ActivateViewModel.kt +++ b/feature/activate/src/main/java/com/mifos/feature/activate/ActivateViewModel.kt @@ -1,7 +1,9 @@ package com.mifos.feature.activate +import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.mifos.core.common.utils.Constants import com.mifos.core.common.utils.Resource import com.mifos.core.domain.use_cases.ActivateCenterUseCase import com.mifos.core.domain.use_cases.ActivateClientUseCase @@ -18,9 +20,13 @@ import javax.inject.Inject class ActivateViewModel @Inject constructor( private val activateClientUseCase: ActivateClientUseCase, private val activateCenterUseCase: ActivateCenterUseCase, - private val activateGroupUseCase: ActivateGroupUseCase + private val activateGroupUseCase: ActivateGroupUseCase, + savedStateHandle: SavedStateHandle ) : ViewModel() { + val id = savedStateHandle.getStateFlow(key = Constants.ACTIVATE_ID, initialValue = 0) + val activateType = savedStateHandle.getStateFlow(key = Constants.ACTIVATE_TYPE, initialValue = "") + private val _activateUiState = MutableStateFlow(ActivateUiState.Initial) val activateUiState = _activateUiState.asStateFlow() diff --git a/feature/activate/src/main/java/com/mifos/feature/activate/navigation/ActivateNavigation.kt b/feature/activate/src/main/java/com/mifos/feature/activate/navigation/ActivateNavigation.kt new file mode 100644 index 00000000000..4aebcb69bda --- /dev/null +++ b/feature/activate/src/main/java/com/mifos/feature/activate/navigation/ActivateNavigation.kt @@ -0,0 +1,32 @@ +package com.mifos.feature.activate.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavType +import androidx.navigation.compose.composable +import androidx.navigation.navArgument +import com.mifos.core.common.utils.Constants +import com.mifos.feature.activate.ActivateScreen + +/** + * Created by Pronay Sarker on 18/08/2024 (1:40 PM) + */ +fun NavGraphBuilder.activateScreen( + onBackPressed: () -> Unit +) { + composable( + route = ActivateScreens.ActivateScreen.route, + arguments = listOf( + navArgument(name = Constants.ACTIVATE_ID, builder = { NavType.IntType }), + navArgument(name = Constants.ACTIVATE_TYPE, builder = { NavType.StringType }) + ) + ) { + ActivateScreen( + onBackPressed = onBackPressed + ) + } +} + +fun NavController.navigateToActivateScreen(id : Int, type : String){ + navigate(ActivateScreens.ActivateScreen.argument(id, type)) +} \ No newline at end of file diff --git a/feature/activate/src/main/java/com/mifos/feature/activate/navigation/ActivateScreens.kt b/feature/activate/src/main/java/com/mifos/feature/activate/navigation/ActivateScreens.kt new file mode 100644 index 00000000000..5b466e3257d --- /dev/null +++ b/feature/activate/src/main/java/com/mifos/feature/activate/navigation/ActivateScreens.kt @@ -0,0 +1,12 @@ +package com.mifos.feature.activate.navigation + +import com.mifos.core.common.utils.Constants + +/** + * Created by Pronay Sarker on 18/08/2024 (1:40 PM) + */ +sealed class ActivateScreens(val route: String) { + data object ActivateScreen : ActivateScreens("activate_screen/{${Constants.ACTIVATE_ID}}/{${Constants.ACTIVATE_TYPE}}") { + fun argument(id: Int, type: String) = "activate_screen/$id/$type" + } +} \ No newline at end of file diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginScreen.kt b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginScreen.kt similarity index 99% rename from feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginScreen.kt rename to feature/auth/src/main/java/com/mifos/feature/auth/login/LoginScreen.kt index 63f753236d4..08d80f378a1 100644 --- a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginScreen.kt +++ b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginScreen.kt @@ -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 diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginUiState.kt b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginUiState.kt similarity index 90% rename from feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginUiState.kt rename to feature/auth/src/main/java/com/mifos/feature/auth/login/LoginUiState.kt index fdb409b0c37..48b5c57ad7b 100644 --- a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginUiState.kt +++ b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginUiState.kt @@ -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. diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginViewModel.kt b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt similarity index 98% rename from feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginViewModel.kt rename to feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt index 65e7ef2c556..3217fec6cc2 100644 --- a/feature/auth/src/main/java/com/mifos/feature/auth/login/presentation/LoginViewModel.kt +++ b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt @@ -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 diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthNavigation.kt b/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthNavigation.kt new file mode 100644 index 00000000000..d72e070a583 --- /dev/null +++ b/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthNavigation.kt @@ -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) +} \ No newline at end of file diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthScreens.kt b/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthScreens.kt new file mode 100644 index 00000000000..d64d4948e74 --- /dev/null +++ b/feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthScreens.kt @@ -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") + +} \ No newline at end of file diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetScreen.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetScreen.kt index 359427bd5e5..98a18b89020 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetScreen.kt +++ b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetScreen.kt @@ -195,6 +195,7 @@ fun GenerateCollectionSheetScreen( } } +@OptIn(ExperimentalMaterial3Api::class) @Composable fun GenerateCollectionSheetContent( centerDetailsState: List?, diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet/ui/IndividualCollectionSheetScreen.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet/ui/IndividualCollectionSheetScreen.kt index e8d31d76b32..5e42bb66f11 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet/ui/IndividualCollectionSheetScreen.kt +++ b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet/ui/IndividualCollectionSheetScreen.kt @@ -27,7 +27,6 @@ fun IndividualCollectionSheetScreen( onBackPressed: () -> Unit, onDetail: (String, IndividualCollectionSheet) -> Unit, ) { - val snackbarHostState = remember { SnackbarHostState() } val pagerState = rememberPagerState( diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsScreen.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsScreen.kt index 1c6738db1df..a5bfa6c8010 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsScreen.kt +++ b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsScreen.kt @@ -65,17 +65,16 @@ import com.mifos.feature.collection_sheet.R @Composable fun IndividualCollectionSheetDetailsScreen( - sheet: IndividualCollectionSheet, onBackPressed: () -> Unit, submit: (Int, IndividualCollectionSheetPayload, List, LoanAndClientName, List, Int) -> Unit ) { val viewModel: IndividualCollectionSheetDetailsViewModel = hiltViewModel() val state by viewModel.individualCollectionSheetDetailsUiState.collectAsStateWithLifecycle() - val loansAndClientNames = viewModel.filterLoanAndClientNames(sheet.clients ?: emptyList()) + val loansAndClientNames = viewModel.filterLoanAndClientNames(viewModel.sheet.clients ?: emptyList()) IndividualCollectionSheetDetailsScreen( - sheet = sheet, + sheet = viewModel.sheet, loansAndClientNames = loansAndClientNames, state = state, onBackPressed = onBackPressed, diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsViewModel.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsViewModel.kt index bd6311c96a9..9f676f86664 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsViewModel.kt +++ b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsViewModel.kt @@ -1,11 +1,15 @@ package com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details +import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.google.gson.Gson +import com.mifos.core.common.utils.Constants import com.mifos.core.common.utils.Resource import com.mifos.core.domain.use_cases.SaveIndividualCollectionSheetUseCase import com.mifos.core.network.model.IndividualCollectionSheetPayload import com.mifos.core.objects.collectionsheet.ClientCollectionSheet +import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet import com.mifos.core.objects.collectionsheet.LoanAndClientName import com.mifos.feature.collection_sheet.R import dagger.hilt.android.lifecycle.HiltViewModel @@ -18,9 +22,13 @@ import javax.inject.Inject @HiltViewModel class IndividualCollectionSheetDetailsViewModel @Inject constructor( - private val saveIndividualCollectionSheetUseCase: SaveIndividualCollectionSheetUseCase + private val saveIndividualCollectionSheetUseCase: SaveIndividualCollectionSheetUseCase, + savedStateHandle: SavedStateHandle ) : ViewModel() { + private val arg = savedStateHandle.getStateFlow(key = Constants.INDIVIDUAL_SHEET, initialValue = "" ) + val sheet : IndividualCollectionSheet = Gson().fromJson(arg.value, IndividualCollectionSheet::class.java) + private val _individualCollectionSheetDetailsUiState = MutableStateFlow( IndividualCollectionSheetDetailsUiState.Empty diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetNavigation.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetNavigation.kt new file mode 100644 index 00000000000..7bb7a09889f --- /dev/null +++ b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetNavigation.kt @@ -0,0 +1,89 @@ +package com.mifos.feature.individual_collection_sheet.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.core.network.model.IndividualCollectionSheetPayload +import com.mifos.core.objects.accounts.loan.PaymentTypeOptions +import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet +import com.mifos.core.objects.collectionsheet.LoanAndClientName +import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetScreen +import com.mifos.feature.individual_collection_sheet.individual_collection_sheet.ui.IndividualCollectionSheetScreen +import com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details.IndividualCollectionSheetDetailsScreen + +/** + * Created by Pronay Sarker on 20/08/2024 (4:06 PM) + */ +fun NavGraphBuilder.individualCollectionSheetNavGraph( + navController: NavController, + onBackPressed: () -> Unit, + navigateToPaymentDetails: (Int, IndividualCollectionSheetPayload, List, LoanAndClientName, List, Int) -> Unit +) { + navigation( + route = "generate_collection_sheet", + startDestination = CollectionSheetScreens.IndividualCollectionSheetScreen.route + ) { + individualCollectionSheetScreen( + onBackPressed = onBackPressed, + onDetail = { _, sheet -> navController.navigateToIndividualCollectionSheetDetailScreen(sheet) } + ) + + individualCollectionSheetDetailScreen( + onBackPressed = onBackPressed, + submit = navigateToPaymentDetails + ) + } +} + +private fun NavGraphBuilder.individualCollectionSheetScreen( + onBackPressed: () -> Unit, + onDetail: (String, IndividualCollectionSheet) -> Unit +) { + composable( + route = CollectionSheetScreens.IndividualCollectionSheetScreen.route + ) { + IndividualCollectionSheetScreen( + onBackPressed = onBackPressed, + onDetail = onDetail + ) + } +} + +private fun NavGraphBuilder.individualCollectionSheetDetailScreen( + onBackPressed: () -> Unit, + submit: (Int, IndividualCollectionSheetPayload, List, LoanAndClientName, List, Int) -> Unit +) { + composable( + route = CollectionSheetScreens.IndividualCollectionSheetDetailScreen.route, + arguments = listOf( + navArgument(name = Constants.INDIVIDUAL_SHEET, builder = { NavType.StringType }) + ) + ) { + IndividualCollectionSheetDetailsScreen( + onBackPressed = onBackPressed, + submit = submit + ) + } +} + +fun NavGraphBuilder.generateCollectionSheetScreen( + onBackPressed: () -> Unit +) { + composable(CollectionSheetScreens.GenerateCollectionSheetScreen.route) { + GenerateCollectionSheetScreen( + onBackPressed = onBackPressed + ) + } +} + +fun NavController.navigateToIndividualCollectionSheetDetailScreen(sheet: IndividualCollectionSheet) { + navigate(CollectionSheetScreens.IndividualCollectionSheetDetailScreen.argument(sheet)) +} + +fun NavController.navigateToIndividualCollectionSheet() { + navigate(CollectionSheetScreens.IndividualCollectionSheetScreen.route) +} \ No newline at end of file diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetScreens.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetScreens.kt new file mode 100644 index 00000000000..209a63136e4 --- /dev/null +++ b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetScreens.kt @@ -0,0 +1,26 @@ +package com.mifos.feature.individual_collection_sheet.navigation + +import com.google.gson.Gson +import com.mifos.core.common.utils.Constants +import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet +import com.mifos.core.objects.db.CollectionSheet +import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetUiState + +/** + * Created by Pronay Sarker on 20/08/2024 (4:11 PM) + */ +sealed class CollectionSheetScreens(val route: String) { + + data object GenerateCollectionSheetScreen : CollectionSheetScreens("generate_collection_sheet_route") + + data object IndividualCollectionSheetScreen : CollectionSheetScreens("individual_collection_sheet_route") + + data object IndividualCollectionSheetDetailScreen : CollectionSheetScreens("individual_collection_sheet_detail/{${Constants.INDIVIDUAL_SHEET}}") { + fun argument(sheet: IndividualCollectionSheet): String { + val gson = Gson() + val sheetInGsonString = gson.toJson(sheet) + + return "individual_collection_sheet_detail/$sheetInGsonString" + } + } +} \ No newline at end of file diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/GenerateCollectionSheetNavigation.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/GenerateCollectionSheetNavigation.kt deleted file mode 100644 index 4d43e9c23f4..00000000000 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/GenerateCollectionSheetNavigation.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.mifos.feature.individual_collection_sheet.navigation - -import androidx.navigation.NavController -import androidx.navigation.NavGraphBuilder -import androidx.navigation.compose.composable -import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetScreen - -/** - * Created by Pronay Sarker on 10/08/2024 (7:30 AM) - */ -const val GENERATE_COLLECTION_SHEET_SCREEN_ROUTE = "generate_collection_sheet_route" - -fun NavController.navigateToGenerateCollectionSheet() { - this.navigate(GENERATE_COLLECTION_SHEET_SCREEN_ROUTE) -} - -fun NavGraphBuilder.generateCollectionSheetScreen( - onBackPressed: () -> Unit -){ - composable(GENERATE_COLLECTION_SHEET_SCREEN_ROUTE) { - GenerateCollectionSheetScreen ( - onBackPressed = onBackPressed - ) - } -} \ No newline at end of file diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/IndividualCollectionSheetNavigation.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/IndividualCollectionSheetNavigation.kt deleted file mode 100644 index e3fe4293924..00000000000 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/IndividualCollectionSheetNavigation.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.mifos.feature.individual_collection_sheet.navigation - -import androidx.navigation.NavController -import androidx.navigation.NavGraphBuilder -import androidx.navigation.compose.composable -import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet -import com.mifos.feature.individual_collection_sheet.individual_collection_sheet.ui.IndividualCollectionSheetScreen - -/** - * Created by Pronay Sarker on 10/08/2024 (7:24 AM) - */ -const val INDIVIDUAL_COLLECTION_SHEET_SCREEN_ROUTE = "individual_collection_sheet_route" - -fun NavController.navigateToIndividualCollectionSheet() { - this.navigate(INDIVIDUAL_COLLECTION_SHEET_SCREEN_ROUTE) -} - -fun NavGraphBuilder.individualCollectionSheetScreen( - onBackClicked: () -> Unit, - onDetail: (String, IndividualCollectionSheet) -> Unit, -){ - composable(INDIVIDUAL_COLLECTION_SHEET_SCREEN_ROUTE) { - IndividualCollectionSheetScreen( - onBackPressed = {}, - onDetail = { _, _ -> } - ) - } -} \ No newline at end of file diff --git a/feature/passcode/.gitignore b/feature/passcode/.gitignore new file mode 100644 index 00000000000..42afabfd2ab --- /dev/null +++ b/feature/passcode/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/passcode/build.gradle.kts b/feature/passcode/build.gradle.kts new file mode 100644 index 00000000000..f3e8f90b5af --- /dev/null +++ b/feature/passcode/build.gradle.kts @@ -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") +} \ No newline at end of file diff --git a/feature/passcode/consumer-rules.pro b/feature/passcode/consumer-rules.pro new file mode 100644 index 00000000000..e69de29bb2d diff --git a/feature/passcode/proguard-rules.pro b/feature/passcode/proguard-rules.pro new file mode 100644 index 00000000000..481bb434814 --- /dev/null +++ b/feature/passcode/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/feature/passcode/src/androidTest/java/com/mifos/feature/passcode/ExampleInstrumentedTest.kt b/feature/passcode/src/androidTest/java/com/mifos/feature/passcode/ExampleInstrumentedTest.kt new file mode 100644 index 00000000000..73c1fc6f9b2 --- /dev/null +++ b/feature/passcode/src/androidTest/java/com/mifos/feature/passcode/ExampleInstrumentedTest.kt @@ -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) + } +} \ No newline at end of file diff --git a/feature/passcode/src/main/AndroidManifest.xml b/feature/passcode/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..a5918e68abc --- /dev/null +++ b/feature/passcode/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeNavigation.kt b/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeNavigation.kt new file mode 100644 index 00000000000..72562661abb --- /dev/null +++ b/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeNavigation.kt @@ -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( + + ) + } +} \ No newline at end of file diff --git a/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeScreens.kt b/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeScreens.kt new file mode 100644 index 00000000000..35656df6ba4 --- /dev/null +++ b/feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeScreens.kt @@ -0,0 +1,7 @@ +package com.mifos.feature.passcode.navigation + +sealed class PasscodeScreens(val route: String) { + + data object PasscodeScreen : PasscodeScreens("passcode_screen") + +} \ No newline at end of file diff --git a/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeScreen.kt b/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeScreen.kt new file mode 100644 index 00000000000..8b8dd7cd27c --- /dev/null +++ b/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeScreen.kt @@ -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() +} \ No newline at end of file diff --git a/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeViewmodel.kt b/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeViewmodel.kt new file mode 100644 index 00000000000..3d8e63b537e --- /dev/null +++ b/feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeViewmodel.kt @@ -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) + +} \ No newline at end of file diff --git a/feature/passcode/src/test/java/com/mifos/feature/passcode/ExampleUnitTest.kt b/feature/passcode/src/test/java/com/mifos/feature/passcode/ExampleUnitTest.kt new file mode 100644 index 00000000000..9a506a4c167 --- /dev/null +++ b/feature/passcode/src/test/java/com/mifos/feature/passcode/ExampleUnitTest.kt @@ -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) + } +} \ No newline at end of file diff --git a/feature/splash/.gitignore b/feature/splash/.gitignore new file mode 100644 index 00000000000..42afabfd2ab --- /dev/null +++ b/feature/splash/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/splash/build.gradle.kts b/feature/splash/build.gradle.kts new file mode 100644 index 00000000000..fcdf2a24745 --- /dev/null +++ b/feature/splash/build.gradle.kts @@ -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) + +} \ No newline at end of file diff --git a/feature/splash/consumer-rules.pro b/feature/splash/consumer-rules.pro new file mode 100644 index 00000000000..e69de29bb2d diff --git a/feature/splash/proguard-rules.pro b/feature/splash/proguard-rules.pro new file mode 100644 index 00000000000..481bb434814 --- /dev/null +++ b/feature/splash/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt b/feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt new file mode 100644 index 00000000000..8992390a5b5 --- /dev/null +++ b/feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt @@ -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) + } +} \ No newline at end of file diff --git a/feature/splash/src/main/AndroidManifest.xml b/feature/splash/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..a5918e68abc --- /dev/null +++ b/feature/splash/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashNavigation.kt b/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashNavigation.kt new file mode 100644 index 00000000000..6fe06714bda --- /dev/null +++ b/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashNavigation.kt @@ -0,0 +1,35 @@ +package com.mifos.feature.splash.navigation + +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable +import androidx.navigation.navigation +import com.mifos.feature.splash.splash.SplashScreen + +fun NavGraphBuilder.splashNavGraph( + navigatePasscode: () -> Unit, + navigateLogin: () -> Unit +) { + navigation( + startDestination = SplashScreens.SplashScreen.route, + route = SplashScreens.SplashScreenRoute.route, + ) { + splashScreenRoute( + navigateLogin = navigateLogin, + navigatePasscode = navigatePasscode + ) + } +} + +fun NavGraphBuilder.splashScreenRoute( + navigatePasscode: () -> Unit, + navigateLogin: () -> Unit +) { + composable( + route = SplashScreens.SplashScreen.route, + ) { + SplashScreen( + navigatePasscode = navigatePasscode, + navigateLogin = navigateLogin + ) + } +} \ No newline at end of file diff --git a/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashScreens.kt b/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashScreens.kt new file mode 100644 index 00000000000..ee4762d7ee9 --- /dev/null +++ b/feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashScreens.kt @@ -0,0 +1,9 @@ +package com.mifos.feature.splash.navigation + +sealed class SplashScreens(val route: String) { + + data object SplashScreenRoute : SplashScreens("splash_screen_route") + + data object SplashScreen : SplashScreens("splash_screen") + +} \ No newline at end of file diff --git a/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreen.kt b/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreen.kt new file mode 100644 index 00000000000..4afc3b89470 --- /dev/null +++ b/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreen.kt @@ -0,0 +1,77 @@ +package com.mifos.feature.splash.splash + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.mifos.core.designsystem.component.MifosScaffold +import com.mifos.core.designsystem.theme.SummerSky +import com.mifos.feature.splash.R + +@Composable +fun SplashScreen( + viewmodel: SplashScreenViewmodel = hiltViewModel(), + navigatePasscode: () -> Unit, + navigateLogin: () -> Unit +) { + val state by viewmodel.isAuthenticated.collectAsStateWithLifecycle() + + SplashScreen( + state = state, + navigatePasscode = navigatePasscode, + navigateLogin = navigateLogin + ) +} + +@Composable +fun SplashScreen( + state: Boolean?, + navigatePasscode: () -> Unit, + navigateLogin: () -> Unit +) { + + when (state) { + false -> navigateLogin() + true -> navigatePasscode() + else -> {} + } + + MifosScaffold( + containerColor = SummerSky + ) { paddingValues -> + Column( + modifier = Modifier + .padding(paddingValues) + .fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + modifier = Modifier.size(100.dp), + painter = painterResource(id = R.drawable.feature_splash_icon), + contentDescription = null + ) + } + } +} + +@Preview +@Composable +private fun SplashScreenPreview() { + SplashScreen( + state = false, + navigatePasscode = {}, + navigateLogin = {} + ) +} \ No newline at end of file diff --git a/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreenViewmodel.kt b/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreenViewmodel.kt new file mode 100644 index 00000000000..f4883f73a33 --- /dev/null +++ b/feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreenViewmodel.kt @@ -0,0 +1,32 @@ +package com.mifos.feature.splash.splash + +import android.util.Log +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.mifos.core.datastore.PrefManager +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class SplashScreenViewmodel @Inject constructor( + private val prefManager: PrefManager +) : ViewModel() { + + private val _isAuthenticated = MutableStateFlow(null) + val isAuthenticated = _isAuthenticated.asStateFlow() + + init { + checkAuthenticationStatus() + } + + private fun checkAuthenticationStatus() = viewModelScope.launch(Dispatchers.IO) { + delay(2000) + _isAuthenticated.value = prefManager.isAuthenticated() + } + +} \ No newline at end of file diff --git a/feature/splash/src/main/res/drawable/feature_splash_icon.png b/feature/splash/src/main/res/drawable/feature_splash_icon.png new file mode 100644 index 00000000000..d8f0bdc33ad Binary files /dev/null and b/feature/splash/src/main/res/drawable/feature_splash_icon.png differ diff --git a/feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt b/feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt new file mode 100644 index 00000000000..8da7f2fdf58 --- /dev/null +++ b/feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.mifos.feature.splash + +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) + } +} \ No newline at end of file diff --git a/mifosng-android/build.gradle.kts b/mifosng-android/build.gradle.kts index 1bb25e05323..ca7b3499c0f 100644 --- a/mifosng-android/build.gradle.kts +++ b/mifosng-android/build.gradle.kts @@ -143,6 +143,8 @@ dependencies { implementation(projects.feature.document) implementation(projects.feature.dataTable) implementation(projects.feature.search) + implementation(projects.feature.splash) + implementation(projects.feature.passcode) implementation(projects.core.common) implementation(projects.core.ui) diff --git a/mifosng-android/src/main/AndroidManifest.xml b/mifosng-android/src/main/AndroidManifest.xml index 8d20d0817f4..8237eccdfed 100755 --- a/mifosng-android/src/main/AndroidManifest.xml +++ b/mifosng-android/src/main/AndroidManifest.xml @@ -36,16 +36,10 @@ android:name="com.google.android.geo.API_KEY" android:value="${GEO_API_KEY}" /> - - + android:screenOrientation="portrait"> diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClient.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClient.kt new file mode 100644 index 00000000000..5e795b7d9cf --- /dev/null +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClient.kt @@ -0,0 +1,41 @@ +package com.mifos.mifosxdroid + +import androidx.compose.runtime.Composable +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.rememberNavController +import com.mifos.feature.auth.navigation.authNavGraph +import com.mifos.feature.auth.navigation.navigateToLogin +import com.mifos.feature.passcode.navigation.passcodeNavGraph +import com.mifos.feature.splash.navigation.SplashScreens +import com.mifos.feature.splash.navigation.splashNavGraph +import com.mifos.mifosxdroid.navigation.HomeScreens +import com.mifos.mifosxdroid.navigation.homeGraph +import com.mifos.mifosxdroid.navigation.navigateHome + +@Composable +fun AndroidClient() { + + val navController = rememberNavController() + + NavHost( + navController = navController, + startDestination = SplashScreens.SplashScreenRoute.route + ) { + splashNavGraph( + navigatePasscode = navController::navigateHome, + navigateLogin = navController::navigateToLogin + ) + + passcodeNavGraph( + navController = navController + ) + + authNavGraph( + navigatePasscode = {}, + navigateHome = navController::navigateHome, + updateServerConfig = {} + ) + + homeGraph() + } +} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/DashboardActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientActivity.kt similarity index 81% rename from mifosng-android/src/main/java/com/mifos/mifosxdroid/DashboardActivity.kt rename to mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientActivity.kt index ca93dccbca5..07aec95c3de 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/DashboardActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientActivity.kt @@ -6,12 +6,12 @@ import androidx.activity.compose.setContent import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint -class DashboardActivity : ComponentActivity() { +class AndroidClientActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - AndroidClientApp() + AndroidClient() } } diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt index bfe020d2030..7d85da4b7db 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt @@ -13,11 +13,13 @@ import androidx.compose.material.icons.rounded.PowerSettingsNew import androidx.compose.material.icons.rounded.Settings import androidx.compose.material.icons.rounded.Task import androidx.compose.ui.graphics.vector.ImageVector + import com.mifos.feature.about.navigation.ABOUT_SCREEN_ROUTE import com.mifos.feature.checker_inbox_task.navigation.CheckerInboxTaskScreens + + + import com.mifos.feature.groups.navigation.GROUP_LIST_SCREEN_ROUTE -import com.mifos.feature.individual_collection_sheet.navigation.GENERATE_COLLECTION_SHEET_SCREEN_ROUTE -import com.mifos.feature.individual_collection_sheet.navigation.INDIVIDUAL_COLLECTION_SHEET_SCREEN_ROUTE import com.mifos.feature.path_tracking.navigation.PATH_TRACKING_SCREEN_ROUTE import com.mifos.feature.search.Navigation.SEARCH_SCREEN_ROUTE import com.mifos.feature.settings.navigation.SETTINGS_SCREEN_ROUTE @@ -59,13 +61,13 @@ sealed class HomeDestinationsScreen( data object IndividualCollectionSheetScreen : HomeDestinationsScreen( title = "Individual Collection Sheet", - route = INDIVIDUAL_COLLECTION_SHEET_SCREEN_ROUTE, + route = "individual_collection_sheet_route", icon = Icons.AutoMirrored.Rounded.Assignment ) data object CollectionSheetScreen : HomeDestinationsScreen( title = "Collection Sheet", - route = GENERATE_COLLECTION_SHEET_SCREEN_ROUTE, + route = "generate_collection_sheet", icon = Icons.AutoMirrored.Rounded.Assignment ) @@ -89,7 +91,7 @@ sealed class HomeDestinationsScreen( data object AboutScreen : HomeDestinationsScreen( title = "About", - route = ABOUT_SCREEN_ROUTE, + route = "about_screen_route", icon = Icons.Rounded.Info ) diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/login/LoginActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/login/LoginActivity.kt index d51d7f6cc8f..a352a958093 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/login/LoginActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/login/LoginActivity.kt @@ -6,12 +6,8 @@ package com.mifos.mifosxdroid.activity.login import android.content.Intent import android.os.Bundle -import android.util.Log import androidx.activity.compose.setContent -import androidx.navigation.findNavController -import androidx.navigation.fragment.findNavController -import com.mifos.feature.auth.login.presentation.LoginScreen -import com.mifos.mifosxdroid.R +import com.mifos.feature.auth.login.LoginScreen import com.mifos.mifosxdroid.activity.home.HomeActivity import com.mifos.mifosxdroid.activity.setting.UpdateServerConfigFragment import com.mifos.mifosxdroid.core.MifosBaseActivity diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/splashscreen/SplashScreenActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/splashscreen/SplashScreenActivity.kt deleted file mode 100644 index 06646cb6b49..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/splashscreen/SplashScreenActivity.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This project is licensed under the open source MPL V2. - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.mifosxdroid.activity.splashscreen - -import android.content.Intent -import android.os.Bundle -import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen -import com.mifos.mifosxdroid.activity.login.LoginActivity -import com.mifos.mifosxdroid.core.MifosBaseActivity -import com.mifos.mifosxdroid.passcode.PassCodeActivity -import com.mifos.mobile.passcode.utils.PassCodeConstants -import com.mifos.utils.PrefManager - -/** - * This is the First Activity which can be used for initial checks, inits at app Startup - */ -class SplashScreenActivity : MifosBaseActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - val splashScreen = installSplashScreen() - super.onCreate(savedInstanceState) - splashScreen.setKeepOnScreenCondition { true } - if (!PrefManager.isAuthenticated()) { - startActivity(Intent(this@SplashScreenActivity, LoginActivity::class.java)) - } else { - val intent = Intent( - this@SplashScreenActivity, - PassCodeActivity::class.java - ) - intent.putExtra(PassCodeConstants.PASSCODE_INITIAL_LOGIN, true) - startActivity(intent) - } - finish() - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt index e6c2c4fd91d..343d8c0e4e3 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt @@ -8,6 +8,8 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import com.mifos.core.common.utils.Constants import com.mifos.feature.about.navigation.aboutScreen +import com.mifos.feature.activate.navigation.activateScreen +import com.mifos.feature.activate.navigation.navigateToActivateScreen import com.mifos.feature.center.navigation.centerNavGraph import com.mifos.feature.checker_inbox_task.navigation.checkerInboxTaskGraph import com.mifos.feature.client.navigation.clientNavGraph @@ -15,7 +17,7 @@ import com.mifos.feature.document.navigation.documentListScreen import com.mifos.feature.document.navigation.navigateToDocumentListScreen import com.mifos.feature.groups.navigation.groupListScreen import com.mifos.feature.individual_collection_sheet.navigation.generateCollectionSheetScreen -import com.mifos.feature.individual_collection_sheet.navigation.individualCollectionSheetScreen +import com.mifos.feature.individual_collection_sheet.navigation.individualCollectionSheetNavGraph import com.mifos.feature.loan.navigation.addLoanAccountScreen import com.mifos.feature.loan.navigation.loanNavGraph import com.mifos.feature.loan.navigation.navigateToLoanAccountScreen @@ -56,7 +58,7 @@ fun Navigation( savingsAccountSelected = { id, type -> navController.navigateToSavingsAccountSummaryScreen(id, type) }, - activateClient = { } + activateClient = { navController.navigateToActivateScreen(it, Constants.ACTIVATE_CLIENT) } ) savingsNavGraph( @@ -89,6 +91,8 @@ fun Navigation( onBackPressed = navController::popBackStack ) + activateScreen ( onBackPressed = navController::popBackStack ) + searchScreen( modifier = Modifier.padding(padding), centerListScreen = { }, @@ -99,7 +103,7 @@ fun Navigation( centerNavGraph( navController = navController, paddingValues = padding, - onActivateCenter = { _, _ -> }, + onActivateCenter = navController::navigateToActivateScreen, addSavingsAccount = { // navController.navigateToAddSavingsAccount(0, it, true) } @@ -123,18 +127,6 @@ fun Navigation( checkerInboxTaskGraph( navController = navController ) - - individualCollectionSheetScreen( - onBackClicked = { navController.popBackStack() }, - onDetail = { String, IndividualCollectionSheet -> - - } - ) - - generateCollectionSheetScreen( - onBackPressed = { navController.popBackStack() } - ) - pathTrackingScreen( onBackPressed = { navController.popBackStack() } ) @@ -151,5 +143,13 @@ fun Navigation( onBackPressed = { navController.popBackStack() } ) + individualCollectionSheetNavGraph( + onBackPressed = { navController.popBackStack() } , + navController = navController, + navigateToPaymentDetails = { _, _, _, _, _, _ -> +// TODO() navigate to payment details + } + ) + generateCollectionSheetScreen ( onBackPressed = navController::popBackStack ) } } \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt index e9f36a0e0f9..7bddb27de68 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt @@ -15,8 +15,8 @@ import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager +import com.mifos.mifosxdroid.AndroidClientActivity import com.mifos.mifosxdroid.R -import com.mifos.mifosxdroid.activity.splashscreen.SplashScreenActivity import com.mifos.mifosxdroid.passcode.PassCodeActivity import com.mifos.mobile.passcode.BasePassCodeActivity import com.mifos.utils.Constants @@ -117,7 +117,7 @@ open class MifosBaseActivity : BasePassCodeActivity(), BaseActivityCallback { startActivity( Intent( this@MifosBaseActivity, - SplashScreenActivity::class.java + AndroidClientActivity::class.java ) ) Toast.makeText( diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientApp.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeNavigation.kt similarity index 92% rename from mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientApp.kt rename to mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeNavigation.kt index 5717539e07a..27a7c173a51 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClientApp.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeNavigation.kt @@ -1,6 +1,6 @@ @file:OptIn(ExperimentalMaterial3Api::class) -package com.mifos.mifosxdroid +package com.mifos.mifosxdroid.navigation import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement @@ -51,17 +51,47 @@ import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController +import androidx.navigation.navigation import com.mifos.core.designsystem.theme.Black import com.mifos.core.designsystem.theme.White +import com.mifos.feature.splash.navigation.SplashScreens +import com.mifos.mifosxdroid.HomeDestinationsScreen +import com.mifos.mifosxdroid.R import com.mifos.mifosxdroid.components.MifosNavigationBar import com.mifos.mifosxdroid.components.Navigation import com.mifos.mifosxdroid.components.NavigationConstants import kotlinx.coroutines.launch +fun NavGraphBuilder.homeGraph() { + navigation( + startDestination = HomeScreens.HomeScreen.route, + route = "home_screen_route" + ) { + homeNavigate() + } +} + +fun NavGraphBuilder.homeNavigate() { + composable( + route = HomeScreens.HomeScreen.route + ) { + HomeNavigation() + } +} + +fun NavController.navigateHome() { + navigate(HomeScreens.HomeScreen.route) { + popBackStack(route = SplashScreens.SplashScreenRoute.route, inclusive = true) + } +} + @Composable -fun AndroidClientApp() { +fun HomeNavigation() { val navController = rememberNavController() val navBackStackEntry by navController.currentBackStackEntryAsState() diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeScreens.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeScreens.kt new file mode 100644 index 00000000000..8b740caeb45 --- /dev/null +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeScreens.kt @@ -0,0 +1,7 @@ +package com.mifos.mifosxdroid.navigation + +sealed class HomeScreens(val route: String) { + + data object HomeScreen : HomeScreens("home_screen") + +} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/activate/ActivateFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/activate/ActivateFragment.kt index b2b11e6c0a6..78bcd0fb646 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/activate/ActivateFragment.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/activate/ActivateFragment.kt @@ -19,14 +19,14 @@ import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class ActivateFragment : Fragment() { - private val arg: ActivateFragmentArgs by navArgs() +// private val arg: ActivateFragmentArgs by navArgs() private var id = 0 private lateinit var activateType: String override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - id = arg.clientId - activateType = arg.activationType +// id = arg.clientId +// activateType = arg.activationType } override fun onCreateView( @@ -38,8 +38,8 @@ class ActivateFragment : Fragment() { ) setContent { ActivateScreen( - id = id, - activateType = activateType, +// id = id, +// activateType = activateType, onBackPressed = { findNavController().popBackStack() } diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/IndividualCollectionSheetDetailsFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/IndividualCollectionSheetDetailsFragment.kt index 608bb996d7a..bde49117469 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/IndividualCollectionSheetDetailsFragment.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/IndividualCollectionSheetDetailsFragment.kt @@ -24,14 +24,14 @@ class IndividualCollectionSheetDetailsFragment : MifosBaseFragment() { private val arg: IndividualCollectionSheetDetailsFragmentArgs by navArgs() private lateinit var sheet: IndividualCollectionSheet - private lateinit var actualDisbursementDate: String - private lateinit var transactionDate: String +// private lateinit var actualDisbursementDate: String +// private lateinit var transactionDate: String override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) sheet = arg.sheet - actualDisbursementDate = arg.actualDisbursementDate - transactionDate = arg.transactionDate +// actualDisbursementDate = arg.actualDisbursementDate +// transactionDate = arg.transactionDate } override fun onCreateView( @@ -41,7 +41,7 @@ class IndividualCollectionSheetDetailsFragment : MifosBaseFragment() { return ComposeView(requireContext()).apply { setContent { IndividualCollectionSheetDetailsScreen( - sheet = sheet, +// sheet = sheet, onBackPressed = { findNavController().popBackStack() }, diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/passcode/PassCodeActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/passcode/PassCodeActivity.kt index ec39d577b90..adcbb7e3f35 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/passcode/PassCodeActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/passcode/PassCodeActivity.kt @@ -4,10 +4,8 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.core.widget.NestedScrollView -import com.mifos.mifosxdroid.DashboardActivity +import com.mifos.mifosxdroid.AndroidClientActivity import com.mifos.mifosxdroid.R -import com.mifos.mifosxdroid.activity.home.HomeActivity -import com.mifos.mifosxdroid.activity.splashscreen.SplashScreenActivity import com.mifos.mifosxdroid.core.util.Toaster import com.mifos.mobile.passcode.MifosPassCodeActivity import com.mifos.mobile.passcode.utils.EncryptionUtil @@ -36,7 +34,7 @@ class PassCodeActivity : MifosPassCodeActivity() { } override fun startLoginActivity() { - startActivity(Intent(this, SplashScreenActivity::class.java)) + startActivity(Intent(this, AndroidClientActivity::class.java)) finish() } @@ -49,7 +47,7 @@ class PassCodeActivity : MifosPassCodeActivity() { } override fun startNextActivity() { - startActivity(Intent(this, DashboardActivity::class.java)) + startActivity(Intent(this, AndroidClientActivity::class.java)) } override fun onBackPressed() { diff --git a/settings.gradle.kts b/settings.gradle.kts index 81c609e281b..da9a287441d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -50,3 +50,5 @@ include(":feature:document") include(":feature:savings") include(":feature:data-table") include(":feature:search") +include(":feature:splash") +include(":feature:passcode")