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

bryansills

10/16/2020, 4:02 PM
speaking of navigation, should something like this work?
Copy code
@Composable
fun BasicNav() {
    var isLoggedIn by remember { mutableStateOf(false) }
    NavHost(startDestination = "Profile") {
        composable("Profile") { Profile(isLoggedIn) { isLoggedIn = !isLoggedIn } }
        composable("Dashboard") { Dashboard() }
        if (isLoggedIn) {
            composable("Scrollable") { Scrollable() }
        }
    }
}
(the lambda passed into
Profile()
) is just connected to a
Button
to toggle the logged in state
i

Ian Lake

10/16/2020, 6:45 PM
The underlying issue that Mark filed, https://issuetracker.google.com/issues/169471826, is still open and assigned to @Leland Richardson [G]
b

bryansills

10/16/2020, 8:22 PM
yeah it is. lifting the state up to a higher level made the conditional navigation graph work.
this type of code (where you define state locally) works in react. it would be nice to work in compose land.
but super glad that the nav stuff already has some of this functionality working.
2 Views