Skip to content
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

The closed issue (No way to know when a sheet is dismissed #14) resurfaced #78

Closed
DeanFs opened this issue Jul 3, 2024 · 1 comment
Closed

Comments

@DeanFs
Copy link

DeanFs commented Jul 3, 2024

The issue No way to know when a sheet is dismissed resurfaced after the this commit: Rewrites FlowStacks APIs.

This issue is not fixed in the latest version.
Will the onDismiss closure be supported again in a future release.
Or is there any other way to achieve the same effect.
Thank you so much for providing such an excellent library!

@DeanFs DeanFs changed the title #15 is now merged, so I'll close this issue. Thanks @lionel-alves for raising it. And thanks @zntfdr for your suggestion - I think I prefer that approach as each Route can remain a simple 'bag of values', and it's not much work to be notified when a route is dismissed, e.g.: The issue [#14](https://github.com/johnpatrickmorgan/FlowStacks/issues/14) resurfaced Jul 3, 2024
@DeanFs DeanFs changed the title The issue [#14](https://github.com/johnpatrickmorgan/FlowStacks/issues/14) resurfaced The closed issue (No way to know when a sheet is dismissed #14) resurfaced Jul 3, 2024
@johnpatrickmorgan
Copy link
Owner

Hi @DeanFs , thanks for raising this issue. It's possible to detect dismissals by adding an onChange modifier, e.g.:

.onChange(of: routes) { [oldRoutes = routes] newRoutes in
  let dismissedRoutes = oldRoutes.suffix(from: min(oldRoutes.endIndex, newRoutes.endIndex))
  guard !dismissedRoutes.isEmpty else { return }
  print("dismissed:", dismissedRoutes.map { $0.screen })
}

This has the advantage of working for all forms of navigation, e.g. push/pop navigation too. Does that work for your use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants