Migrate to Swift 5.0

This commit is contained in:
Danny Moesch 2019-05-01 17:49:27 +02:00
parent e06413b348
commit f9c19b3ca4
26 changed files with 143 additions and 152 deletions

View file

@ -47,8 +47,8 @@ open class PasscodeLockPresenter {
}
fileprivate func moveWindowsToFront(windowLevel: CGFloat?) {
let windowLevel = windowLevel ?? UIWindowLevelNormal
let maxWinLevel = max(windowLevel, UIWindowLevelNormal)
passcodeLockWindow?.windowLevel = maxWinLevel + 1
let windowLevel = windowLevel ?? UIWindow.Level.normal.rawValue
let maxWinLevel = max(windowLevel, UIWindow.Level.normal.rawValue)
passcodeLockWindow?.windowLevel = UIWindow.Level(rawValue: maxWinLevel + 1)
}
}

View file

@ -47,12 +47,12 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
self.passcodeWrongAttemptsLabel = passcodeWrongAttemptsLabel
let passcodeTextField = UITextField(frame: CGRect(x: 0, y: 0, width: 300, height: 40))
passcodeTextField.borderStyle = UITextBorderStyle.roundedRect
passcodeTextField.borderStyle = UITextField.BorderStyle.roundedRect
passcodeTextField.placeholder = "Passcode".localize()
passcodeTextField.isSecureTextEntry = true
passcodeTextField.clearButtonMode = UITextFieldViewMode.whileEditing
passcodeTextField.clearButtonMode = UITextField.ViewMode.whileEditing
passcodeTextField.delegate = self
passcodeTextField.addTarget(self, action: #selector(self.passcodeTextFieldDidChange(_:)), for: UIControlEvents.editingChanged)
passcodeTextField.addTarget(self, action: #selector(self.passcodeTextFieldDidChange(_:)), for: UIControl.Event.editingChanged)
self.view.backgroundColor = UIColor.white
passcodeTextField.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(passcodeTextField)
@ -88,7 +88,7 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
cancelButton.addTarget(self, action: #selector(passcodeLockDidCancel), for: .touchUpInside)
cancelButton.isHidden = !self.isCancellable
cancelButton.translatesAutoresizingMaskIntoConstraints = false
cancelButton.contentHorizontalAlignment = UIControlContentHorizontalAlignment.left
cancelButton.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.left
self.view.addSubview(cancelButton)
self.cancelButton = cancelButton

View file

@ -13,7 +13,7 @@ import KeychainAccess
public class Utils {
public static func getPasswordFromKeychain(name: String) -> String? {
let keychain = Keychain(service: Globals.bundleIdentifier, accessGroup: Globals.groupIdentifier)
return (try? keychain.getString(name)) ?? nil
return try? keychain.getString(name)
}
public static func addPasswordToKeychain(name: String, password: String?) {
@ -49,14 +49,14 @@ public class Utils {
} else {
charColor = Globals.letterColor
}
attributedPassword.addAttribute(NSAttributedStringKey.foregroundColor, value: charColor, range: NSRange(location: index, length: 1))
attributedPassword.addAttribute(NSAttributedString.Key.foregroundColor, value: charColor, range: NSRange(location: index, length: 1))
}
return attributedPassword
}
public static func alert(title: String, message: String, controller: UIViewController, handler: ((UIAlertAction) -> Void)? = nil, completion: (() -> Void)? = nil) {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: handler))
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: handler))
controller.present(alert, animated: true, completion: completion)
}
}

View file

@ -109,7 +109,7 @@ public class PasswordStore {
}
public var numberOfLocalCommits: Int? {
return (try? getLocalCommits())?.flatMap { $0.count }
return (try? getLocalCommits())?.count
}
public var lastSyncedTime: Date? {