voyager
voyager copied to clipboard
How to hide bottom tab bar at specific screens?
I have bottom tab bar at an app, but I want to hide it at specific screes. How to implement that?
Has anyone found any solution for this case?
You can use Nested Navigator, as mentioned in this issue: https://github.com/adrielcafe/voyager/issues/204.
To get the root, I implemented it like this:
fun findRootNavigator(
currentNavigator: Navigator,
depth: Int
): Navigator {
return if (depth == 0 || currentNavigator.parent == null) {
currentNavigator
} else {
return findRootNavigator(
currentNavigator = currentNavigator.parent!!,
depth = depth - 1
)
}
}
val currentNavigator = LocalNavigator.currentOrThrow
val targetNavigator = findRootNavigator(
currentNavigator = currentNavigator,
depth = 2
)
targetNavigator.push(
item = DetailsScreen()
)