Hello, guys. First of all, thank you for such a gr...
# compose-destinations
i
Hello, guys. First of all, thank you for such a great piece of software. I enjoy using it - makes the code much more reliable and easier to support. I have a question that has been strangling me for the past week. I have a multi-module project with feature graphs and all of that stuff - it's set up according to the library documentation. The issue is that I want to add a ModalBottomSheetLayout and use bottom sheet destinations within a feature graph. However, from what I’ve seen, the official approach suggests placing the ModalBottomSheetLayout at the root of a whole composable hierarchy. Is there any way to include the ModalBottomSheetLayout at the root of a feature graph instead? And would that even be considered a good approach? I am asking because I need to customize appearance for bottom sheets in each feature and this looks to me as the easiest approach for that task.
r
Afaik, If you want bottom sheet destinations, you have to place the layout in the top level. That said, you should probably think of it as providing support for bottom sheets, it doesn’t need to be tied to any specific bottom sheet or feature. If you do that, then each feature module should be able to register bottom sheet styled destinations as normal.
i
Yeah, I've tried it and such approach works. The problem is that for some features, we need the initial bottom sheet state to be fully expanded, and for others, partially expanded - and I don't see any built-in support for that in Jetpack Compose with the Material 3 system. I'm not even mentioning things like background color or shape, which could probably be better handled via theming in a feature module - though I haven't checked that yet. By the way, I read the source code of this amazing library and found this function: com.ramcosta.composedestinations.DestinationsNavHostKt#addNavGraphDestinations
Copy code
private fun NavGraphBuilder.addNavGraphDestinations(
    engine: NavHostEngine,
    navGraph: NavGraphSpec,
    navController: NavHostController,
    dependenciesContainerBuilder: @Composable DependenciesContainerBuilder<*>.() -> Unit,
    manualComposableCalls: ManualComposableCalls,
): Unit = with(engine) {

    navGraph.destinations.forEach { destination ->
        composable(
            destination,
            navController,
            dependenciesContainerBuilder,
            manualComposableCalls
        )
    }

    addNestedNavGraphs(
        engine = engine,
        nestedNavGraphs = navGraph.nestedNavGraphs,
        navController = navController,
        dependenciesContainerBuilder = dependenciesContainerBuilder,
        manualComposableCalls = manualComposableCalls
    )
}
What do you think - would it make sense to add something like this?
Copy code
if (navGraph.graphWrapper!= null) {
    composable("graph_wrapper") {
        navGraph.destinations.forEach { destination ->
            composable(
                destination,
                navController,
                dependenciesContainerBuilder,
                manualComposableCalls
            )
        }

        addNestedNavGraphs(
            engine = engine,
            nestedNavGraphs = navGraph.nestedNavGraphs,
            navController = navController,
            dependenciesContainerBuilder = dependenciesContainerBuilder,
            manualComposableCalls = manualComposableCalls
        )
    }
}
Just a thought, I could try to investigate it further if you think it makes sense. Thank you.
d
Just chiming in on Material 3 bottom sheet navigation, it is yet not supported by compose. See the following issue tracker ticket: https://issuetracker.google.com/issues/328949006
i
@David well, I would be happy to do nothing, wait for the google team and drink my cappuccino. But, unfortunately, employee demands some solution 🥲
😭 1
d
Yeah hand-rolling your own thing or putting them in each screen, is the two alternatives if you want Material 3 bottom sheets. It's too bad they've been really slow on supporting this for M3, I was looking into this almost a year ago and since we don't have that many bottom sheets we opted for putting them in each screen for now. 😢