From 1c86d4e17e0113c9e651d8190387c06a0a34128b Mon Sep 17 00:00:00 2001 From: Nikita Ermolenko Date: Thu, 30 Nov 2017 15:59:40 +0600 Subject: [PATCH 1/3] Fix some swiftlint warnings --- Sources/MakerHelper.swift | 34 +++++++++++++++++----------------- Sources/UIView+Installer.swift | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Sources/MakerHelper.swift b/Sources/MakerHelper.swift index be1b41b..3c08df2 100644 --- a/Sources/MakerHelper.swift +++ b/Sources/MakerHelper.swift @@ -45,21 +45,21 @@ extension Maker { } switch type { - case .top: return convertedRect.minY - case .bottom: return convertedRect.maxY - case .centerY: return view.contains(self.view) ? convertedRect.height / 2 : convertedRect.midY - case .centerX: return view.contains(self.view) ? convertedRect.width / 2 : convertedRect.midX - case .right: return convertedRect.maxX - case .left: return convertedRect.minX - default: return 0 + case .top: return convertedRect.minY + case .bottom: return convertedRect.maxY + case .centerY: return view.contains(self.view) ? convertedRect.height / 2 : convertedRect.midY + case .centerX: return view.contains(self.view) ? convertedRect.width / 2 : convertedRect.midX + case .right: return convertedRect.maxX + case .left: return convertedRect.minX + default: return 0 } } func relationSize(view: UIView, for type: RelationType) -> CGFloat { switch type { - case .width: return view.bounds.width - case .height: return view.bounds.height - default: return 0 + case .width: return view.bounds.width + case .height: return view.bounds.height + default: return 0 } } } @@ -69,13 +69,13 @@ extension CGRect { mutating func setValue(_ value: CGFloat, for type: RelationType) { var frame = self switch type { - case .width: frame.size.width = value - case .height: frame.size.height = value - case .left: frame.origin.x = value - case .top: frame.origin.y = value - case .centerX: frame.origin.x = value - width/2 - case .centerY: frame.origin.y = value - height/2 - default: break + case .width: frame.size.width = value + case .height: frame.size.height = value + case .left: frame.origin.x = value + case .top: frame.origin.y = value + case .centerX: frame.origin.x = value - width/2 + case .centerY: frame.origin.y = value - height/2 + default: break } self = frame } diff --git a/Sources/UIView+Installer.swift b/Sources/UIView+Installer.swift index fcaddde..827c888 100644 --- a/Sources/UIView+Installer.swift +++ b/Sources/UIView+Installer.swift @@ -11,8 +11,8 @@ import ObjectiveC public let DEFAULT_STATE = "DEFAULT STATE" -fileprivate var stateTypeAssociationKey: UInt8 = 0 -fileprivate var nxStateTypeAssociationKey: UInt8 = 1 +private var stateTypeAssociationKey: UInt8 = 0 +private var nxStateTypeAssociationKey: UInt8 = 1 public extension UIView { From 4da92b4d44123187fb0233a2c1f87a39f37fb799 Mon Sep 17 00:00:00 2001 From: Nikita Ermolenko Date: Thu, 30 Nov 2017 17:07:47 +0600 Subject: [PATCH 2/3] Capture relation types beforehand for centerX and centerY (between) --- Sources/Maker.swift | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Sources/Maker.swift b/Sources/Maker.swift index 7b7ffc5..1d7e407 100644 --- a/Sources/Maker.swift +++ b/Sources/Maker.swift @@ -699,9 +699,15 @@ public final class Maker { @discardableResult public func centerY(between relationView1: RelationView, _ relationView2: RelationView) -> Maker { + let view1 = relationView1.view + let view2 = relationView2.view + + let relationType1 = relationView1.relationType + let relationType2 = relationView2.relationType + let handler = { [unowned self] in - let y1 = self.convertedValue(for: relationView1.relationType, with: relationView1.view) - let y2 = self.convertedValue(for: relationView2.relationType, with: relationView2.view) + let y1 = self.convertedValue(for: relationType1, with: view1) + let y2 = self.convertedValue(for: relationType2, with: view2) let topY = y1 < y2 ? y1 : y2 let bottomY = y1 >= y2 ? y1 : y2 @@ -778,9 +784,15 @@ public final class Maker { @discardableResult public func centerX(between relationView1: RelationView, _ relationView2: RelationView) -> Maker { + let view1 = relationView1.view + let view2 = relationView2.view + + let relationType1 = relationView1.relationType + let relationType2 = relationView2.relationType + let handler = { [unowned self] in - let x1 = self.convertedValue(for: relationView1.relationType, with: relationView1.view) - let x2 = self.convertedValue(for: relationView2.relationType, with: relationView2.view) + let x1 = self.convertedValue(for: relationType1, with: view1) + let x2 = self.convertedValue(for: relationType2, with: view2) let rightX = x1 < x2 ? x1 : x2 let leftX = x1 >= x2 ? x1 : x2 From 445a0241c49afda329c51ab6cc1ed56a0b93dc65 Mon Sep 17 00:00:00 2001 From: Nikita Ermolenko Date: Thu, 30 Nov 2017 17:09:39 +0600 Subject: [PATCH 3/3] Change podspec version -> 2.4.1 --- Framezilla.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framezilla.podspec b/Framezilla.podspec index 79ac852..46bcb93 100644 --- a/Framezilla.podspec +++ b/Framezilla.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "Framezilla" - spec.version = "2.4.0" + spec.version = "2.4.1" spec.summary = "Comfortable syntax for working with frames." spec.homepage = "https://github.com/Otbivnoe/Framezilla"