Enhance presentationControllerDidAttemptToDismiss to include support for presentationControllerDidAttemptToDismiss

Originator:PFriese
Number:rdar://FB9782213 Date Originated:2021-11-26
Status:Open Resolved:
Product:SwiftUI Product Version:
Classification:Suggestion Reproducible:Yes
 
Using interactiveDismissDisabled, it is now possible to disable interactive dismissal of a sheet or other modal views.

However, it’s often desirable to make this dependent on a user interaction. A canonical example for this is Apple’s Reminders app: after changing a reminder in the edit dialog, the user will be shown a confirmation dialog when trying to dismiss the dialog. 

In UIKit, we can use presentationControllerDidAttemptToDismiss to achieve this. It seems presentationControllerDidAttemptToDismiss is lacking this feature.

I built a drop-in solution that adds this to SwiftUI: in this gist: https://gist.github.com/peterfriese/8fb3d76bdbe21b84495b79b3a86bf898

There is also an article discussing this in more detail on my blog at https://peterfriese.dev

Happy to discuss this further.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!