Skip to content

Commit

Permalink
Fix LockViewController dismissal when presented as a popup (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
agirault authored Apr 13, 2021
1 parent aa6287a commit 5a7499e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Lock/LockViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class LockViewController: UIViewController {
self.modalPresentationStyle = .fullScreen
}
self.router = lock.classicMode ? ClassicRouter(lock: lock, controller: self) : PasswordlessRouter(lock: lock, controller: self)
if #available(iOS 13.0, *) {
self.isModalInPresentation = !lock.options.closable
}
}

public required init?(coder aDecoder: NSCoder) {
Expand Down Expand Up @@ -134,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
self.present(self.router.root, title: Route.root.title(withStyle: self.lock.style))
}

Expand Down Expand Up @@ -212,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 5a7499e

Please sign in to comment.