-
Notifications
You must be signed in to change notification settings - Fork 110
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
Fix LockViewController dismissal when presented as a popup #647
Conversation
closable
option behavior when Lock is presented as a popupclosable
option behavior when Lock is presented as a popup
On iPad, with a presentation style of .formSheet, the LockViewController could be dismissed by simply tapping outside the bounds of the modal, without regard for the `closable` [1] option. Setting `isModalInPresentation` [2] based on `closable` allows controlling whether or not UIKit should prevent the interactive dismissal of the popup. [1] https://auth0.com/docs/libraries/lock-swift/lock-swift-configuration-options#closable [2] https://developer.apple.com/documentation/uikit/uiviewcontroller/3229894-ismodalinpresentation
Call onCancel when the Lock view controller modal is dismissed by the user (by tapping outside its bounds on iPad). This is not called when it's dismissed programmatically: https://developer.apple.com/documentation/uikit/uiadaptivepresentationcontrollerdelegate/3229889-presentationcontrollerdiddismiss
closable
option behavior when Lock is presented as a popup
FYI @Widcket I'm still interested in pursuing this but had some issues running the tests locally. I should be able to spend a bit more time investigating early next year, though I'd appreciate any insight if you found the time to review. Ty! |
I found out the issue, the delegate needs to be set on Screen.Recording.2021-04-08.at.21.57.19.mov@cocojoe please review, as I made and pushed that change. |
@@ -138,6 +137,7 @@ public class LockViewController: UIViewController { | |||
center.addObserver(self, selector: #selector(keyboardWasShown), name: UIResponder.responderKeyboardWillShowNotification, object: nil) | |||
center.addObserver(self, selector: #selector(keyboardWasHidden), name: UIResponder.responderKeyboardWillHideNotification, object: nil) | |||
|
|||
self.presentationController?.delegate = self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why it had to be in viewDidLoad
instead of init
: could you explain?
Issues
On iPad, the
LockViewController
is presented as a.formSheet
. As such, it can be dismissed by simply tapping outside the bounds of the modal. In this scenario, there are two issues:closable
option has no effect on iPad #658: Theclosable
Lock option has no effect if set tofalse
(default): the modal will be dismissed either wayonCancel
callback not triggered when dismissing LockViewController on iPad #659: The developer gets no callbacks (onCancel
) after that dismissalChanges
isModalInPresentation
based onclosable
allows controlling whether or not UIKit should prevent the interactive dismissal of the modalpresentationControllerDidDismiss
allows us to trigger the cancel callback when the user manually dismissed the modalTesting
On iPad:
closable
option set to false (or not set, since that's the default), check that the lock modal does not get dismissed when tapping outside its bounds (used to fail before this change)closable
option set to true, check that the lock modal gets dismissed when tapping outside its bounds and that theonCancel
callback is triggered.Checklist