mirror of
https://github.com/mssun/passforios.git
synced 2026-03-03 18:24:08 +01:00
* Do not present lock view in 'viewDidLoad' since this might be too early for an extension ("Not running foreground").
* Instead, show it for actions requiring authentication, e.g. showing the password list or providing a password, or only in 'viewDidAppear'.
* Refactor and lazily load other view controllers and data.
* Let credential providing view controllers decide when to hide themselves.
31 lines
1.1 KiB
Swift
31 lines
1.1 KiB
Swift
//
|
|
// PasscodeExtensionDisplay.swift
|
|
// passAutoFillExtension
|
|
//
|
|
// Created by Yishi Lin on 14/6/17.
|
|
// Copyright © 2017 Bob Sun. All rights reserved.
|
|
//
|
|
|
|
import passKit
|
|
|
|
class PasscodeExtensionDisplay {
|
|
private let passcodeLockVC: PasscodeLockViewControllerForExtension
|
|
private let extensionContext: NSExtensionContext?
|
|
|
|
init(extensionContext: NSExtensionContext) {
|
|
self.extensionContext = extensionContext
|
|
self.passcodeLockVC = PasscodeLockViewControllerForExtension(extensionContext: extensionContext)
|
|
passcodeLockVC.setCancellable(true)
|
|
}
|
|
|
|
// present the passcode lock view if passcode is set and the view controller is not presented
|
|
func presentPasscodeLockIfNeeded(_ sender: UIViewController, before: (() -> Void)? = nil, after: (() -> Void)? = nil) {
|
|
if PasscodeLock.shared.hasPasscode {
|
|
before?()
|
|
passcodeLockVC.successCallback = after
|
|
passcodeLockVC.modalPresentationStyle = .fullScreen
|
|
sender.parent?.present(passcodeLockVC, animated: false)
|
|
}
|
|
}
|
|
}
|