Skip to content

Commit

Permalink
Corrected Swiflint warnings
Browse files Browse the repository at this point in the history
This commit is to try to fix the build process of Travis.
  • Loading branch information
PedroAnibarro1 committed Nov 17, 2017
1 parent afbf9f4 commit 9796090
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ShowcaseExampleViewController: UIViewController, UITextFieldDelegate {

applySkyscannerThemeWithIcon(textField: arrivalCityField)
arrivalCityField.iconWidth = 12.5 // Control the size of the image

if isLTRLanguage {
arrivalCityField.iconRotationDegrees = 90
} else { // In RTL languages the plane should point to the other side
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SettingTextsViewController: UIViewController {
break
}
}

@IBAction func enabledChanged(_ sender: Any) {
if let textField = textField {
textField.isEnabled = !textField.isEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CustomizingColorsViewController: UIViewController {

@IBOutlet var addErrorButton: UIButton?
@IBOutlet var enableButton: UIButton?

// MARK: - view lifecycle

override func viewDidLoad() {
Expand Down Expand Up @@ -108,7 +108,7 @@ class CustomizingColorsViewController: UIViewController {
}
}
}

@IBAction func resignTextField() {
textField?.resignFirstResponder()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ
// then
XCTAssertEqual(floatingLabelTextField.titleLabel.textColor, self.customColor)
}

func test_whenSettingDisabledColor_withTextFieldBeingEnabled_thenTitleLabelTextColorIsNotChangedToThisColor() {
// given
floatingLabelTextField.isEnabled = true

// when
floatingLabelTextField.disabledColor = self.customColor

// then
XCTAssertNotEqual(floatingLabelTextField.titleLabel.textColor, self.customColor)
}
Expand All @@ -164,10 +164,10 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ
floatingLabelTextField.placeholder = "test"
var fullRange =
NSRange(location: 0, length: floatingLabelTextField.placeholder!.characters.count)

// when
floatingLabelTextField.disabledColor = self.customColor

// then
#if swift(>=4.0)
XCTAssertNotEqual(
Expand All @@ -189,25 +189,25 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ
func test_whenSettingDisabledColor_withTextFieldBeingEnabled_thenLineViewBackgroundColorIsNotChangedToThisColor() {
// given
floatingLabelTextField.isEnabled = true

// when
floatingLabelTextField.disabledColor = self.customColor

// then
XCTAssertNotEqual(floatingLabelTextField.lineView.backgroundColor, self.customColor)
}

func test_whenSettingDisabledColor_withTextFieldBeingDisabled_thenTitleLabelTextColorIsChangedToThisColor() {
// given
floatingLabelTextField.isEnabled = false

// when
floatingLabelTextField.disabledColor = self.customColor

// then
XCTAssertEqual(floatingLabelTextField.titleLabel.textColor, self.customColor)
}

func test_whenSettingDisabledColor_withTextFieldBeingDisabled_thenPlaceholderColorIsChangedToThisColor() {
// given
floatingLabelTextField.isEnabled = false
Expand All @@ -217,7 +217,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ

// when
floatingLabelTextField.disabledColor = self.customColor

// then
#if swift(>=4.0)
XCTAssertEqual(
Expand All @@ -235,18 +235,18 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ
)
#endif
}

func test_whenSettingDisabledColor_withTextFieldBeingDisabled_thenLineViewBackgroundColorIsChangedToThisColor() {
// given
floatingLabelTextField.isEnabled = false

// when
floatingLabelTextField.disabledColor = self.customColor

// then
XCTAssertEqual(floatingLabelTextField.lineView.backgroundColor, self.customColor)
}

// MARK: - fonts

func test_whenSettingPlaceholderFont_thenAttributedPlaceholderTextIsSet_withFont() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class SkyFloatingLabelTextFieldWithIconTests: XCTestCase {
// then
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconLabel.text, "customIconText")
}

func test_whenSettingIconImage_thenImageAppliedToIconImageView() {
// when
floatingLabelTextFieldWithIcon.iconImage = #imageLiteral(resourceName: "SkyScannerIcon")

// then
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconImageView.image, #imageLiteral(resourceName: "SkyScannerIcon"))
}
Expand All @@ -65,16 +65,16 @@ class SkyFloatingLabelTextFieldWithIconTests: XCTestCase {
// then
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconLabel.textColor, customColor)
}

func test_whenSettingDisabledColor_withTextFieldBeingDisabled_thenColorAppliedToIconLabel() {
// when
floatingLabelTextFieldWithIcon.disabledColor = customColor
floatingLabelTextFieldWithIcon.isEnabled = false

// then
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconLabel.textColor, customColor)
}

func test_whenSettingSelectedIconColor_withTextFieldBeingSelected_thenColorAppliedToIconLabel() {
// when
floatingLabelTextFieldWithIcon.selectedIconColor = customColor
Expand Down Expand Up @@ -107,11 +107,11 @@ class SkyFloatingLabelTextFieldWithIconTests: XCTestCase {
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconLabel.transform.tx, expectedTransform.tx)
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconLabel.transform.ty, expectedTransform.ty)
}

func test_whenSettingIconRotationDegrees_thenRotationAppliedToIconImageView() {
// when
floatingLabelTextFieldWithIcon.iconRotationDegrees = 45

// then
let expectedTransform = CGAffineTransform(rotationAngle: CGFloat(45.0 * .pi / 180.0))
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconImageView.transform.a, expectedTransform.a)
Expand All @@ -137,68 +137,68 @@ class SkyFloatingLabelTextFieldWithIconTests: XCTestCase {
// then
XCTAssertNotNil(floatingLabelTextFieldWithIcon.iconLabel)
}

func test_whenInitializingWithCoder_thenIconImageViewIsCreated() {
// given
let data = NSMutableData()
let archiver = NSKeyedArchiver(forWritingWith: data)
archiver.finishEncoding()
let coder = NSKeyedUnarchiver(forReadingWith: data as Data)

// when
floatingLabelTextFieldWithIcon = SkyFloatingLabelTextFieldWithIcon(coder: coder)

// then
XCTAssertNotNil(floatingLabelTextFieldWithIcon.iconImageView)
}

func test_whenInitializingWithCoder_thenSelectedIconTypeIsPresented() {
// given
let data = NSMutableData()
let archiver = NSKeyedArchiver(forWritingWith: data)
archiver.finishEncoding()
let coder = NSKeyedUnarchiver(forReadingWith: data as Data)

// when
floatingLabelTextFieldWithIcon = SkyFloatingLabelTextFieldWithIcon(coder: coder)

// then
let iconLabelIsHidden = floatingLabelTextFieldWithIcon.iconLabel.isHidden
let iconImageViewIsHidden = floatingLabelTextFieldWithIcon.iconImageView.isHidden

switch floatingLabelTextFieldWithIcon.iconType {
case .font:
XCTAssertTrue(!iconLabelIsHidden && iconImageViewIsHidden)
case .image:
XCTAssertTrue(iconLabelIsHidden && !iconImageViewIsHidden)
}
}

func test_whenInitializingWithIconTypeAsFont_thenIconLabelIsPresented() {
// given
let frame = CGRect(x: 0, y: 0, width: 200, height: 50)

// when
floatingLabelTextFieldWithIcon = SkyFloatingLabelTextFieldWithIcon(frame: frame, iconType: .font)

// then
let iconLabelIsHidden = floatingLabelTextFieldWithIcon.iconLabel.isHidden
let iconImageViewIsHidden = floatingLabelTextFieldWithIcon.iconImageView.isHidden

XCTAssertTrue(!iconLabelIsHidden && iconImageViewIsHidden)
}

func test_whenInitializingWithIconTypeAsImage_thenIconImageViewIsPresented() {
// given
let frame = CGRect(x: 0, y: 0, width: 200, height: 50)

// when
floatingLabelTextFieldWithIcon = SkyFloatingLabelTextFieldWithIcon(frame: frame, iconType: .image)

// then
let iconLabelIsHidden = floatingLabelTextFieldWithIcon.iconLabel.isHidden
let iconImageViewIsHidden = floatingLabelTextFieldWithIcon.iconImageView.isHidden

XCTAssertTrue(iconLabelIsHidden && !iconImageViewIsHidden)
}

Expand Down Expand Up @@ -308,15 +308,15 @@ class SkyFloatingLabelTextFieldWithIconTests: XCTestCase {
// then
XCTAssertNotEqual(floatingLabelTextFieldWithIcon.iconLabel.frame.height, 0)
}

func test_whenInvokingLayoutSubviews_thenUpdatesIconImageViewFrame() {
// given
floatingLabelTextFieldWithIcon.iconImageView.frame = CGRect(x: 0, y: 0, width: 0, height: 0)
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconImageView.frame.height, 0)

// when
floatingLabelTextFieldWithIcon.layoutSubviews()

// then
XCTAssertNotEqual(floatingLabelTextFieldWithIcon.iconLabel.frame.height, 0)
}
Expand All @@ -333,16 +333,16 @@ class SkyFloatingLabelTextFieldWithIconTests: XCTestCase {
// then
XCTAssertNotEqual(floatingLabelTextFieldWithIcon.iconLabel.frame.height, 0)
}

func test_whenInvokingLayoutSubviews_withNonRTLLanguage_thenUpdatesIconImageViewFrame() {
// given
floatingLabelTextFieldWithIcon.iconImageView.frame = CGRect(x: 0, y: 0, width: 0, height: 0)
XCTAssertEqual(floatingLabelTextFieldWithIcon.iconImageView.frame.height, 0)
floatingLabelTextFieldWithIcon.isLTRLanguage = false

// when
floatingLabelTextFieldWithIcon.layoutSubviews()

// then
XCTAssertNotEqual(floatingLabelTextFieldWithIcon.iconImageView.frame.height, 0)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SkyFloatingLabelTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
updateColors()
}
}

/// A UIColor value that determines the color used for the title label and line when text field is disabled
@IBInspectable dynamic open var disabledColor: UIColor = UIColor(white: 0.88, alpha: 1.0) {
didSet {
Expand Down Expand Up @@ -376,7 +376,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
updatePlaceholder()
}
}

// MARK: - View updates

fileprivate func updateControl(_ animated: Bool = false) {
Expand Down
Loading

0 comments on commit 9796090

Please sign in to comment.