From 58309fd887c50bf68f2a1c49f102e4dd5f752341 Mon Sep 17 00:00:00 2001 From: Ali Ozan CILGA Date: Tue, 22 Aug 2023 11:26:25 +0300 Subject: [PATCH] Add translatesAutoresizingMaskIntoConstraints func --- MobilliumBuilders.podspec | 2 +- Sources/MobilliumBuilders/Classes/UIButtonBuilder.swift | 6 ++++++ .../Classes/UICollectionViewBuilder.swift | 8 +++++++- .../MobilliumBuilders/Classes/UIImageViewBuilder.swift | 6 ++++++ Sources/MobilliumBuilders/Classes/UILabelBuilder.swift | 6 ++++++ .../MobilliumBuilders/Classes/UIScrollViewBuilder.swift | 6 ++++++ Sources/MobilliumBuilders/Classes/UISliderBuilder.swift | 6 ++++++ .../MobilliumBuilders/Classes/UIStackViewBuilder.swift | 6 ++++++ .../MobilliumBuilders/Classes/UITableViewBuilder.swift | 8 +++++++- .../MobilliumBuilders/Classes/UITextFieldBuilder.swift | 6 ++++++ Sources/MobilliumBuilders/Classes/UITextViewBuilder.swift | 6 ++++++ Sources/MobilliumBuilders/Classes/UIViewBuilder.swift | 6 ++++++ 12 files changed, 69 insertions(+), 3 deletions(-) diff --git a/MobilliumBuilders.podspec b/MobilliumBuilders.podspec index 48c02aa..5035177 100644 --- a/MobilliumBuilders.podspec +++ b/MobilliumBuilders.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MobilliumBuilders' - s.version = '1.5.0' + s.version = '1.5.1' s.summary = 'Builders classes' s.homepage = 'https://github.com/mobillium/MobilliumBuilders' diff --git a/Sources/MobilliumBuilders/Classes/UIButtonBuilder.swift b/Sources/MobilliumBuilders/Classes/UIButtonBuilder.swift index 9fdf77e..3b2f901 100644 --- a/Sources/MobilliumBuilders/Classes/UIButtonBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UIButtonBuilder.swift @@ -165,6 +165,12 @@ public class UIButtonBuilder { return self } + @discardableResult + public func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool = false) -> Self { + self.button.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return button } diff --git a/Sources/MobilliumBuilders/Classes/UICollectionViewBuilder.swift b/Sources/MobilliumBuilders/Classes/UICollectionViewBuilder.swift index 015cd3d..1f55293 100644 --- a/Sources/MobilliumBuilders/Classes/UICollectionViewBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UICollectionViewBuilder.swift @@ -126,7 +126,7 @@ public class UICollectionViewBuilder { self.collectionView.accessibilityIdentifier = accessibilityIdentifier return self } - + @discardableResult public func registerCell(_ cellType: C.Type, reuseIdentifier: String) -> Self { self.collectionView.register(cellType, forCellWithReuseIdentifier: reuseIdentifier) @@ -171,6 +171,12 @@ public class UICollectionViewBuilder { return self } + @discardableResult + public func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool = false) -> Self { + self.collectionView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return collectionView } diff --git a/Sources/MobilliumBuilders/Classes/UIImageViewBuilder.swift b/Sources/MobilliumBuilders/Classes/UIImageViewBuilder.swift index b8db989..f740f02 100644 --- a/Sources/MobilliumBuilders/Classes/UIImageViewBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UIImageViewBuilder.swift @@ -115,6 +115,12 @@ public class UIImageViewBuilder { return self } + @discardableResult + func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self { + self.imageView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + @discardableResult public func size(_ size: CGSize) -> Self { imageView.translatesAutoresizingMaskIntoConstraints = false diff --git a/Sources/MobilliumBuilders/Classes/UILabelBuilder.swift b/Sources/MobilliumBuilders/Classes/UILabelBuilder.swift index 14f79e3..ff2a1f9 100644 --- a/Sources/MobilliumBuilders/Classes/UILabelBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UILabelBuilder.swift @@ -145,6 +145,12 @@ public class UILabelBuilder { return self } + @discardableResult + func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self { + self.label.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return label } diff --git a/Sources/MobilliumBuilders/Classes/UIScrollViewBuilder.swift b/Sources/MobilliumBuilders/Classes/UIScrollViewBuilder.swift index daa814e..9b440be 100644 --- a/Sources/MobilliumBuilders/Classes/UIScrollViewBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UIScrollViewBuilder.swift @@ -110,6 +110,12 @@ public class UIScrollViewBuilder { return self } + @discardableResult + func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self { + self.scrollView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return scrollView } diff --git a/Sources/MobilliumBuilders/Classes/UISliderBuilder.swift b/Sources/MobilliumBuilders/Classes/UISliderBuilder.swift index 2e3fcf5..f8c017e 100644 --- a/Sources/MobilliumBuilders/Classes/UISliderBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UISliderBuilder.swift @@ -97,6 +97,12 @@ public class UISliderBuilder { return self } + @discardableResult + func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self { + self.slider.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return slider } diff --git a/Sources/MobilliumBuilders/Classes/UIStackViewBuilder.swift b/Sources/MobilliumBuilders/Classes/UIStackViewBuilder.swift index f300622..85d5760 100644 --- a/Sources/MobilliumBuilders/Classes/UIStackViewBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UIStackViewBuilder.swift @@ -80,6 +80,12 @@ public class UIStackViewBuilder { return self } + @discardableResult + func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self { + self.stackView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return stackView } diff --git a/Sources/MobilliumBuilders/Classes/UITableViewBuilder.swift b/Sources/MobilliumBuilders/Classes/UITableViewBuilder.swift index a713ea8..c1649da 100644 --- a/Sources/MobilliumBuilders/Classes/UITableViewBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UITableViewBuilder.swift @@ -134,7 +134,13 @@ public class UITableViewBuilder { 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 } diff --git a/Sources/MobilliumBuilders/Classes/UITextFieldBuilder.swift b/Sources/MobilliumBuilders/Classes/UITextFieldBuilder.swift index d462d92..3e924db 100644 --- a/Sources/MobilliumBuilders/Classes/UITextFieldBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UITextFieldBuilder.swift @@ -147,6 +147,12 @@ public class UITextFieldBuilder { return self } + @discardableResult + func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self { + self.textField.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return textField } diff --git a/Sources/MobilliumBuilders/Classes/UITextViewBuilder.swift b/Sources/MobilliumBuilders/Classes/UITextViewBuilder.swift index b53f0d6..3cd1c90 100644 --- a/Sources/MobilliumBuilders/Classes/UITextViewBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UITextViewBuilder.swift @@ -133,6 +133,12 @@ public class UITextViewBuilder { return self } + @discardableResult + func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self { + self.textView.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return textView } diff --git a/Sources/MobilliumBuilders/Classes/UIViewBuilder.swift b/Sources/MobilliumBuilders/Classes/UIViewBuilder.swift index 53084c5..0c248ac 100644 --- a/Sources/MobilliumBuilders/Classes/UIViewBuilder.swift +++ b/Sources/MobilliumBuilders/Classes/UIViewBuilder.swift @@ -109,6 +109,12 @@ public class UIViewBuilder { return self } + @discardableResult + func translatesAutoresizingMaskIntoConstraints(_ translatesAutoresizingMaskIntoConstraints: Bool) -> Self { + self.view.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints + return self + } + public func build() -> T { return view }