Handles iOS 13 dismiss gesture when signing in

This commit is contained in:
Riley Testut
2019-10-03 13:09:38 -07:00
parent d76543d045
commit f1d287294d
2 changed files with 39 additions and 18 deletions

View File

@@ -36,6 +36,7 @@ class AuthenticationOperation: ResultOperation<ALTSigner>
private lazy var navigationController: UINavigationController = {
let navigationController = self.storyboard.instantiateViewController(withIdentifier: "navigationController") as! UINavigationController
navigationController.presentationController?.delegate = self
return navigationController
}()
@@ -44,6 +45,8 @@ class AuthenticationOperation: ResultOperation<ALTSigner>
private var appleIDPassword: String?
private var shouldShowInstructions = false
private var signer: ALTSigner?
init(presentingViewController: UIViewController?)
{
self.presentingViewController = presentingViewController
@@ -87,8 +90,10 @@ class AuthenticationOperation: ResultOperation<ALTSigner>
case .success(let certificate):
self.progress.completedUnitCount += 1
let signer = ALTSigner(team: team, certificate: certificate)
self.signer = signer
self.showInstructionsIfNecessary() { (didShowInstructions) in
let signer = ALTSigner(team: team, certificate: certificate)
self.finish(.success(signer))
}
}
@@ -388,3 +393,18 @@ private extension AuthenticationOperation
}
}
}
extension AuthenticationOperation: UIAdaptivePresentationControllerDelegate
{
func presentationControllerWillDismiss(_ presentationController: UIPresentationController)
{
if let signer = self.signer
{
self.finish(.success(signer))
}
else
{
self.finish(.failure(OperationError.cancelled))
}
}
}