diff --git a/.swiftlint.yml b/.swiftlint.yml index 4fc076e..257d2ac 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,8 +1,19 @@ disabled_rules: opt_in_rules: + - closure_end_indentation + - closure_spacing + - conditional_returns_on_newline + - empty_count + - explicit_type_interface + - first_where + - implicit_return + - let_var_whitespace + - multiline_parameters + - number_separator + - operator_usage_whitespace included: - - ../Sources - - . - - Package.swift + - ../Sources + - . + - Package.swift excluded: diff --git a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/AppDelegate.swift b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/AppDelegate.swift index dbc5d29..c2fa485 100644 --- a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/AppDelegate.swift +++ b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/AppDelegate.swift @@ -44,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { styles.placeholderFont = .systemFont(ofSize: 14, weight: 0.1) // Line - styles.lineHeight = 2 + styles.lineHeight = 2 styles.lineColor = .brown // Selected line @@ -66,11 +66,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { iconStyles.selectedIconColor = .orange // Icon font - iconStyles.iconFont = UIFont(name: "FontAwesome", size: 15) + iconStyles.iconFont = UIFont(name: "FontAwesome", size: 15) // Icon margins - iconStyles.iconMarginLeft = 5 - iconStyles.iconMarginBottom = 5 + iconStyles.iconMarginLeft = 5 + iconStyles.iconMarginBottom = 5 } return true diff --git a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/Example0/ShowcaseExampleViewController.swift b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/Example0/ShowcaseExampleViewController.swift index 2e606e2..5735388 100644 --- a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/Example0/ShowcaseExampleViewController.swift +++ b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/Example0/ShowcaseExampleViewController.swift @@ -24,11 +24,11 @@ class ShowcaseExampleViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var emailField: SkyFloatingLabelTextField! @IBOutlet weak var submitButton: UIButton! - var textFields: [SkyFloatingLabelTextField]! + var textFields: [SkyFloatingLabelTextField] = [] - let lightGreyColor = UIColor(red: 197/255, green: 205/255, blue: 205/255, alpha: 1.0) - let darkGreyColor = UIColor(red: 52/255, green: 42/255, blue: 61/255, alpha: 1.0) - let overcastBlueColor = UIColor(red: 0, green: 187/255, blue: 204/255, alpha: 1.0) + let lightGreyColor: UIColor = UIColor(red: 197 / 255, green: 205 / 255, blue: 205 / 255, alpha: 1.0) + let darkGreyColor: UIColor = UIColor(red: 52 / 255, green: 42 / 255, blue: 61 / 255, alpha: 1.0) + let overcastBlueColor: UIColor = UIColor(red: 0, green: 187 / 255, blue: 204 / 255, alpha: 1.0) override func viewDidLoad() { super.viewDidLoad() @@ -189,9 +189,9 @@ class ShowcaseExampleViewController: UIViewController, UITextFieldDelegate { // MARK: - Validating the fields when "submit" is pressed - var isSubmitButtonPressed = false + var isSubmitButtonPressed: Bool = false - var showingTitleInProgress = false + var showingTitleInProgress: Bool = false @IBAction func submitButtonDown(_ sender: AnyObject) { self.isSubmitButtonPressed = true @@ -261,7 +261,7 @@ class ShowcaseExampleViewController: UIViewController, UITextFieldDelegate { return } - if email.characters.count == 0 { + if email.characters.isEmpty { emailField.errorMessage = nil } else if !validateEmail(email) { emailField.errorMessage = NSLocalizedString( diff --git a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/Example3/SubclassingViewController.swift b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/Example3/SubclassingViewController.swift index 4c6ca8c..cd0448a 100644 --- a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/Example3/SubclassingViewController.swift +++ b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldExample/Example3/SubclassingViewController.swift @@ -21,7 +21,7 @@ class SubclassingViewController: UIViewController { super.viewDidLoad() // SkyFloatingLabelTextField will inherit it's superview's `tintColor`. - self.view.tintColor = UIColor(red: 0.0, green: 221.0/256.0, blue: 238.0/256.0, alpha: 1.0) + self.view.tintColor = UIColor(red: 0.0, green: 221.0 / 256.0, blue: 238.0 / 256.0, alpha: 1.0) textField?.placeholder = NSLocalizedString("Placeholder", tableName: "SkyFloatingLabelTextField", comment: "") } diff --git a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldAppearanceTests.swift b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldAppearanceTests.swift index 4c2b727..6c2378b 100644 --- a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldAppearanceTests.swift +++ b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldAppearanceTests.swift @@ -22,37 +22,37 @@ class SkyFloatingLabelTextFieldAppearanceTests: XCTestCase { let styles = SkyFloatingLabelTextField.appearance() // Text-, placeholder- and tintcolor - styles.textColor = UIColor.brown - styles.tintColor = UIColor.brown - styles.placeholderColor = UIColor.darkGray + styles.textColor = UIColor.brown + styles.tintColor = UIColor.brown + styles.placeholderColor = UIColor.darkGray styles.selectedTitleColor = UIColor.orange - styles.errorColor = UIColor.purple + styles.errorColor = UIColor.purple // Fonts - styles.font = UIFont(name: "HelveticaNeue-Bold", size: 14)! - styles.placeholderFont = UIFont(name: "HelveticaNeue-Medium", size: 14)! + styles.font = UIFont(name: "HelveticaNeue-Bold", size: 14)! + styles.placeholderFont = UIFont(name: "HelveticaNeue-Medium", size: 14)! // Line - styles.lineHeight = 2 - styles.lineColor = UIColor.brown + styles.lineHeight = 2 + styles.lineColor = UIColor.brown // Selected line styles.selectedLineHeight = 3 - styles.selectedLineColor = UIColor.orange + styles.selectedLineColor = UIColor.orange // Apply icon styles let iconStyles = SkyFloatingLabelTextFieldWithIcon.appearance() // Icon colors - iconStyles.iconColor = UIColor.brown - iconStyles.selectedIconColor = UIColor.orange + iconStyles.iconColor = UIColor.brown + iconStyles.selectedIconColor = UIColor.orange // Icon font - iconStyles.iconFont = UIFont(name: "FontAwesome", size: 15) + iconStyles.iconFont = UIFont(name: "FontAwesome", size: 15) // Icon margins - iconStyles.iconMarginLeft = 5 - iconStyles.iconMarginBottom = 5 + iconStyles.iconMarginLeft = 5 + iconStyles.iconMarginBottom = 5 } override func tearDown() { diff --git a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldTests.swift b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldTests.swift index ac998fd..43a6087 100644 --- a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldTests.swift +++ b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldTests.swift @@ -18,8 +18,8 @@ import XCTest class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this type_body_length var floatingLabelTextField: SkyFloatingLabelTextField! - let customColor = UIColor(red: 125/255, green: 120/255, blue: 50/255, alpha: 1.0) - let textFieldDelegateMock = TextFieldDelegateMock() + let customColor: UIColor = UIColor(red: 125 / 255, green: 120 / 255, blue: 50 / 255, alpha: 1.0) + let textFieldDelegateMock: TextFieldDelegateMock = TextFieldDelegateMock() override func setUp() { super.setUp() @@ -720,20 +720,20 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ } class TextFieldDelegateMock: NSObject, UITextFieldDelegate { - var textFieldShouldBeginEditing = false - var textFieldShouldEndEditing = false - var textFieldShouldReturn = false - var textFieldShouldClear = false - var shouldChangeCharactersInRange = false - - var textFieldChangedInvoked = false - var textFieldShouldBeginEditingInvoked = false - var textFieldShouldEndEditingInvoked = false - var textFieldDidBeginEditingInvoked = false - var textFieldDidEndEditingInvoked = false - var textFieldShouldReturnInvoked = false - var textFieldShouldClearInvoked = false - var shouldChangeCharactersInRangeInvoked = false + var textFieldShouldBeginEditing: Bool = false + var textFieldShouldEndEditing: Bool = false + var textFieldShouldReturn: Bool = false + var textFieldShouldClear: Bool = false + var shouldChangeCharactersInRange: Bool = false + + var textFieldChangedInvoked: Bool = false + var textFieldShouldBeginEditingInvoked: Bool = false + var textFieldShouldEndEditingInvoked: Bool = false + var textFieldDidBeginEditingInvoked: Bool = false + var textFieldDidEndEditingInvoked: Bool = false + var textFieldShouldReturnInvoked: Bool = false + var textFieldShouldClearInvoked: Bool = false + var shouldChangeCharactersInRangeInvoked: Bool = false func textFieldDidBeginEditing(_ textField: UITextField) { textFieldDidBeginEditingInvoked = true @@ -778,7 +778,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ } class SkyFloatingLabelTextFieldSpy: SkyFloatingLabelTextField { - var updateColorsInvoked = false + var updateColorsInvoked: Bool = false override func updateColors() { updateColorsInvoked = true diff --git a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldWithIconTests.swift b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldWithIconTests.swift index 0b14bb6..3eeb4d0 100644 --- a/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldWithIconTests.swift +++ b/SkyFloatingLabelTextField/SkyFloatingLabelTextFieldTests/SkyFloatingLabelTextFieldWithIconTests.swift @@ -12,7 +12,7 @@ import XCTest class SkyFloatingLabelTextFieldWithIconTests: XCTestCase { var floatingLabelTextFieldWithIcon: SkyFloatingLabelTextFieldWithIcon! - let customColor = UIColor(red: 125/255, green: 120/255, blue: 50/255, alpha: 1.0) + let customColor: UIColor = UIColor(red: 125 / 255, green: 120 / 255, blue: 50 / 255, alpha: 1.0) override func setUp() { super.setUp() diff --git a/Sources/SkyFloatingLabelTextField.swift b/Sources/SkyFloatingLabelTextField.swift index 3140da8..10e4504 100644 --- a/Sources/SkyFloatingLabelTextField.swift +++ b/Sources/SkyFloatingLabelTextField.swift @@ -20,7 +20,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty A Boolean value that determines if the language displayed is LTR. Default value set automatically from the application language settings. */ - open var isLTRLanguage = UIApplication.shared.userInterfaceLayoutDirection == .leftToRight { + open var isLTRLanguage: Bool = UIApplication.shared.userInterfaceLayoutDirection == .leftToRight { didSet { updateTextAligment() } @@ -182,7 +182,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty } /// The backing property for the highlighted property - fileprivate var _highlighted = false + fileprivate var _highlighted: Bool = false /** A Boolean value that determines whether the receiver is highlighted. @@ -345,7 +345,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty */ @discardableResult override open func resignFirstResponder() -> Bool { - let result = super.resignFirstResponder() + let result = super.resignFirstResponder() updateControl(true) return result } @@ -425,7 +425,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty updateTitleVisibility(animated) } - fileprivate var _titleVisible = false + fileprivate var _titleVisible: Bool = false /* * Set this value to make the title visible