From c83d295e874542c81ea3018cadcec838e2ea5a9f Mon Sep 17 00:00:00 2001 From: Pronay Sarker Date: Wed, 21 Aug 2024 03:56:15 +0600 Subject: [PATCH 1/5] MIFOSAC-263 implemented compose navigation in Collection sheet module (#2200) --- .../GenerateCollectionSheetScreen.kt | 1 + .../ui/IndividualCollectionSheetScreen.kt | 1 - .../IndividualCollectionSheetDetailsScreen.kt | 5 +- ...dividualCollectionSheetDetailsViewModel.kt | 10 ++- .../navigation/CollectionSheetNavigation.kt | 89 +++++++++++++++++++ .../navigation/CollectionSheetScreens.kt | 26 ++++++ .../GenerateCollectionSheetNavigation.kt | 25 ------ .../IndividualCollectionSheetNavigation.kt | 28 ------ .../mifosxdroid/HomeDestinationsScreen.kt | 6 +- .../mifosxdroid/components/Navigation.kt | 22 ++--- ...ndividualCollectionSheetDetailsFragment.kt | 10 +-- 11 files changed, 143 insertions(+), 80 deletions(-) create mode 100644 feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetNavigation.kt create mode 100644 feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetScreens.kt delete mode 100644 feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/GenerateCollectionSheetNavigation.kt delete mode 100644 feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/IndividualCollectionSheetNavigation.kt 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/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt index e81055f2d80..a8a1ffe5159 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt @@ -16,8 +16,6 @@ import androidx.compose.ui.graphics.vector.ImageVector import com.mifos.feature.about.navigation.ABOUT_SCREEN_ROUTE import com.mifos.feature.checker_inbox_task.navigation.CHECKER_INBOX_TASK_SCREEN_ROUTE 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 +57,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 ) 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 268f0cc67b3..3f25ab39a97 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 @@ -15,7 +15,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 @@ -123,18 +123,6 @@ fun Navigation( checkerInboxTasksScreen( onBackPressed = { navController.popBackStack() }, ) - - individualCollectionSheetScreen( - onBackClicked = { navController.popBackStack() }, - onDetail = { String, IndividualCollectionSheet -> - - } - ) - - generateCollectionSheetScreen( - onBackPressed = { navController.popBackStack() } - ) - pathTrackingScreen( onBackPressed = { navController.popBackStack() } ) @@ -151,5 +139,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/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() }, From b9bde5f57c168d6f8915e045ecc66efd5b09e342 Mon Sep 17 00:00:00 2001 From: Pronay Sarker Date: Wed, 21 Aug 2024 16:54:24 +0600 Subject: [PATCH 2/5] MIFOSAC-258: Implemented compose navigation in about module (#2196) implemented navigation --- .../mifos/feature/about/navigation/AboutScreens.kt | 8 ++++++++ .../feature/about/navigation/AccountNavigation.kt | 14 ++++++-------- .../mifos/mifosxdroid/HomeDestinationsScreen.kt | 3 +-- 3 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 feature/about/src/main/java/com/mifos/feature/about/navigation/AboutScreens.kt 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/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt index a8a1ffe5159..e073569d572 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/HomeDestinationsScreen.kt @@ -13,7 +13,6 @@ 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.CHECKER_INBOX_TASK_SCREEN_ROUTE import com.mifos.feature.groups.navigation.GROUP_LIST_SCREEN_ROUTE import com.mifos.feature.path_tracking.navigation.PATH_TRACKING_SCREEN_ROUTE @@ -87,7 +86,7 @@ sealed class HomeDestinationsScreen( data object AboutScreen : HomeDestinationsScreen( title = "About", - route = ABOUT_SCREEN_ROUTE, + route = "about_screen_route", icon = Icons.Rounded.Info ) From 39f9fd401c0896542c7ac1dac4718bd017e79764 Mon Sep 17 00:00:00 2001 From: Aditya Gupta <94394661+Aditya-gupta99@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:24:36 +0530 Subject: [PATCH 3/5] feat: Implement compose navigation on splash , auth, passcode module (#2194) --- .../com/mifos/core/common/utils/Constants.kt | 1 + .../mifos/core/designsystem/theme/Color.kt | 3 +- .../login/{presentation => }/LoginScreen.kt | 2 +- .../login/{presentation => }/LoginUiState.kt | 2 +- .../{presentation => }/LoginViewModel.kt | 2 +- .../feature/auth/navigation/AuthNavigation.kt | 45 ++++++++++ .../feature/auth/navigation/AuthScreens.kt | 9 ++ feature/passcode/.gitignore | 1 + feature/passcode/build.gradle.kts | 25 ++++++ feature/passcode/consumer-rules.pro | 0 feature/passcode/proguard-rules.pro | 21 +++++ .../passcode/ExampleInstrumentedTest.kt | 24 ++++++ feature/passcode/src/main/AndroidManifest.xml | 4 + .../passcode/navigation/PasscodeNavigation.kt | 38 +++++++++ .../passcode/navigation/PasscodeScreens.kt | 7 ++ .../passcode/passcode/PasscodeScreen.kt | 44 ++++++++++ .../passcode/passcode/PasscodeViewmodel.kt | 17 ++++ .../mifos/feature/passcode/ExampleUnitTest.kt | 17 ++++ feature/splash/.gitignore | 1 + feature/splash/build.gradle.kts | 23 ++++++ feature/splash/consumer-rules.pro | 0 feature/splash/proguard-rules.pro | 21 +++++ .../feature/splash/ExampleInstrumentedTest.kt | 24 ++++++ feature/splash/src/main/AndroidManifest.xml | 4 + .../splash/navigation/SplashNavigation.kt | 35 ++++++++ .../splash/navigation/SplashScreens.kt | 9 ++ .../feature/splash/splash/SplashScreen.kt | 77 ++++++++++++++++++ .../splash/splash/SplashScreenViewmodel.kt | 32 ++++++++ .../main/res/drawable/feature_splash_icon.png | Bin 0 -> 2834 bytes .../mifos/feature/splash/ExampleUnitTest.kt | 17 ++++ mifosng-android/build.gradle.kts | 2 + mifosng-android/src/main/AndroidManifest.xml | 10 +-- .../com/mifos/mifosxdroid/AndroidClient.kt | 41 ++++++++++ ...rdActivity.kt => AndroidClientActivity.kt} | 4 +- .../activity/login/LoginActivity.kt | 6 +- .../splashscreen/SplashScreenActivity.kt | 36 -------- .../mifosxdroid/core/MifosBaseActivity.kt | 4 +- .../HomeNavigation.kt} | 34 +++++++- .../mifosxdroid/navigation/HomeScreens.kt | 7 ++ .../mifosxdroid/passcode/PassCodeActivity.kt | 8 +- settings.gradle.kts | 2 + 41 files changed, 595 insertions(+), 64 deletions(-) rename feature/auth/src/main/java/com/mifos/feature/auth/login/{presentation => }/LoginScreen.kt (99%) rename feature/auth/src/main/java/com/mifos/feature/auth/login/{presentation => }/LoginUiState.kt (90%) rename feature/auth/src/main/java/com/mifos/feature/auth/login/{presentation => }/LoginViewModel.kt (98%) create mode 100644 feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthNavigation.kt create mode 100644 feature/auth/src/main/java/com/mifos/feature/auth/navigation/AuthScreens.kt create mode 100644 feature/passcode/.gitignore create mode 100644 feature/passcode/build.gradle.kts create mode 100644 feature/passcode/consumer-rules.pro create mode 100644 feature/passcode/proguard-rules.pro create mode 100644 feature/passcode/src/androidTest/java/com/mifos/feature/passcode/ExampleInstrumentedTest.kt create mode 100644 feature/passcode/src/main/AndroidManifest.xml create mode 100644 feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeNavigation.kt create mode 100644 feature/passcode/src/main/java/com/mifos/feature/passcode/navigation/PasscodeScreens.kt create mode 100644 feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeScreen.kt create mode 100644 feature/passcode/src/main/java/com/mifos/feature/passcode/passcode/PasscodeViewmodel.kt create mode 100644 feature/passcode/src/test/java/com/mifos/feature/passcode/ExampleUnitTest.kt create mode 100644 feature/splash/.gitignore create mode 100644 feature/splash/build.gradle.kts create mode 100644 feature/splash/consumer-rules.pro create mode 100644 feature/splash/proguard-rules.pro create mode 100644 feature/splash/src/androidTest/java/com/mifos/feature/splash/ExampleInstrumentedTest.kt create mode 100644 feature/splash/src/main/AndroidManifest.xml create mode 100644 feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashNavigation.kt create mode 100644 feature/splash/src/main/java/com/mifos/feature/splash/navigation/SplashScreens.kt create mode 100644 feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreen.kt create mode 100644 feature/splash/src/main/java/com/mifos/feature/splash/splash/SplashScreenViewmodel.kt create mode 100644 feature/splash/src/main/res/drawable/feature_splash_icon.png create mode 100644 feature/splash/src/test/java/com/mifos/feature/splash/ExampleUnitTest.kt create mode 100644 mifosng-android/src/main/java/com/mifos/mifosxdroid/AndroidClient.kt rename mifosng-android/src/main/java/com/mifos/mifosxdroid/{DashboardActivity.kt => AndroidClientActivity.kt} (81%) delete mode 100644 mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/splashscreen/SplashScreenActivity.kt rename mifosng-android/src/main/java/com/mifos/mifosxdroid/{AndroidClientApp.kt => navigation/HomeNavigation.kt} (92%) create mode 100644 mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/HomeScreens.kt 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..bc86777a765 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 @@ -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" } \ 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/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/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 0000000000000000000000000000000000000000..d8f0bdc33ad9d6c2c3aa6a48612009b8e80d41fc GIT binary patch literal 2834 zcmZ`*dpOhkAK%PnVsi<(jnK^{a@3}|ki__8+KUUHDt-pWI?|I&r=koHE@VyMk$Ge_z1%WzCRkorOWLP=%SZEpuq$wk6 zri16=jI%(XZ7p6Nt^rvQA7^J$DyI>{pZx=S&t9`mu$iD*BsY}{8u>??=F;&Nf!?2s zEI-@a$H8itTAJnRZiD5~kq6|HAaST+VdsNOyVQrRqDGKGJhu>kzDXQxFU4hIa^7}@ zuX7;Faczv0vsAZK)~DZZHe+;CVm2BalNY6X>HpPR=K2TB?{>3(r>exqd_AOr=kGV} zq6_CH!f($vJK%zsGMlwlThil2&jlrKBoIZs@9P`$W&iy09K2JqDn|sKG&J>t@shP| zM0;U|gNTdSEQHs zr8t-jFK-b(9bbmv{q;PyV7o?E4fLx ztH=>nW5PohlYZZLEVPR@PF>oe#vO$c_aDywO)=^NnSUpQZscz{v^M&3r{1MDyCN!{ z+d(FMDrzvoFm9f<9^z>ye6k;y0;4`06y4#N_3bbW-ZEfYxJEYVvT<*@JniF=AIQ{L zM{I{Fw-uUPQXKvm%7O!-Lvrh1UY6tB69fryvXswEbr^f^mR0JXdp&)CB8%9dhjHq( zHj#D);Vi~$2B*O6vMhSL8J8%3aNeFX1EcA7H3mezv@K|Zh(n_DvT?nQ0Sj$i zAenyQ_48bq^5?;9uiMA22c#$`AyRj=lyGy_7zR)xq`rvZ1=D#TQ@LO3=~RpD2mEjr z6A`>KdNLlSg21h%)EsB*McsKsdf~}K3$3l-jME8~i%mrq-W3M>FUtJ3qVv%13@S9L z?0Q|NE~^BLADob=8?_T$zMremvO%?)#ve|iMG4mUKDl0JzPv^jXFqvI$!ZF{5{$g9 zd+ujOV`C+*Khi5Z!1gUv=Bs9?!lfz`Rq_fgt7SLal!nmpWs5I^v=jYL8Rp9@NqU&x zL#~e+Yr2mP&9%0{2dBQ4@DGa4QnE!l<`MimMF)w64NPL+Vq9LfWql6ys$PPK59dsM zy+nnGrst}nUpYKUEs^01e0x!{vhBxk^N8GF+eZ){dYX{AOQMJQ{tan9$7{}dqmo2x z1w!d_z6|#Eeb&iqP}bNXL9^fZqdgA|92#r-+-*ngcxVo=M1LA@2ci+plVyryI?v>-kwk~Z{z3!0T)?vb z)FF~_q*~qABR+GYY_ZaV*sV#%(sD)gSWaxLHu-za(?ulfNmUhm}C2PmT|0d$?*t;c4&$e5IC!U z1AK#Kz`U>3P8P#)xmsHfH*849-tMKH$ zel(o-Vnkjh_oY!QaPPGOa0cOtHOzPL=^c2kPXG;VdFQ0LO)FY~_o8~%e7JXwCfxP3 z?cJNM^omWR?)T2}JdNPFsbM*yeR0n_j{gbX~C>p z@Fhq5fKfK90p3EeahkNOq6LbHip+vaO9p5CwX+W}uA$f>w_KM7BLdnKlHNl5ZgsId z?{F1SlL+JpmXsyu-4;B^Guu&JQP&gvcrtQ~@ z=(^$F#b}$RyD+A4Z78?)&C1bHXxd6xw1X_dfi4Es=f}S5%) zP>#UI{KF}N2GjVFm8f}Q$zuSZfT9y|B*%II{cKOJStP z1fC%lwY%R?H`+FuOhPO~V1VO6OTQ$oU<(KXvlw6#T3au2CTg+R436sSIXdCASYy5V zTG>>1hC1u4>~g7HKOfpx4B}MTY0SKDdAh>({t2_G(|(;nxkDyAm+yZ%KK!VfL^s+6 z2Rbyxt@1XPL>*|50VD0{L9qen;kQJmTMO4Ma#$QiQT;Wq@J|r-GiDyT-(HB{DKKbn zT_irk@m#_~#$K~DGR|)}(Mxv10o1Q6ItD3>e|zwHN%Rt=4v?ZQ9*4#>hRPc-3MQmlucy)vnCte z0mTG|d)wG&c`nJphN&sidsJNhZ|X=azZL-$KbV7abw9qq>}}Nq~JuFmw^d&B=J-DDKFV57s#OV|#-#=?1iY z(HKh|vl8p9|MscOeRP+<%QMq1fToX4Qvp7uYbHwpl%w|CyFLdQWEx9=?&Pv1CH zK(PE=ER{&lSR?Wr@7{isnJ2HxIq<(_x#wXnXv;p4W~xn_k^N&qUPpaB+T9{A{1 - - + 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/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/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/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") From bd1948b4db91c580f6be62c2219ebad552eba111 Mon Sep 17 00:00:00 2001 From: Pronay Sarker Date: Wed, 21 Aug 2024 16:54:56 +0600 Subject: [PATCH 4/5] feat: Implemented compose navigation in activate module (#2195) * implemented compose navigation in activateModule * MIFOSAC-260 implemented compose navigation in document module (#2193) * MIFOSAC-258: compose navigation in activate module --- .../com/mifos/core/common/utils/Constants.kt | 1 + .../mifos/feature/activate/ActivateScreen.kt | 4 +-- .../feature/activate/ActivateViewModel.kt | 8 ++++- .../activate/navigation/ActivateNavigation.kt | 32 +++++++++++++++++++ .../activate/navigation/ActivateScreens.kt | 12 +++++++ .../mifosxdroid/components/Navigation.kt | 8 +++-- .../online/activate/ActivateFragment.kt | 10 +++--- 7 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 feature/activate/src/main/java/com/mifos/feature/activate/navigation/ActivateNavigation.kt create mode 100644 feature/activate/src/main/java/com/mifos/feature/activate/navigation/ActivateScreens.kt 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 bc86777a765..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" 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/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt index 3f25ab39a97..16e1443cde6 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.checkerInboxTasksScreen import com.mifos.feature.client.navigation.clientNavGraph @@ -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) } 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() } From e2b3338816038adb26be3faf2c8a7e6d0e49863b Mon Sep 17 00:00:00 2001 From: Aditya Gupta <94394661+Aditya-gupta99@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:54:13 +0530 Subject: [PATCH 5/5] feat: implemented navigation component in checker inbox task module (#2197) --- .../{ui => }/CheckerInboxScreen.kt | 4 +- .../{ui => }/CheckerInboxUiState.kt | 2 +- .../{ui => }/CheckerInboxViewModel.kt | 2 +- .../CheckerInboxTasksFilterDialog.kt | 2 +- .../CheckerInboxViewModel.kt | 2 +- .../{ui => }/CheckerInboxTasksScreen.kt | 2 +- .../{ui => }/CheckerInboxTasksUiState.kt | 2 +- .../{ui => }/CheckerInboxTasksViewModel.kt | 2 +- .../navigation/CheckerInboxTaskNavigation.kt | 55 +++++++++++++++++++ .../navigation/CheckerInboxTaskScreens.kt | 12 ++++ .../navigation/CheckerInboxTasksNavigation.kt | 26 --------- .../mifosxdroid/HomeDestinationsScreen.kt | 9 ++- .../mifosxdroid/components/Navigation.kt | 6 +- .../CheckerTaskFilterDialogFragment.kt | 2 +- .../checkerinbox/CheckerInboxFragment.kt | 5 +- .../checkerinbox/CheckerInboxTasksFragment.kt | 2 +- .../CheckerInboxViewModelFactory.kt | 2 +- 17 files changed, 90 insertions(+), 47 deletions(-) rename feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/{ui => }/CheckerInboxScreen.kt (99%) rename feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/{ui => }/CheckerInboxUiState.kt (88%) rename feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/{ui => }/CheckerInboxViewModel.kt (98%) rename feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/{dialog => checker_inbox_dialog}/CheckerInboxTasksFilterDialog.kt (99%) rename feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/{dialog => checker_inbox_dialog}/CheckerInboxViewModel.kt (96%) rename feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/{ui => }/CheckerInboxTasksScreen.kt (99%) rename feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/{ui => }/CheckerInboxTasksUiState.kt (99%) rename feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/{ui => }/CheckerInboxTasksViewModel.kt (99%) create mode 100644 feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTaskNavigation.kt create mode 100644 feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTaskScreens.kt delete mode 100644 feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTasksNavigation.kt diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxScreen.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxScreen.kt similarity index 99% rename from feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxScreen.kt rename to feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxScreen.kt index 0f6e43fd51a..1d73066e954 100644 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxScreen.kt +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxScreen.kt @@ -3,7 +3,7 @@ ExperimentalFoundationApi::class ) -package com.mifos.feature.checker_inbox_task.checker_inbox.ui +package com.mifos.feature.checker_inbox_task.checker_inbox import android.widget.Toast import androidx.activity.compose.BackHandler @@ -70,7 +70,7 @@ import com.mifos.core.designsystem.theme.White import com.mifos.core.objects.checkerinboxandtasks.CheckerTask import com.mifos.core.ui.components.SelectionModeTopAppBar import com.mifos.feature.checker_inbox_task.R -import com.mifos.feature.checker_inbox_task.dialog.CheckerInboxTasksFilterDialog +import com.mifos.feature.checker_inbox_task.checker_inbox_dialog.CheckerInboxTasksFilterDialog import java.sql.Timestamp @Composable diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxUiState.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxUiState.kt similarity index 88% rename from feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxUiState.kt rename to feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxUiState.kt index 1a904d83356..0ab7fd3b4d8 100644 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxUiState.kt +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxUiState.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.checker_inbox_task.checker_inbox.ui +package com.mifos.feature.checker_inbox_task.checker_inbox import com.mifos.core.objects.checkerinboxandtasks.CheckerInboxSearchTemplate import com.mifos.core.objects.checkerinboxandtasks.CheckerTask diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxViewModel.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxViewModel.kt similarity index 98% rename from feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxViewModel.kt rename to feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxViewModel.kt index e484e6808a4..16bf8994c1b 100644 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/ui/CheckerInboxViewModel.kt +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox/CheckerInboxViewModel.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.checker_inbox_task.checker_inbox.ui +package com.mifos.feature.checker_inbox_task.checker_inbox import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/dialog/CheckerInboxTasksFilterDialog.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_dialog/CheckerInboxTasksFilterDialog.kt similarity index 99% rename from feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/dialog/CheckerInboxTasksFilterDialog.kt rename to feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_dialog/CheckerInboxTasksFilterDialog.kt index 27713120f2f..68eeadd88b3 100644 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/dialog/CheckerInboxTasksFilterDialog.kt +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_dialog/CheckerInboxTasksFilterDialog.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.checker_inbox_task.dialog +package com.mifos.feature.checker_inbox_task.checker_inbox_dialog import android.annotation.SuppressLint import android.widget.Toast diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/dialog/CheckerInboxViewModel.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_dialog/CheckerInboxViewModel.kt similarity index 96% rename from feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/dialog/CheckerInboxViewModel.kt rename to feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_dialog/CheckerInboxViewModel.kt index e19e348b18f..603a6b12f22 100644 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/dialog/CheckerInboxViewModel.kt +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_dialog/CheckerInboxViewModel.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.checker_inbox_task.dialog +package com.mifos.feature.checker_inbox_task.checker_inbox_dialog import android.util.Log import androidx.compose.runtime.mutableStateOf diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksScreen.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksScreen.kt similarity index 99% rename from feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksScreen.kt rename to feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksScreen.kt index e7f166127d1..b2fe7617298 100644 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksScreen.kt +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksScreen.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.checker_inbox_task.checker_inbox_tasks.ui +package com.mifos.feature.checker_inbox_task.checker_inbox_tasks import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksUiState.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksUiState.kt similarity index 99% rename from feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksUiState.kt rename to feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksUiState.kt index a8d433a7620..003e8370114 100644 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksUiState.kt +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksUiState.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.checker_inbox_task.checker_inbox_tasks.ui +package com.mifos.feature.checker_inbox_task.checker_inbox_tasks /** diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksViewModel.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksViewModel.kt similarity index 99% rename from feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksViewModel.kt rename to feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksViewModel.kt index a0694878bc2..61bd93335ee 100644 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/ui/CheckerInboxTasksViewModel.kt +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/checker_inbox_tasks/CheckerInboxTasksViewModel.kt @@ -1,4 +1,4 @@ -package com.mifos.feature.checker_inbox_task.checker_inbox_tasks.ui +package com.mifos.feature.checker_inbox_task.checker_inbox_tasks import android.util.Log import androidx.lifecycle.ViewModel diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTaskNavigation.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTaskNavigation.kt new file mode 100644 index 00000000000..71a4f865919 --- /dev/null +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTaskNavigation.kt @@ -0,0 +1,55 @@ +package com.mifos.feature.checker_inbox_task.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable +import androidx.navigation.navigation +import com.mifos.feature.checker_inbox_task.checker_inbox.CheckerInboxScreen +import com.mifos.feature.checker_inbox_task.checker_inbox_tasks.CheckerInboxTasksScreen + +fun NavGraphBuilder.checkerInboxTaskGraph( + navController: NavController, +) { + navigation( + startDestination = CheckerInboxTaskScreens.CheckerInboxTaskScreen.route, + route = CheckerInboxTaskScreens.CheckerInboxTaskScreenRoute.route + ) { + checkerInboxTaskRoute( + onBackPressed = navController::popBackStack, + checkerInbox = navController::navigateCheckerInbox + ) + checkerInboxRoute( + onBackPressed = navController::popBackStack + ) + } +} + +fun NavGraphBuilder.checkerInboxTaskRoute( + onBackPressed: () -> Unit, + checkerInbox: () -> Unit +) { + composable( + route = CheckerInboxTaskScreens.CheckerInboxTaskScreen.route + ) { + CheckerInboxTasksScreen( + onBackPressed = onBackPressed, + checkerInbox = checkerInbox + ) + } +} + +fun NavGraphBuilder.checkerInboxRoute( + onBackPressed: () -> Unit +) { + composable( + route = CheckerInboxTaskScreens.CheckerInboxScreen.route + ) { + CheckerInboxScreen( + onBackPressed = onBackPressed + ) + } +} + +fun NavController.navigateCheckerInbox() { + navigate(CheckerInboxTaskScreens.CheckerInboxScreen.route) +} \ No newline at end of file diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTaskScreens.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTaskScreens.kt new file mode 100644 index 00000000000..ff5d8d62eac --- /dev/null +++ b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTaskScreens.kt @@ -0,0 +1,12 @@ +package com.mifos.feature.checker_inbox_task.navigation + +sealed class CheckerInboxTaskScreens(val route: String) { + + data object CheckerInboxTaskScreenRoute : + CheckerInboxTaskScreens("checker_inbox_task_screen_route") + + data object CheckerInboxTaskScreen : CheckerInboxTaskScreens("checker_inbox_task_screen") + + data object CheckerInboxScreen : CheckerInboxTaskScreens("checker_inbox_screen") + +} \ No newline at end of file diff --git a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTasksNavigation.kt b/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTasksNavigation.kt deleted file mode 100644 index a9a311d3440..00000000000 --- a/feature/checker-inbox-task/src/main/java/com/mifos/feature/checker_inbox_task/navigation/CheckerInboxTasksNavigation.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.mifos.feature.checker_inbox_task.navigation - -import androidx.navigation.NavController -import androidx.navigation.NavGraphBuilder -import androidx.navigation.compose.composable -import com.mifos.feature.checker_inbox_task.checker_inbox_tasks.ui.CheckerInboxTasksScreen - -/** - * Created by Pronay Sarker on 10/08/2024 (7:59 AM) - */ -const val CHECKER_INBOX_TASK_SCREEN_ROUTE = "checker_inbox_task_screen_route" - -fun NavController.navigateToCheckerInboxTaskScreen() { - this.navigate(CHECKER_INBOX_TASK_SCREEN_ROUTE) -} - -fun NavGraphBuilder.checkerInboxTasksScreen( - onBackPressed: () -> Unit, -){ - composable(CHECKER_INBOX_TASK_SCREEN_ROUTE) { - CheckerInboxTasksScreen( - onBackPressed = onBackPressed, - checkerInbox = {} - ) - } -} \ No newline at end of file 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 e073569d572..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,7 +13,12 @@ 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.checker_inbox_task.navigation.CHECKER_INBOX_TASK_SCREEN_ROUTE + +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.path_tracking.navigation.PATH_TRACKING_SCREEN_ROUTE import com.mifos.feature.search.Navigation.SEARCH_SCREEN_ROUTE @@ -50,7 +55,7 @@ sealed class HomeDestinationsScreen( data object CheckerInboxAndTasksScreen : HomeDestinationsScreen( title = "Checker Inbox & Tasks", - route = CHECKER_INBOX_TASK_SCREEN_ROUTE, + route = CheckerInboxTaskScreens.CheckerInboxTaskScreen.route, icon = Icons.Rounded.CheckBox ) 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 16e1443cde6..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 @@ -11,7 +11,7 @@ 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.checkerInboxTasksScreen +import com.mifos.feature.checker_inbox_task.navigation.checkerInboxTaskGraph import com.mifos.feature.client.navigation.clientNavGraph import com.mifos.feature.document.navigation.documentListScreen import com.mifos.feature.document.navigation.navigateToDocumentListScreen @@ -124,8 +124,8 @@ fun Navigation( } ) - checkerInboxTasksScreen( - onBackPressed = { navController.popBackStack() }, + checkerInboxTaskGraph( + navController = navController ) pathTrackingScreen( onBackPressed = { navController.popBackStack() } diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/checkertaskfilterdialog/CheckerTaskFilterDialogFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/checkertaskfilterdialog/CheckerTaskFilterDialogFragment.kt index 5b82e87f01d..d6716ec3de0 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/checkertaskfilterdialog/CheckerTaskFilterDialogFragment.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/checkertaskfilterdialog/CheckerTaskFilterDialogFragment.kt @@ -14,7 +14,7 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.mifos.mifosxdroid.R import com.mifos.mifosxdroid.databinding.DialogFragmentCheckerTaskFilterBinding -import com.mifos.feature.checker_inbox_task.dialog.CheckerInboxViewModel +import com.mifos.feature.checker_inbox_task.checker_inbox_dialog.CheckerInboxViewModel import com.mifos.feature.checker_inbox_task.dialog.CheckerInboxViewModelFactory import com.mifos.mifosxdroid.uihelpers.MFDatePicker import com.mifos.utils.FragmentConstants diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxFragment.kt index 3b444a26e7f..0099189e5b5 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxFragment.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxFragment.kt @@ -7,12 +7,9 @@ import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy -import com.mifos.core.common.utils.Constants -import com.mifos.core.objects.checkerinboxandtasks.CheckerTask -import com.mifos.feature.checker_inbox_task.checker_inbox.ui.CheckerInboxScreen +import com.mifos.feature.checker_inbox_task.checker_inbox.CheckerInboxScreen import com.mifos.mifosxdroid.core.MifosBaseFragment import dagger.hilt.android.AndroidEntryPoint -import java.sql.Timestamp @AndroidEntryPoint diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxTasksFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxTasksFragment.kt index e259a3d759e..c5c1ceacabb 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxTasksFragment.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxTasksFragment.kt @@ -8,7 +8,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.navigation.fragment.findNavController -import com.mifos.feature.checker_inbox_task.checker_inbox_tasks.ui.CheckerInboxTasksScreen +import com.mifos.feature.checker_inbox_task.checker_inbox_tasks.CheckerInboxTasksScreen import com.mifos.mifosxdroid.R import com.mifos.mifosxdroid.core.MifosBaseFragment import dagger.hilt.android.AndroidEntryPoint diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxViewModelFactory.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxViewModelFactory.kt index 523d92d6b57..fcc6858e9c4 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxViewModelFactory.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxViewModelFactory.kt @@ -3,7 +3,7 @@ package com.mifos.mifosxdroid.online.checkerinbox import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import com.mifos.core.network.datamanager.DataManagerCheckerInbox -import com.mifos.feature.checker_inbox_task.dialog.CheckerInboxViewModel +import com.mifos.feature.checker_inbox_task.checker_inbox_dialog.CheckerInboxViewModel import rx.subscriptions.CompositeSubscription import javax.inject.Inject