Introduce color provider to encapsulate check for iOS 13 availability

This commit is contained in:
Danny Moesch 2019-10-01 22:36:22 +02:00
parent e0c32003e3
commit 51c9510f3d
12 changed files with 80 additions and 41 deletions

View file

@ -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

View file

@ -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]

View file

@ -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
}

View file

@ -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
}

View file

@ -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!

View file

@ -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
}
}