https://kotlinlang.org logo
Title
t

Tgo1014

05/02/2022, 1:55 PM
What’s the best way to avoid clicking two items at the same time and navigating to both at once with compose navigation?
🤔 1
f

Filip Wiesner

05/02/2022, 2:09 PM
Double clicking the same item is not an issue?
t

Tgo1014

05/02/2022, 2:10 PM
Also is
f

Filip Wiesner

05/02/2022, 2:10 PM
I use this:
val NavBackStackEntry.isResumed: Boolean
    get() = lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)
And then use like this:
onNavigateToNotifications = {
    if (navEntry.isResumed) {
        navController.navigate(Destination.Notifications.route)
    }
}
You get
navEntry
as input parameter of
composable
destination
content
lambda
t

Tgo1014

05/02/2022, 2:34 PM
This fixed it, thanks Filip!
🎉 1