Quick Start¶
This section describes how to quickly get started with Eungabi.
1. Create Navigation Controller.¶
The navigation Controller(EunGabiController) holds the navigation graph and provides methods that allow your app to move between the destinations you want by controlling backStack.
To create a EunGabiController in composable function, call rememberEunGabiController
val controller = rememberEunGabiController()
Warning
You must use EunGabiController with EunGabiNavHost, as described in the next section, by passing it as a parameter.
There are two key methods you should know: navigate, navigateUp
navigate allows you to navigate to the next screen by adding the provided route to the back stack.
navigateUp allows you to navigate to the previous screen by removing a latest entry(or entries) from the back stack.
2. Create a Navigation Host Composable¶
The EunGabiNavHost creates a navigation graph and displays the current entry of the back stack.
By using this, you can define and control your desired routes.
you can simply call EunGabiNavHost in the composable function to create a navigation host.
val controller = rememberEunGabiController()
EunGabiNavHost(
modifier = Modifier,
controller = controller,
startDestination = "routeA",
) {
composable("routeA") {
MainComponent("routeA") {
controller.navigate("routeB")
}
}
composable("routeB") {
DetailsComponent(
"routeB",
onNavigateBack = controller::navigateUp
) {
egController.navigate("routeC")
}
}
//...
}
The process of displaying a screen to the user
- The call to the
EunGabiNavHostcomposable passes aEunGabiControllerand a route for the start destination. - The lambda passed to the
EunGabiNavHostcreatesEunGabiGraphand set the graph to theEunGabiController.graph - Each route is supplied as a
EunGabiDestinationby callingEunGabiGraphBuilder.composable()which adds the destination to the resultingEunGabiGraphdescribed at 2. - The lambda passed to
composable()is what theEunGabiNavHostdisplays for that destination.