Skip to content

Commit

Permalink
Dispatch cancel callback when the Lock view is interactively dismissed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Alexis Girault committed Dec 1, 2020
1 parent c4b95ca commit 817d769
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Lock/LockViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class LockViewController: UIViewController {
if #available(iOS 13.0, *) {
self.isModalInPresentation = !lock.options.closable
}
self.presentationController?.delegate = self
self.router = lock.classicMode ? ClassicRouter(lock: lock, controller: self) : PasswordlessRouter(lock: lock, controller: self)
}

Expand Down Expand Up @@ -215,3 +216,11 @@ public class LockViewController: UIViewController {
}

}

// MARK: - UIAdaptivePresentationControllerDelegate

extension LockViewController: UIAdaptivePresentationControllerDelegate {
public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
self.lock.observerStore.dispatch(result: .cancel)
}
}

0 comments on commit 817d769

Please sign in to comment.