Member-only story

Bottom Navigation Bar in Jetpack Compose.

Jayant Kumar🇮🇳
5 min readAug 31, 2023

Photo by Anastasia Petrova on Unsplash

Link For Non-Members

In this article we will be talking about Bottom Navigation Bar in Jetpack Compose.

Basically we will have three screens …..

Splash → BottomBar (Home , Notification , Profile)-> Detail

First screen will be your splash screen after 2 secs it will move to bottom bar screen , when we will click on move to detail screen button it will move to detail screen and we will also see how to hide bottom Bar when it’s not needed , Interesting!!

First let’s define all the required routes/tags (unique keys) for all the composable functions.

BottomBar Routes

enum class BottomBarRoutes(
val id: Int,
@StringRes val title: Int,
val routes: String,
@DrawableRes val icon: Int
) {

HOME(1, R.string.home, "/home", R.drawable.home),
NOTIFICATION(
2,
R.string.notification, "/notification", R.drawable.notification
),
Profile(3, R.string.profile, "/profile", R.drawable.profile)

}

As you can see in the above code , we have created an enum class , which contains Bottom Bar’s routes , title & icon .

Normal Screen Routes

sealed class ScreenRoutes(val route: String) {

data object Splash : ScreenRoutes("/splash")
data object BottomBar : ScreenRoutes("/bottombar")
data object Detail : ScreenRoutes("/detail")

}

As you can see above , we have created routes for splash , bottombar & detail screen. bottombar object will be your nested navigation , which contains BottomBarRoutes enum inside it (if you didn’t get don’t worry).

Okay so we defined all the routes now let’s create all the composable functions ( splash, bottombar (Home , Notification , Profile) , detail screens ).

Splash Screen

@Composable
fun SplashScreen(
navHostController: NavHostController
)
{

LaunchedEffect(key1 = Unit){
delay(2000)
navHostController.navigate(ScreenRoutes.BottomBar.route)
}…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Jayant Kumar🇮🇳
Jayant Kumar🇮🇳

Written by Jayant Kumar🇮🇳

Hello My name is Jayant Kumar, I am a software Engineer , specialist in Mobile Development (Android , IOS , Flutter , React Native) from India 🇮🇳

Responses (1)

Is it possible to do the same thing, but use NavigationBar with NavigationBarItem instead of BottomAppBar and BottomBarRow? Thanks for the interesting tutorial.