Since there are multiple common functionality, it is better to use one ViewModel for all the functionality, this makes sure the ViewModel is the single source of truth.
This violates unidirectional data flow. You are directly passing the pdf to the parent whereas the parent should get the pdf from it's viewmodel.
// Source - https://stackoverflow.com/q/79832596
// Posted by NullPointerException
// Retrieved 2025-11-28, License - CC BY-SA 4.0
composable(InfractionsDestinations.Pending.name) {
PendingScreen(
infractions = uiState.pendingInfractions,
onPDFDisplayRequested = { pdf ->
vm.showPDF(pdf = pdf)
}
)
}
You can add a middle layer for each child screens that receives the activity's context (or any application related information). This middle layer can then be used by the single ViewModel.