2018-09-24 22:03:14 +08:00
|
|
|
//
|
2021-08-25 21:01:22 +02:00
|
|
|
// PasscodeExtensionDisplay.swift
|
|
|
|
|
// passAutoFillExtension
|
2018-09-24 22:03:14 +08:00
|
|
|
//
|
|
|
|
|
// Created by Yishi Lin on 14/6/17.
|
|
|
|
|
// Copyright © 2017 Bob Sun. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import passKit
|
|
|
|
|
|
|
|
|
|
class PasscodeExtensionDisplay {
|
|
|
|
|
private let passcodeLockVC: PasscodeLockViewControllerForExtension
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2021-01-10 13:40:17 -08:00
|
|
|
init(extensionContext: NSExtensionContext) {
|
2020-06-28 21:25:40 +02:00
|
|
|
self.passcodeLockVC = PasscodeLockViewControllerForExtension(extensionContext: extensionContext)
|
2018-09-24 22:03:14 +08:00
|
|
|
passcodeLockVC.setCancellable(true)
|
|
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2018-09-24 22:03:14 +08:00
|
|
|
// present the passcode lock view if passcode is set and the view controller is not presented
|
2021-08-27 23:34:30 +02:00
|
|
|
func presentPasscodeLockIfNeeded(_ sender: UIViewController, before: (() -> Void)? = nil, after: (() -> Void)? = nil) {
|
|
|
|
|
if PasscodeLock.shared.hasPasscode {
|
|
|
|
|
before?()
|
|
|
|
|
passcodeLockVC.successCallback = after
|
|
|
|
|
passcodeLockVC.modalPresentationStyle = .fullScreen
|
2021-08-31 18:25:40 -07:00
|
|
|
sender.parent?.present(passcodeLockVC, animated: false) {
|
|
|
|
|
after?()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
after?()
|
2021-01-03 21:36:57 -08:00
|
|
|
}
|
2018-09-24 22:03:14 +08:00
|
|
|
}
|
|
|
|
|
}
|