FlowStacks icon indicating copy to clipboard operation
FlowStacks copied to clipboard

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

Open DeanFs opened this issue 1 year ago • 1 comments

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 avatar Jul 03 '24 07:07 DeanFs

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?

johnpatrickmorgan avatar Jul 04 '24 15:07 johnpatrickmorgan