Skip to content

Commit

Permalink
Merge pull request #29 from emirhanbattalbas/feature/textfield
Browse files Browse the repository at this point in the history
improvements have been made
  • Loading branch information
aslanmehmetsalih authored May 3, 2021
2 parents 9e3db13 + a7e752b commit 42233cd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Example/Tests/UITextFieldBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,31 @@ class UITextFieldBuilderTests: XCTestCase {

XCTAssertEqual(textField.layer.borderColor, borderColor)
}

func testBackgroundColor() {
let backgroundColor = UIColor.white
let textField = UITextFieldBuilder()
.backgroundColor(backgroundColor)
.build()

XCTAssertEqual(textField.backgroundColor, backgroundColor)
}

func testSecureTextEntry() {
let isSecureTextEntry = true
let textField = UITextFieldBuilder()
.isSecureTextEntry(isSecureTextEntry)
.build()

XCTAssertEqual(textField.isSecureTextEntry, isSecureTextEntry)
}

func testAutocapitalizationType() {
let autocapitalizationType: UITextAutocapitalizationType = .none
let textField = UITextFieldBuilder()
.autocapitalizationType(autocapitalizationType)
.build()

XCTAssertEqual(textField.autocapitalizationType, autocapitalizationType)
}
}
18 changes: 18 additions & 0 deletions MobilliumBuilders/Classes/UITextFieldBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ public class UITextFieldBuilder<T: UITextField> {
return self
}

@discardableResult
public func backgroundColor(_ backgroundColor: UIColor) -> Self {
self.textField.backgroundColor = backgroundColor
return self
}

@discardableResult
public func isSecureTextEntry(_ isSecureTextEntry: Bool) -> Self {
self.textField.isSecureTextEntry = isSecureTextEntry
return self
}

@discardableResult
public func autocapitalizationType(_ autocapitalizationType: UITextAutocapitalizationType) -> Self {
self.textField.autocapitalizationType = autocapitalizationType
return self
}

public func build() -> T {
return textField
}
Expand Down

0 comments on commit 42233cd

Please sign in to comment.