Skip to content

Commit

Permalink
Merge pull request #38 from mobillium/feature/AddTranslatesAutoresizi…
Browse files Browse the repository at this point in the history
…ngMaskIntoConstraints

Add translatesAutoresizingMaskIntoConstraints func
  • Loading branch information
aslanmehmetsalih authored Aug 23, 2023
2 parents c1a4fe5 + 16c9d7d commit a7b9823
Show file tree
Hide file tree
Showing 22 changed files with 148 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Example/Tests/UIButtonBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ class UIButtonBuilderTests: XCTestCase {

XCTAssertEqual(button.titleLabel?.font, font)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let button = UIButtonBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(button.translatesAutoresizingMaskIntoConstraints)
}
}

// MARK: - Custom UIButton
Expand Down
8 changes: 8 additions & 0 deletions Example/Tests/UICollectionViewBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,13 @@ class UICollectionViewBuilderTests: XCTestCase {

XCTAssertEqual(tintColor, collectionView.tintColor)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let collectionView = UICollectionViewBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(collectionView.translatesAutoresizingMaskIntoConstraints)
}

}
8 changes: 8 additions & 0 deletions Example/Tests/UIImageViewBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,12 @@ class UIImageViewBuilderTests: XCTestCase {
XCTAssertEqual(heightConstraint.constant, size.height)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let imageView = UIImageViewBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(imageView.translatesAutoresizingMaskIntoConstraints)
}

}
8 changes: 8 additions & 0 deletions Example/Tests/UILabelBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,12 @@ class UILabelBuilderTests: XCTestCase {
XCTAssertEqual(label.accessibilityIdentifier, accessibilityIdentifier)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let label = UILabelBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(label.translatesAutoresizingMaskIntoConstraints)
}

}
8 changes: 8 additions & 0 deletions Example/Tests/UIScrollViewBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,12 @@ class UIScrollViewBuilderTests: XCTestCase {

XCTAssertEqual(scrollView.accessibilityIdentifier, accessibilityIdentifier)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let scrollView = UIScrollViewBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(scrollView.translatesAutoresizingMaskIntoConstraints)
}
}
8 changes: 8 additions & 0 deletions Example/Tests/UIStackViewBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@ class UIStackViewBuilderTests: XCTestCase {

XCTAssertTrue(stackView.clipsToBounds)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let stackView = UIStackViewBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(stackView.translatesAutoresizingMaskIntoConstraints)
}
}
8 changes: 8 additions & 0 deletions Example/Tests/UITableViewBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,12 @@ class UITableViewBuilderTests: XCTestCase {
}
XCTAssertTrue(isContainsIdentifier)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let tableView = UITableViewBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(tableView.translatesAutoresizingMaskIntoConstraints)
}
}
8 changes: 8 additions & 0 deletions Example/Tests/UITextFieldBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,12 @@ class UITextFieldBuilderTests: XCTestCase {

XCTAssertEqual(textField.autocapitalizationType, autocapitalizationType)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let textField = UITextFieldBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(textField.translatesAutoresizingMaskIntoConstraints)
}
}
7 changes: 7 additions & 0 deletions Example/Tests/UITextViewBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,11 @@ class UITextViewBuilderTests: XCTestCase {
XCTAssertEqual(textView.accessibilityIdentifier, accessibilityIdentifier)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let textView = UITextViewBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(textView.translatesAutoresizingMaskIntoConstraints)
}
}
8 changes: 8 additions & 0 deletions Example/Tests/UIViewBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,12 @@ class UIViewBuilderTests: XCTestCase {
XCTAssertEqual(view.accessibilityIdentifier, accessibilityIdentifier)
}

func testTranslatesAutoresizingMaskIntoConstraints() {
let view = UIViewBuilder()
.translatesAutoresizingMaskIntoConstraints(true)
.build()

XCTAssertTrue(view.translatesAutoresizingMaskIntoConstraints)
}

}
2 changes: 1 addition & 1 deletion MobilliumBuilders.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MobilliumBuilders'
s.version = '1.5.0'
s.version = '1.6.0'
s.summary = 'Builders classes'

s.homepage = 'https://github.com/mobillium/MobilliumBuilders'
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UIButtonBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ public class UIButtonBuilder<T: UIButton> {
return self
}

@discardableResult
public func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool = false) -> Self {
self.button.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

public func build() -> T {
return button
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class UICollectionViewBuilder<T: UICollectionView> {
self.collectionView.accessibilityIdentifier = accessibilityIdentifier
return self
}

@discardableResult
public func registerCell<C: UICollectionViewCell>(_ cellType: C.Type, reuseIdentifier: String) -> Self {
self.collectionView.register(cellType, forCellWithReuseIdentifier: reuseIdentifier)
Expand Down Expand Up @@ -171,6 +171,12 @@ public class UICollectionViewBuilder<T: UICollectionView> {
return self
}

@discardableResult
public func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool = false) -> Self {
self.collectionView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

public func build() -> T {
return collectionView
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UIImageViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public class UIImageViewBuilder<T: UIImageView> {
return self
}

@discardableResult
func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self {
self.imageView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

@discardableResult
public func size(_ size: CGSize) -> Self {
imageView.translatesAutoresizingMaskIntoConstraints = false
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UILabelBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ public class UILabelBuilder<T: UILabel> {
return self
}

@discardableResult
func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self {
self.label.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

public func build() -> T {
return label
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UIScrollViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ public class UIScrollViewBuilder<T: UIScrollView> {
return self
}

@discardableResult
func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self {
self.scrollView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

public func build() -> T {
return scrollView
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UISliderBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public class UISliderBuilder<T: UISlider> {
return self
}

@discardableResult
func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self {
self.slider.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

public func build() -> T {
return slider
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UIStackViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public class UIStackViewBuilder<T: UIStackView> {
return self
}

@discardableResult
func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self {
self.stackView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

public func build() -> T {
return stackView
}
Expand Down
8 changes: 7 additions & 1 deletion Sources/MobilliumBuilders/Classes/UITableViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ public class UITableViewBuilder<T: UITableView> {
self.tableView.register(cellType, forCellReuseIdentifier: reuseIdentifier)
return self
}


@discardableResult
func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self {
self.tableView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

public func build() -> T {
return tableView
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UITextFieldBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ public class UITextFieldBuilder<T: UITextField> {
return self
}

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

public func build() -> T {
return textField
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UITextViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public class UITextViewBuilder<T: UITextView> {
return self
}

@discardableResult
func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self {
self.textView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

public func build() -> T {
return textView
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/MobilliumBuilders/Classes/UIViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public class UIViewBuilder<T: UIView> {
return self
}

@discardableResult
func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self {
self.view.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
return self
}

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

0 comments on commit a7b9823

Please sign in to comment.