-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResultBackNavigator with multiple destinations (optionally with no result) #296
Comments
Hi @MaxMichel2 👋 Navigating back with no result, absolutely there is already a method to do that!
Do you mean the If you're not sending a result, why are you using Result Back feature? 😄 |
Yes (Sorry for the delay) I mean the In my case I'm not currently using the provided result but will likely use it in the future and all of my destinations will return a result of that type so I'd like to group them together since the importance isn't the destination but the result and with the current setup, we have to handle multiple different And yes, I thought of the ON_RESUME after posting this ^^ I've lost my XML reflexes with Compose ;) |
I'll leave this as a possible enhancement for the future. |
Hi @raamcosta, I have a similar situation where I need your help navigating from a fragment and sending the result back to another fragment that is not the previous one but another one on the stack. My app has a flow of 4 screens that can be stacked on top of each other, namely A -> B -> C -> D. Each screen has a button "X" that cancels the entire flow and sends a result back. They also have another call to action that can finish the flow sending a result back. However, when I call the setResult on the screen D, it sets the value on SavedStateHandle of the previous screen on the stack, which is screen C. I was thinking of having a setResult function that also receives a Route/Destination, and then we could search the backstack for it. However, I'm concerned that the popBackStack to the origin will trigger the cancels in screens B and C. fun setResult(route: Route, result : T)
navController.getBackStackEntry(destinationRoute.route)?.savedStateHandle?.let {
it[RESULT_BACK] = result
...
}
result.setResult(ADestination, result) Can you provide some guidance on how to implement this navigation flow properly? |
Hi @extmkv Sorry I didn't notice this question before. There's no built-in support for something like that 🤔 |
Maybe search for how to do this would normal compose navigation, that will definitely also work with compose destinations (maybe not as clean as with the result back feature though). |
Make Result back feature work between different modules....Please write the code from different module such as: ScreenA,ScreenB and ScreenC. ScreenB and ScreenC is different Module. I want to result back ScreenA but how it will be solved it? |
The idea would be to provide a list of destinations that the
ResultBackNavigator
should expect a result from.I imagine something that would look like this:
This would then allow us to have a
onNavResult
listener that passes both the result and the destinationOptionally, in some cases we actually just want to detect the
navigateBack
action without actually passing a result so this could also be an interesting and useful addition (Unless there is something that exists specifically for this that I'm unaware of)The text was updated successfully, but these errors were encountered: