-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MIFOSAC-263 implemented compose navigation in Collection sheet module (…
- Loading branch information
Showing
11 changed files
with
143 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...ava/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetNavigation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String>, LoanAndClientName, List<PaymentTypeOptions>, 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<String>, LoanAndClientName, List<PaymentTypeOptions>, 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) | ||
} |
26 changes: 26 additions & 0 deletions
26
...n/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetScreens.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
...mifos/feature/individual_collection_sheet/navigation/GenerateCollectionSheetNavigation.kt
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
...fos/feature/individual_collection_sheet/navigation/IndividualCollectionSheetNavigation.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters