Alternatively, a key can host its own Composable, called a NavigationNode, then we don't need to declare it in our builder, the builder is convenient in Multi Module projects
class DetailsBottomSheetKey(
val item: String
) : NavigationKey.WithNode<BottomSheet> {
override fun navigationNode() = BottomSheet {
Text(text = "Item: $item")
}
}
To get the instance of our navigator and do some navigation:
@Composable
fun HomeScreen() {
val navigator = requireLocalNavigator()
// On Button click or some other event
navigator.push(ProfileKey("some_id"))
// We can also go back by calling pop
navigator.pop()
}