Hi, finally starting to understand the coordinator pattern!
There is a bug in the final app:
When you swipe down to manually dismiss the modally presented ‘VisitType’ view controller, the performOnDismissed method is never triggered. The child coordinator is never removed.
Pressing the ‘cancel’ button on the ‘VisitType’ view controller calls performOnDismissed so the child coordinator is removed.
Obviously, sometimes people just swipe down to dismiss the view controller. How do we remove the child coordinator in these cases?
As you hint at as well, iOS 13 changes the default way that view controllers are presented modally. They can now be dismissed by swiping down too. The ModalNavigationRouter doesn’t currently detect when this happens, so it doesn’t call performOnDismissed and nothing is cleaned up!
Fortunately, there’s an easy fix for this, by conforming to UIAdaptivePresentationControllerDelegate:
Make ModalNavigationRouter conform to UIAdaptivePresentationControllerDelegate by adding the following to the end of ModalNavigationRouter.swift: