Understanding and Implementing Navigation Components Jetpack Compose in Application | Part 1

Photo by Heidi Fin on Unsplash

Introduction

Navigation in Jetpack Compose

...
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ComicsLibraryTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
val navController = rememberNavController()
CharactersScaffold(navController=navController)

}
}
}
}
}

@Composable
fun CharactersScaffold(navController: NavHostController){
val scaffoldState = rememberScaffoldState()

Scaffold(scaffoldState = scaffoldState, bottomBar = { CharacterBottomNav(navController = navController)}) { _ ->
NavHost(navController = navController,startDestination = Destination.Library.route){
...
//destination screen..
}
}
}
...

Conclusion

“You don’t have to be great to start, but you have to start to be great.” — Zig Ziglar

--

--

music, coding, technology

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store