forked from openMF/android-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement navigation in report module
- Loading branch information
1 parent
774ce74
commit e1feb06
Showing
12 changed files
with
142 additions
and
42 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
88 changes: 88 additions & 0 deletions
88
feature/report/src/main/java/com/mifos/feature/report/navigation/ReportNavigation.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,88 @@ | ||
package com.mifos.feature.report.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.google.gson.Gson | ||
import com.mifos.core.common.utils.Constants | ||
import com.mifos.core.objects.runreports.FullParameterListResponse | ||
import com.mifos.core.objects.runreports.client.ClientReportTypeItem | ||
import com.mifos.feature.report.report.ReportScreen | ||
import com.mifos.feature.report.report_detail.ReportDetailScreen | ||
import com.mifos.feature.report.run_report.RunReportScreen | ||
|
||
fun NavGraphBuilder.reportNavGraph( | ||
navController: NavController | ||
) { | ||
navigation( | ||
startDestination = ReportScreens.RunReportScreen.route, | ||
route = "run_report_route" | ||
) { | ||
runReportScreenRoute( | ||
onBackPressed = navController::popBackStack, | ||
onReportSelected = navController::navigateReportDetailsScreen | ||
) | ||
reportDetailsScreenRoute( | ||
onBackPressed = navController::popBackStack, | ||
runReport = navController::navigateReportScreens | ||
) | ||
reportScreenRoute( | ||
onBackPressed = navController::popBackStack | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.runReportScreenRoute( | ||
onBackPressed: () -> Unit, | ||
onReportSelected: (ClientReportTypeItem) -> Unit | ||
) { | ||
composable( | ||
route = ReportScreens.RunReportScreen.route | ||
) { | ||
RunReportScreen( | ||
onBackPressed = onBackPressed, | ||
onReportClick = onReportSelected | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.reportDetailsScreenRoute( | ||
onBackPressed: () -> Unit, | ||
runReport: (FullParameterListResponse) -> Unit | ||
) { | ||
composable( | ||
route = ReportScreens.ReportDetailScreen.route, | ||
arguments = listOf(navArgument(Constants.REPORT_TYPE_ITEM, builder = {type = NavType.StringType})) | ||
) { | ||
ReportDetailScreen( | ||
onBackPressed = onBackPressed, | ||
runReport = runReport | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.reportScreenRoute( | ||
onBackPressed: () -> Unit | ||
) { | ||
composable( | ||
route = ReportScreens.ReportScreen.route, | ||
arguments = listOf(navArgument(Constants.REPORT_PARAMETER_RESPONSE, builder = {type = NavType.StringType})) | ||
) { | ||
ReportScreen( | ||
onBackPressed = onBackPressed | ||
) | ||
} | ||
} | ||
|
||
fun NavController.navigateReportDetailsScreen(clientReportTypeItem: ClientReportTypeItem) { | ||
val arg = Gson().toJson(clientReportTypeItem) | ||
navigate(ReportScreens.ReportDetailScreen.argument(arg)) | ||
} | ||
|
||
fun NavController.navigateReportScreens(fullParameterListResponse: FullParameterListResponse) { | ||
val arg = Gson().toJson(fullParameterListResponse) | ||
navigate(ReportScreens.ReportScreen.argument(arg)) | ||
} |
18 changes: 18 additions & 0 deletions
18
feature/report/src/main/java/com/mifos/feature/report/navigation/ReportScreens.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,18 @@ | ||
package com.mifos.feature.report.navigation | ||
|
||
import com.mifos.core.common.utils.Constants | ||
|
||
sealed class ReportScreens(val route: String) { | ||
|
||
data object RunReportScreen : ReportScreens(route = "run_report_screen") | ||
|
||
data object ReportDetailScreen : | ||
ReportScreens(route = "report_detail_screen/{${Constants.REPORT_TYPE_ITEM}}") { | ||
fun argument(reportTypeItem: String) = "report_detail_screen/${reportTypeItem}" | ||
} | ||
|
||
data object ReportScreen : | ||
ReportScreens(route = "report_screen/{${Constants.REPORT_PARAMETER_RESPONSE}}") { | ||
fun argument(reportParameter: String) = "report_screen/${reportParameter}" | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
feature/report/src/main/java/com/mifos/feature/report/navigation/RunReportsNavigation.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
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
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