https://kotlinlang.org logo
#compose
Title
# compose
a

aipok

06/01/2021, 7:24 AM
Does anyone know how fake/pass navController to make a preview for BottomNavigation?
k

knthmn

06/01/2021, 7:35 AM
The alternative is to factor out the composable to accept simple values and lambdas
Copy code
@Composable fun BottomNavigation(navController: NavController) {
    val currentDestination by navController.observeDestinationAsState()
    BottomNavigation(currentDestination, navController::navigate)
}

@Composable fun BottomNavigation(destination: String, navigate: (String) -> Unit) { ... }
and you can use the second composable for previews
👍 1
i

Ian Lake

06/01/2021, 7:01 PM