diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index 98991c7..eeab261 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -44,6 +44,7 @@ 30697C5321F63E0B0064FCAC /* PasscodeExtensionDisplay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C5121F63E0B0064FCAC /* PasscodeExtensionDisplay.swift */; }; 30697C5421F63E0B0064FCAC /* CredentialProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C5221F63E0B0064FCAC /* CredentialProviderViewController.swift */; }; 30697C5F21F674800064FCAC /* String+UtilitiesTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C5E21F674800064FCAC /* String+UtilitiesTest.swift */; }; + 3087574F2343E42A00B971A2 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3087574E2343E42A00B971A2 /* Colors.swift */; }; 308C273A2279F9CB0016D0E2 /* SearchBarScope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302202EE222F14E400555236 /* SearchBarScope.swift */; }; 30A1D29C21AF451E00E2D1F7 /* PasswordGeneratorFlavourTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A1D29B21AF451E00E2D1F7 /* PasswordGeneratorFlavourTest.swift */; }; 30A1D2A221B2BC6F00E2D1F7 /* TokenBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A1D2A121B2BC6F00E2D1F7 /* TokenBuilder.swift */; }; @@ -261,6 +262,7 @@ 30697C5121F63E0B0064FCAC /* PasscodeExtensionDisplay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeExtensionDisplay.swift; sourceTree = ""; }; 30697C5221F63E0B0064FCAC /* CredentialProviderViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CredentialProviderViewController.swift; sourceTree = ""; }; 30697C5E21F674800064FCAC /* String+UtilitiesTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+UtilitiesTest.swift"; sourceTree = ""; }; + 3087574E2343E42A00B971A2 /* Colors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Colors.swift; sourceTree = ""; }; 30A1D29B21AF451E00E2D1F7 /* PasswordGeneratorFlavourTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordGeneratorFlavourTest.swift; sourceTree = ""; }; 30A1D2A121B2BC6F00E2D1F7 /* TokenBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenBuilder.swift; sourceTree = ""; }; 30A1D2A521B2D46100E2D1F7 /* OtpType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OtpType.swift; sourceTree = ""; }; @@ -668,6 +670,7 @@ children = ( 30697C2921F63C590064FCAC /* AppError.swift */, 302B2C9722C2BDE700D831EE /* AppKeychain.swift */, + 3087574E2343E42A00B971A2 /* Colors.swift */, 3032328D22CBD4CD009EBD9C /* CryptographicKeys.swift */, 30697C2821F63C590064FCAC /* DefaultsKeys.swift */, 30697C2521F63C590064FCAC /* FileManagerExtension.swift */, @@ -1322,6 +1325,7 @@ 30CCA91623258C380048CA51 /* PgpInterface.swift in Sources */, 30697C4721F63CAB0064FCAC /* PasscodeLock.swift in Sources */, 30697C3421F63C8B0064FCAC /* PasscodeLockViewController.swift in Sources */, + 3087574F2343E42A00B971A2 /* Colors.swift in Sources */, 30697C2C21F63C5A0064FCAC /* FileManagerExtension.swift in Sources */, 30697C3321F63C8B0064FCAC /* PasscodeLockPresenter.swift in Sources */, 30697C3D21F63C990064FCAC /* UIViewExtension.swift in Sources */, diff --git a/pass/Controllers/AdvancedSettingsTableViewController.swift b/pass/Controllers/AdvancedSettingsTableViewController.swift index 43e772e..34d5374 100644 --- a/pass/Controllers/AdvancedSettingsTableViewController.swift +++ b/pass/Controllers/AdvancedSettingsTableViewController.swift @@ -20,7 +20,7 @@ class AdvancedSettingsTableViewController: UITableViewController { let encryptInASCIIArmoredSwitch: UISwitch = { let uiSwitch = UISwitch() - uiSwitch.onTintColor = Globals.blue + uiSwitch.onTintColor = Colors.systemBlue uiSwitch.sizeToFit() uiSwitch.addTarget(self, action: #selector(encryptInASCIIArmoredAction(_:)), for: UIControl.Event.valueChanged) return uiSwitch diff --git a/pass/Controllers/GeneralSettingsTableViewController.swift b/pass/Controllers/GeneralSettingsTableViewController.swift index bb8cde7..aedb9a7 100644 --- a/pass/Controllers/GeneralSettingsTableViewController.swift +++ b/pass/Controllers/GeneralSettingsTableViewController.swift @@ -14,7 +14,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let hideUnknownSwitch: UISwitch = { let uiSwitch = UISwitch() - uiSwitch.onTintColor = Globals.blue + uiSwitch.onTintColor = Colors.systemBlue uiSwitch.sizeToFit() uiSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControl.Event.valueChanged) return uiSwitch @@ -22,7 +22,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let hideOTPSwitch: UISwitch = { let uiSwitch = UISwitch() - uiSwitch.onTintColor = Globals.blue + uiSwitch.onTintColor = Colors.systemBlue uiSwitch.sizeToFit() uiSwitch.addTarget(self, action: #selector(hideOTPSwitchAction(_:)), for: UIControl.Event.valueChanged) return uiSwitch @@ -30,7 +30,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let rememberPGPPassphraseSwitch: UISwitch = { let uiSwitch = UISwitch() - uiSwitch.onTintColor = Globals.blue + uiSwitch.onTintColor = Colors.systemBlue uiSwitch.sizeToFit() uiSwitch.addTarget(self, action: #selector(rememberPGPPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged) uiSwitch.isOn = SharedDefaults[.isRememberPGPPassphraseOn] @@ -39,7 +39,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let rememberGitCredentialPassphraseSwitch: UISwitch = { let uiSwitch = UISwitch() - uiSwitch.onTintColor = Globals.blue + uiSwitch.onTintColor = Colors.systemBlue uiSwitch.sizeToFit() uiSwitch.addTarget(self, action: #selector(rememberGitCredentialPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged) uiSwitch.isOn = SharedDefaults[.isRememberGitCredentialPassphraseOn] @@ -48,7 +48,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let showFolderSwitch: UISwitch = { let uiSwitch = UISwitch() - uiSwitch.onTintColor = Globals.blue + uiSwitch.onTintColor = Colors.systemBlue uiSwitch.sizeToFit() uiSwitch.addTarget(self, action: #selector(showFolderSwitchAction(_:)), for: UIControl.Event.valueChanged) uiSwitch.isOn = SharedDefaults[.isShowFolderOn] @@ -57,7 +57,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let hidePasswordImagesSwitch: UISwitch = { let uiSwitch = UISwitch() - uiSwitch.onTintColor = Globals.blue + uiSwitch.onTintColor = Colors.systemBlue uiSwitch.sizeToFit() uiSwitch.addTarget(self, action: #selector(hidePasswordImagesSwitchAction(_:)), for: UIControl.Event.valueChanged) uiSwitch.isOn = SharedDefaults[.isHidePasswordImagesOn] diff --git a/pass/Controllers/GitSSHKeyArmorSettingTableViewController.swift b/pass/Controllers/GitSSHKeyArmorSettingTableViewController.swift index 40f4e19..c70ab8a 100644 --- a/pass/Controllers/GitSSHKeyArmorSettingTableViewController.swift +++ b/pass/Controllers/GitSSHKeyArmorSettingTableViewController.swift @@ -74,7 +74,7 @@ class GitSSHKeyArmorSettingTableViewController: AutoCellHeightUITableViewControl armorPrivateKeyTextView.delegate = self scanPrivateKeyCell?.textLabel?.text = "ScanPrivateKeyQrCodes".localize() - scanPrivateKeyCell?.textLabel?.textColor = Globals.blue + scanPrivateKeyCell?.textLabel?.textColor = Colors.systemBlue scanPrivateKeyCell?.selectionStyle = .default scanPrivateKeyCell?.accessoryType = .disclosureIndicator } diff --git a/pass/Controllers/PGPKeyArmorSettingTableViewController.swift b/pass/Controllers/PGPKeyArmorSettingTableViewController.swift index 119b661..340adc3 100644 --- a/pass/Controllers/PGPKeyArmorSettingTableViewController.swift +++ b/pass/Controllers/PGPKeyArmorSettingTableViewController.swift @@ -92,12 +92,12 @@ class PGPKeyArmorSettingTableViewController: AutoCellHeightUITableViewController super.viewDidLoad() scanPublicKeyCell?.textLabel?.text = "ScanPublicKeyQrCodes".localize() - scanPublicKeyCell?.textLabel?.textColor = Globals.blue + scanPublicKeyCell?.textLabel?.textColor = Colors.systemBlue scanPublicKeyCell?.selectionStyle = .default scanPublicKeyCell?.accessoryType = .disclosureIndicator scanPrivateKeyCell?.textLabel?.text = "ScanPrivateKeyQrCodes".localize() - scanPrivateKeyCell?.textLabel?.textColor = Globals.blue + scanPrivateKeyCell?.textLabel?.textColor = Colors.systemBlue scanPrivateKeyCell?.selectionStyle = .default scanPrivateKeyCell?.accessoryType = .disclosureIndicator } diff --git a/pass/Controllers/PasswordEditorTableViewController.swift b/pass/Controllers/PasswordEditorTableViewController.swift index 23e6809..d0aca9b 100644 --- a/pass/Controllers/PasswordEditorTableViewController.swift +++ b/pass/Controllers/PasswordEditorTableViewController.swift @@ -48,18 +48,18 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl deletePasswordCell = UITableViewCell(style: .default, reuseIdentifier: "default") deletePasswordCell!.textLabel?.text = "DeletePassword".localize() - deletePasswordCell!.textLabel?.textColor = Globals.red + deletePasswordCell!.textLabel?.textColor = Colors.systemRed deletePasswordCell?.selectionStyle = .default scanQRCodeCell = UITableViewCell(style: .default, reuseIdentifier: "default") scanQRCodeCell?.textLabel?.text = "AddOneTimePassword".localize() - scanQRCodeCell?.textLabel?.textColor = Globals.blue + scanQRCodeCell?.textLabel?.textColor = Colors.systemBlue scanQRCodeCell?.selectionStyle = .default scanQRCodeCell?.accessoryType = .disclosureIndicator memorablePasswordGeneratorCell = UITableViewCell(style: .default, reuseIdentifier: "default") memorablePasswordGeneratorCell?.textLabel?.text = "GetMemorableOne".localize() - memorablePasswordGeneratorCell?.textLabel?.textColor = Globals.blue + memorablePasswordGeneratorCell?.textLabel?.textColor = Colors.systemBlue memorablePasswordGeneratorCell?.selectionStyle = .default memorablePasswordGeneratorCell?.accessoryType = .disclosureIndicator } @@ -125,9 +125,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl additionsCell = tableView.dequeueReusableCell(withIdentifier: "textViewCell", for: indexPath) as?TextViewTableViewCell additionsCell?.contentTextView.delegate = self additionsCell?.setContent(content: cellData[PasswordEditorCellKey.content] as? String) - if #available(iOS 13.0, *) { - additionsCell?.contentTextView.textColor = .label - } + additionsCell?.contentTextView.textColor = Colors.label return additionsCell! case .deletePasswordCell: return deletePasswordCell! diff --git a/pass/Controllers/RawPasswordViewController.swift b/pass/Controllers/RawPasswordViewController.swift index 5b49b33..0a8bdce 100644 --- a/pass/Controllers/RawPasswordViewController.swift +++ b/pass/Controllers/RawPasswordViewController.swift @@ -20,8 +20,6 @@ class RawPasswordViewController: UIViewController { rawPasswordTextView.textContainer.lineFragmentPadding = 0 rawPasswordTextView.textContainerInset = .zero rawPasswordTextView.text = password?.plainText - if #available(iOS 13.0, *) { - rawPasswordTextView.textColor = .label - } + rawPasswordTextView.textColor = Colors.label } } diff --git a/pass/Views/LabelTableViewCell.swift b/pass/Views/LabelTableViewCell.swift index 36b53cb..33561a0 100644 --- a/pass/Views/LabelTableViewCell.swift +++ b/pass/Views/LabelTableViewCell.swift @@ -119,7 +119,7 @@ class LabelTableViewCell: UITableViewCell { if type == .password { if cellData?.content.isEmpty == false { contentLabel.text = Globals.passwordDots - contentLabel.textColor = Globals.black + contentLabel.textColor = Colors.label } else { contentLabel.text = "" } diff --git a/passKit/Controllers/PasscodeLockViewController.swift b/passKit/Controllers/PasscodeLockViewController.swift index c962ad6..59b5858 100644 --- a/passKit/Controllers/PasscodeLockViewController.swift +++ b/passKit/Controllers/PasscodeLockViewController.swift @@ -40,17 +40,13 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate { self.view.addSubview(passcodeTextField) self.passcodeTextField = passcodeTextField - if #available(iOSApplicationExtension 13.0, *) { - view.backgroundColor = .systemBackground - passcodeTextField.backgroundColor = .secondarySystemBackground - passcodeTextField.textColor = .secondaryLabel - } else { - view.backgroundColor = .white - } + view.backgroundColor = Colors.systemBackground + passcodeTextField.backgroundColor = Colors.secondarySystemBackground + passcodeTextField.textColor = Colors.secondaryLabel let biometryAuthButton = UIButton(type: .custom) biometryAuthButton.setTitle("", for: .normal) - biometryAuthButton.setTitleColor(Globals.blue, for: .normal) + biometryAuthButton.setTitleColor(Colors.systemBlue, for: .normal) biometryAuthButton.addTarget(self, action: #selector(bioButtonPressedAction(_:)), for: .touchUpInside) biometryAuthButton.isHidden = true biometryAuthButton.translatesAutoresizingMaskIntoConstraints = false @@ -76,7 +72,7 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate { let forgotPasscodeButton = UIButton(type: .custom) forgotPasscodeButton.setTitle("ForgotYourPasscode?".localize(), for: .normal) forgotPasscodeButton.titleLabel?.font = UIFont.systemFont(ofSize: UIFont.systemFontSize) - forgotPasscodeButton.setTitleColor(Globals.blue, for: .normal) + forgotPasscodeButton.setTitleColor(Colors.systemBlue, for: .normal) forgotPasscodeButton.addTarget(self, action: #selector(forgotPasscodeButtonPressedAction(_:)), for: .touchUpInside) // hide the forgotPasscodeButton if the native app is running forgotPasscodeButton.isHidden = self.isCancellable @@ -86,7 +82,7 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate { let cancelButton = UIButton(type: .custom) cancelButton.setTitle("Cancel".localize(), for: .normal) - cancelButton.setTitleColor(Globals.blue, for: .normal) + cancelButton.setTitleColor(Colors.systemBlue, for: .normal) cancelButton.addTarget(self, action: #selector(passcodeLockDidCancel), for: .touchUpInside) cancelButton.isHidden = !self.isCancellable cancelButton.translatesAutoresizingMaskIntoConstraints = false diff --git a/passKit/Helpers/Colors.swift b/passKit/Helpers/Colors.swift new file mode 100644 index 0000000..ddaf1ca --- /dev/null +++ b/passKit/Helpers/Colors.swift @@ -0,0 +1,51 @@ +// +// Colors.swift +// passKit +// +// Created by Danny Moesch on 01.10.19. +// Copyright © 2019 Bob Sun. All rights reserved. +// + +public struct Colors { + public static let label: UIColor = { + if #available(iOS 13.0, *) { + return .label + } + return .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 systemBackground: UIColor = { + if #available(iOS 13.0, *) { + return .systemBackground + } + return .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 systemRed: UIColor = { + if #available(iOS 13.0, *) { + return .systemRed + } + return .red + }() + + public static let systemBlue: UIColor = { + if #available(iOS 13.0, *) { + return .systemBlue + } + return .blue + }() +} diff --git a/passKit/Helpers/Globals.swift b/passKit/Helpers/Globals.swift index be36b35..6634e32 100644 --- a/passKit/Helpers/Globals.swift +++ b/passKit/Helpers/Globals.swift @@ -41,14 +41,6 @@ public class Globals { public static let passwordFont = UIFont(name: "Courier-Bold", size: UIFont.labelFontSize - 1) // UI related - public static let red = UIColor.systemRed - public static let blue = UIColor.systemBlue - public static let black: UIColor = { - if #available(iOSApplicationExtension 13.0, *) { - return UIColor.label - } - return UIColor.black - }() public static let tableCellButtonSize = CGFloat(20.0) private init() { } diff --git a/passKit/Helpers/Utils.swift b/passKit/Helpers/Utils.swift index 671a15e..bd80802 100644 --- a/passKit/Helpers/Utils.swift +++ b/passKit/Helpers/Utils.swift @@ -22,11 +22,11 @@ public class Utils { for (index, element) in plainPassword.unicodeScalars.enumerated() { var charColor = UIColor.darkText if NSCharacterSet.decimalDigits.contains(element) { - charColor = Globals.red + charColor = Colors.systemRed } else if !NSCharacterSet.letters.contains(element) { - charColor = Globals.blue + charColor = Colors.systemBlue } else { - charColor = Globals.black + charColor = Colors.label } attributedPassword.addAttribute(NSAttributedString.Key.foregroundColor, value: charColor, range: NSRange(location: index, length: 1)) }