How do I add wrapping content to a scene? #279
-
Now, I have @Composable
fun NavWrapper(content: @Composable (PaddingValues) -> Unit = {}) {
Scaffold(
modifier = Modifier,
topBar = {
// ......
},
bottomBar = {
// ......
},
) {
content(it)
}
}
Now I have the following scenes
For the first two, I tried using the following method NavHost(
navigator = GlobalStore.navigator,
initialRoute = Route.Home,
navTransition = NavFadeTransition()
) {
NavWrapper {
scene(
route = Route.Home,
) {
HomeScene(it)
}
scene(
route = Route.User,
) {
UserScene(it)
}
}
scene(
route = Route.User,
) {
DetailScene()
}
} But it doesn't work. Is there any support for this? How do I add wrapping content to a scene? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
You can wrap your |
Beta Was this translation helpful? Give feedback.
-
For NavWrapper { paddingValues ->
NavHost(
navigator = GlobalStore.navigator,
initialRoute = Route.PERIOD,
navTransition = NavFadeTransition()
) {
scene(
route = Route.PERIOD,
) {
HomeScene(paddingValues)
}
scene(
route = Route.USER,
) {
UserScene(paddingValues)
}
}
}
NavHost(
navigator = GlobalStore.navigator,
initialRoute = Route.DETAIL,
navTransition = NavFadeTransition()
) {
DetailScene()
} I cannot jump from Is there another solution? Or does it behave like a child page? |
Beta Was this translation helpful? Give feedback.
-
You can wrap the screen that you do want to wrap with |
Beta Was this translation helpful? Give feedback.
-
Like this? NavHost(
navigator = GlobalStore.navigator,
initialRoute = Route.PERIOD,
navTransition = NavFadeTransition()
) {
scene(
route = Route.HOME,
) {
NavWrapper {
HomeContent(it)
}
}
scene(
route = Route.USER,
) {
NavWrapper {
UsertContent(it)
}
}
scene(
route = Route.DETAIL,
) {
DetailScene()
}
} My route switching has animation effects. When I do this, both the |
Beta Was this translation helpful? Give feedback.
-
Or you can have a nested |
Beta Was this translation helpful? Give feedback.
-
Convert into discussion since this is not a "issue" |
Beta Was this translation helpful? Give feedback.
Or you can have a nested
NavHost
for your home and user