Hello ! I'm building a wear os app using compose, ...
# compose-wear
l
Hello ! I'm building a wear os app using compose, and using
SwipeDismissableNavHost
I've found that the swiping gesture is ignoring the
BackHandler
inside the composable. For example, if my nav graph is: A -> B -> C, and the swipe from C should redirect to A. I think I have to custom some behavior of the SwipeToDismissBox, but I'm not sure how. Any help is appreciated!
Copy code
composable(
    Paths.WORD,
    arguments = listOf(navArgument("language") { defaultValue = "EN" })
){ navBackStackEntry ->
    BackHandler() { navController.navigate(Paths.HOME) }
    CompleteWord(navController, listState, completeWordViewModel, navBackStackEntry.arguments?.getString("language")!!.toLanguage())
}
Slack Conversation
j
@Steve Bower [G]
s
Hi Lisandro - I'll have a look at this, but at first sight I would expect a) SwipeDismissableNavHost to always pop the navigation back stack when you swipe to dismiss b) the back button (e.g. on the emulator) to trigger the BackHandler you've configured.
l
b is happening correctly
But now you mention, I think I should change the backstack when going to this path in order to change swipedismissablenavhost to pop the navigation where i expect
s
Yes, you could pop the backstack on the way to C so that swiping back takes you to A. That's nice, because it means you can configure different behaviour according to how you get to C (e.g. for A -> D -> C you might still want to swipe back to D).
🙌 1
Also, the NavController defaults its back button handler to popping the back stack - so changing the backstack on that path means everything is consistent and there's no need to configure a BackHandler.
l
Great! Thank you for helping 😄 I'll try that and let you know 🙌 🙌