Refactor and merge code of extensions
This commit is contained in:
parent
87d1dd5be1
commit
776884e894
13 changed files with 391 additions and 446 deletions
|
|
@ -32,6 +32,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
|
|||
let dataSource = PasswordsTableDataSource(entries: passwordsTableEntries)
|
||||
passwordsViewController.dataSource = dataSource
|
||||
passwordsViewController.selectionDelegate = self
|
||||
passwordsViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancel))
|
||||
}
|
||||
|
||||
override func prepareCredentialList(for serviceIdentifiers: [ASCredentialServiceIdentifier]) {
|
||||
|
|
@ -58,6 +59,11 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
|
|||
passwordsViewController.navigationItem.prompt = identifier
|
||||
passwordsViewController.showPasswordsWithSuggstion(matching: identifier)
|
||||
}
|
||||
|
||||
@objc
|
||||
private func cancel(_: AnyObject?) {
|
||||
self.extensionContext.cancelRequest(withError: NSError(domain: "PassExtension", code: 0))
|
||||
}
|
||||
}
|
||||
|
||||
extension CredentialProviderViewController: PasswordSelectionDelegate {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ import passKit
|
|||
|
||||
// cancel means cancel the extension
|
||||
class PasscodeLockViewControllerForExtension: PasscodeLockViewController {
|
||||
var originalExtensionContext: ASCredentialProviderExtensionContext!
|
||||
var originalExtensionContext: NSExtensionContext!
|
||||
|
||||
convenience init(extensionContext: ASCredentialProviderExtensionContext) {
|
||||
convenience init(extensionContext: NSExtensionContext) {
|
||||
self.init()
|
||||
self.originalExtensionContext = extensionContext
|
||||
}
|
||||
|
|
@ -27,15 +27,15 @@ class PasscodeLockViewControllerForExtension: PasscodeLockViewController {
|
|||
|
||||
@objc
|
||||
func cancelExtension() {
|
||||
originalExtensionContext.cancelRequest(withError: NSError(domain: ASExtensionErrorDomain, code: ASExtensionError.userCanceled.rawValue))
|
||||
originalExtensionContext.cancelRequest(withError: NSError(domain: "PassExtension", code: 0))
|
||||
}
|
||||
}
|
||||
|
||||
class PasscodeExtensionDisplay {
|
||||
private let passcodeLockVC: PasscodeLockViewControllerForExtension
|
||||
private let extensionContext: ASCredentialProviderExtensionContext?
|
||||
private let extensionContext: NSExtensionContext?
|
||||
|
||||
init(extensionContext: ASCredentialProviderExtensionContext) {
|
||||
init(extensionContext: NSExtensionContext) {
|
||||
self.extensionContext = extensionContext
|
||||
self.passcodeLockVC = PasscodeLockViewControllerForExtension(extensionContext: extensionContext)
|
||||
passcodeLockVC.setCancellable(true)
|
||||
|
|
|
|||
|
|
@ -47,12 +47,6 @@ class PasswordsViewController: UIViewController {
|
|||
dataSource.showTableEntriesWithSuggestion(matching: text)
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
@IBAction
|
||||
private func cancel(_: AnyObject?) {
|
||||
self.extensionContext?.cancelRequest(withError: NSError(domain: ASExtensionErrorDomain, code: ASExtensionError.userCanceled.rawValue))
|
||||
self.dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
extension PasswordsViewController: UISearchBarDelegate {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue