From b09bc7444f0e753c035bbfc938b2c44028a7e63a Mon Sep 17 00:00:00 2001 From: Mingshen Sun Date: Sat, 4 Feb 2023 15:27:37 -0800 Subject: [PATCH] Remove branches for iOS 12 compatibility --- .../PGPKeyFIleImportTableViewController.swift | 4 +-- .../PasswordDetailTableViewController.swift | 14 ++-------- .../PasswordNavigationViewController.swift | 18 ++++-------- .../SSHKeyFileImportTableViewController.swift | 4 +-- .../Controllers/PasswordsViewController.swift | 4 +-- passKit/Helpers/Colors.swift | 28 +++---------------- passKit/Helpers/YubiKeyConnection.swift | 4 +-- 7 files changed, 17 insertions(+), 59 deletions(-) diff --git a/pass/Controllers/PGPKeyFIleImportTableViewController.swift b/pass/Controllers/PGPKeyFIleImportTableViewController.swift index 58dd834..90d5cbf 100644 --- a/pass/Controllers/PGPKeyFIleImportTableViewController.swift +++ b/pass/Controllers/PGPKeyFIleImportTableViewController.swift @@ -35,9 +35,7 @@ class PGPKeyFileImportTableViewController: AutoCellHeightUITableViewController, return } picker.delegate = self - if #available(iOS 13.0, *) { - picker.shouldShowFileExtensions = true - } + picker.shouldShowFileExtensions = true present(picker, animated: true, completion: nil) } } diff --git a/pass/Controllers/PasswordDetailTableViewController.swift b/pass/Controllers/PasswordDetailTableViewController.swift index 7885d8e..4a462d3 100644 --- a/pass/Controllers/PasswordDetailTableViewController.swift +++ b/pass/Controllers/PasswordDetailTableViewController.swift @@ -550,17 +550,9 @@ extension PasswordDetailTableViewController { switch error { case let .yubiKey(yubiKeyError): let errorMessage = yubiKeyError.localizedDescription - if #available(iOS 13.0, *) { - YubiKitManager.shared.stopNFCConnection(withErrorMessage: errorMessage) - DispatchQueue.main.async { - self.navigationController?.popViewController(animated: true) - } - } else { - DispatchQueue.main.async { - self.presentFailureAlert(message: errorMessage) { _ in - self.navigationController?.popViewController(animated: true) - } - } + YubiKitManager.shared.stopNFCConnection(withErrorMessage: errorMessage) + DispatchQueue.main.async { + self.navigationController?.popViewController(animated: true) } default: DispatchQueue.main.async { diff --git a/pass/Controllers/PasswordNavigationViewController.swift b/pass/Controllers/PasswordNavigationViewController.swift index 7ac2839..2030e19 100644 --- a/pass/Controllers/PasswordNavigationViewController.swift +++ b/pass/Controllers/PasswordNavigationViewController.swift @@ -34,9 +34,7 @@ class PasswordNavigationViewController: UIViewController { uiSearchController.obscuresBackgroundDuringPresentation = false uiSearchController.searchBar.sizeToFit() uiSearchController.searchBar.returnKeyType = .done - if #available(iOS 13.0, *) { - uiSearchController.searchBar.searchTextField.clearButtonMode = .whileEditing - } + uiSearchController.searchBar.searchTextField.clearButtonMode = .whileEditing return uiSearchController }() @@ -50,15 +48,11 @@ class PasswordNavigationViewController: UIViewController { lazy var addPasswordUIBarButtonItem: UIBarButtonItem = { var addPasswordUIBarButtonItem = UIBarButtonItem() - if #available(iOS 13.0, *) { - let addPasswordButton = UIButton(type: .system) - let plusImage = UIImage(systemName: "plus.circle", withConfiguration: UIImage.SymbolConfiguration(weight: .regular)) - addPasswordButton.setImage(plusImage, for: .normal) - addPasswordButton.addTarget(self, action: #selector(self.addPasswordAction), for: .touchDown) - addPasswordUIBarButtonItem.customView = addPasswordButton - } else { - addPasswordUIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(self.addPasswordAction)) - } + let addPasswordButton = UIButton(type: .system) + let plusImage = UIImage(systemName: "plus.circle", withConfiguration: UIImage.SymbolConfiguration(weight: .regular)) + addPasswordButton.setImage(plusImage, for: .normal) + addPasswordButton.addTarget(self, action: #selector(self.addPasswordAction), for: .touchDown) + addPasswordUIBarButtonItem.customView = addPasswordButton return addPasswordUIBarButtonItem }() diff --git a/pass/Controllers/SSHKeyFileImportTableViewController.swift b/pass/Controllers/SSHKeyFileImportTableViewController.swift index 9e8e5c4..4483794 100644 --- a/pass/Controllers/SSHKeyFileImportTableViewController.swift +++ b/pass/Controllers/SSHKeyFileImportTableViewController.swift @@ -27,9 +27,7 @@ class SSHKeyFileImportTableViewController: AutoCellHeightUITableViewController { return } picker.delegate = self - if #available(iOS 13.0, *) { - picker.shouldShowFileExtensions = true - } + picker.shouldShowFileExtensions = true present(picker, animated: true, completion: nil) } } diff --git a/passAutoFillExtension/Controllers/PasswordsViewController.swift b/passAutoFillExtension/Controllers/PasswordsViewController.swift index b33c043..31eaa0a 100644 --- a/passAutoFillExtension/Controllers/PasswordsViewController.swift +++ b/passAutoFillExtension/Controllers/PasswordsViewController.swift @@ -21,9 +21,7 @@ class PasswordsViewController: UIViewController { uiSearchController.searchBar.isTranslucent = true uiSearchController.obscuresBackgroundDuringPresentation = false uiSearchController.searchBar.sizeToFit() - if #available(iOS 13.0, *) { - uiSearchController.searchBar.searchTextField.clearButtonMode = .whileEditing - } + uiSearchController.searchBar.searchTextField.clearButtonMode = .whileEditing return uiSearchController }() diff --git a/passKit/Helpers/Colors.swift b/passKit/Helpers/Colors.swift index 737b971..51aabc0 100644 --- a/passKit/Helpers/Colors.swift +++ b/passKit/Helpers/Colors.swift @@ -7,33 +7,13 @@ // public enum Colors { - public static let label: UIColor = { - if #available(iOS 13.0, *) { - return .label - } - return .black - }() + public static let label: UIColor = .black - public static let secondaryLabel: UIColor = { - if #available(iOS 13.0, *) { - return .secondaryLabel - } - return .init(red: 60.0, green: 60.0, blue: 67.0, alpha: 0.6) - }() + public static let secondaryLabel: UIColor = .init(red: 60.0, green: 60.0, blue: 67.0, alpha: 0.6) - public static let systemBackground: UIColor = { - if #available(iOS 13.0, *) { - return .systemBackground - } - return .white - }() + public static let systemBackground: UIColor = .white - public static let secondarySystemBackground: UIColor = { - if #available(iOS 13.0, *) { - return .secondarySystemBackground - } - return .init(red: 242.0, green: 242.0, blue: 247.0, alpha: 1.0) - }() + public static let secondarySystemBackground: UIColor = .init(red: 242.0, green: 242.0, blue: 247.0, alpha: 1.0) public static let systemRed = UIColor.systemRed diff --git a/passKit/Helpers/YubiKeyConnection.swift b/passKit/Helpers/YubiKeyConnection.swift index fe75940..4d8c758 100644 --- a/passKit/Helpers/YubiKeyConnection.swift +++ b/passKit/Helpers/YubiKeyConnection.swift @@ -27,9 +27,7 @@ public class YubiKeyConnection: NSObject { completion(connection) } else { connectionCallback = completion - if #available(iOSApplicationExtension 13.0, *) { - YubiKitManager.shared.startNFCConnection() - } + YubiKitManager.shared.startNFCConnection() } cancellationCallback = cancellation }