The closed issue (No way to know when a sheet is dismissed #14) resurfaced
Closed this issue · 1 comments
DeanFs commented
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!
johnpatrickmorgan commented
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?