From b85ff7f232a1299f19070819974d912f3b9c46b7 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Wed, 2 Mar 2016 23:51:22 +1300 Subject: [PATCH 1/7] Add issue template --- ISSUE_TEMPLATE.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ISSUE_TEMPLATE.md diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..15d85b7 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,26 @@ +### New Issue Checklist + +- [ ] I have looked at the [Documentation](http://snapkit.io/docs) +- [ ] I have read the [F.A.Q.](http://snapkit.io/faq) + +### Environment / Configuration + +##### Platform + +* [ ] OS X +* [ ] iOS + +##### Versions + +* Platform version is: `INSERT PLATFORM VERSION` +* SnapKit version is: `INSERT SNAPKIT VERSION` + +##### Integration + +- [ ] Carthage +- [ ] Cocoapods +- [ ] Manually / Other + +### Issue + +`INSERT ISSUE DESCRIPTION` \ No newline at end of file From 424b9f816018efeeaed661f1fd08c6d63f74769e Mon Sep 17 00:00:00 2001 From: Rohan Panchal Date: Mon, 21 Mar 2016 18:04:23 -0500 Subject: [PATCH 2/7] Added identifier field to ConstraintDescription --- Source/Constraint.swift | 6 +++++- Source/ConstraintDescription.swift | 11 ++++++++++- Tests/Tests.swift | 13 +++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Source/Constraint.swift b/Source/Constraint.swift index 5d57e02..60e0f2f 100644 --- a/Source/Constraint.swift +++ b/Source/Constraint.swift @@ -193,15 +193,18 @@ internal class ConcreteConstraint: Constraint { } } + private let identifier: String? + private var installInfo: ConcreteConstraintInstallInfo? = nil - internal init(fromItem: ConstraintItem, toItem: ConstraintItem, relation: ConstraintRelation, constant: Any, multiplier: Float, priority: Float) { + internal init(fromItem: ConstraintItem, toItem: ConstraintItem, relation: ConstraintRelation, constant: Any, multiplier: Float, priority: Float, identifier: String? = nil) { self.fromItem = fromItem self.toItem = toItem self.relation = relation self.constant = constant self.multiplier = multiplier self.priority = priority + self.identifier = identifier } internal func installOnView(updateExisting updateExisting: Bool = false, file: String? = nil, line: UInt? = nil) -> [LayoutConstraint] { @@ -269,6 +272,7 @@ internal class ConcreteConstraint: Constraint { attribute: layoutToAttribute, multiplier: CGFloat(self.multiplier), constant: layoutConstant) + layoutConstraint.identifier = self.identifier // set priority layoutConstraint.priority = self.priority diff --git a/Source/ConstraintDescription.swift b/Source/ConstraintDescription.swift index 2fc8d84..6368fc2 100644 --- a/Source/ConstraintDescription.swift +++ b/Source/ConstraintDescription.swift @@ -34,6 +34,8 @@ public protocol ConstraintDescriptionFinalizable: class { var constraint: Constraint { get } + func identifiedAs(identifier: String) -> ConstraintDescriptionFinalizable + } /** @@ -191,6 +193,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain internal var centerX: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterX) } internal var centerY: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterY) } internal var baseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Baseline) } + internal var identifier: String? @available(iOS 8.0, *) internal var firstBaseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.FirstBaseline) } @@ -487,11 +490,17 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain relation: self.relation!, constant: self.constant, multiplier: self.multiplier, - priority: self.priority) + priority: self.priority, + identifier: self.identifier) } return self.concreteConstraint! } + func identifiedAs(identifier: String) -> ConstraintDescriptionFinalizable { + self.identifier = identifier + return self + } + // MARK: Private private let fromItem: ConstraintItem diff --git a/Tests/Tests.swift b/Tests/Tests.swift index e21c85d..7aa81c0 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -249,4 +249,17 @@ class SnapKitTests: XCTestCase { XCTAssertEqual(constraints[1].constant, 50, "Should be 50") } + func testConstraintIdentifier() { + let identifier = "Test-Identifier" + let view = View() + self.container.addSubview(view) + + view.snp_makeConstraints { (make) -> Void in + make.top.equalTo(self.container.snp_top).identifiedAs(identifier) + } + + let constraints = container.snp_constraints as! [NSLayoutConstraint] + XCTAssertEqual(constraints[0].identifier, identifier, "Identifier should be 'Test'") + } + } From 1cfd8424f1b45e799b32b3d4bd6aeb90d23fc700 Mon Sep 17 00:00:00 2001 From: Rohan Panchal Date: Mon, 21 Mar 2016 18:53:30 -0500 Subject: [PATCH 3/7] Changed identifier to label/labeled --- Source/Constraint.swift | 8 ++++---- Source/ConstraintDescription.swift | 10 +++++----- Tests/Tests.swift | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Constraint.swift b/Source/Constraint.swift index 60e0f2f..4f291e6 100644 --- a/Source/Constraint.swift +++ b/Source/Constraint.swift @@ -193,18 +193,18 @@ internal class ConcreteConstraint: Constraint { } } - private let identifier: String? + private let label: String? private var installInfo: ConcreteConstraintInstallInfo? = nil - internal init(fromItem: ConstraintItem, toItem: ConstraintItem, relation: ConstraintRelation, constant: Any, multiplier: Float, priority: Float, identifier: String? = nil) { + internal init(fromItem: ConstraintItem, toItem: ConstraintItem, relation: ConstraintRelation, constant: Any, multiplier: Float, priority: Float, label: String? = nil) { self.fromItem = fromItem self.toItem = toItem self.relation = relation self.constant = constant self.multiplier = multiplier self.priority = priority - self.identifier = identifier + self.label = label } internal func installOnView(updateExisting updateExisting: Bool = false, file: String? = nil, line: UInt? = nil) -> [LayoutConstraint] { @@ -272,7 +272,7 @@ internal class ConcreteConstraint: Constraint { attribute: layoutToAttribute, multiplier: CGFloat(self.multiplier), constant: layoutConstant) - layoutConstraint.identifier = self.identifier + layoutConstraint.identifier = self.label // set priority layoutConstraint.priority = self.priority diff --git a/Source/ConstraintDescription.swift b/Source/ConstraintDescription.swift index 6368fc2..6eb5492 100644 --- a/Source/ConstraintDescription.swift +++ b/Source/ConstraintDescription.swift @@ -34,7 +34,7 @@ public protocol ConstraintDescriptionFinalizable: class { var constraint: Constraint { get } - func identifiedAs(identifier: String) -> ConstraintDescriptionFinalizable + func labeled(label: String) -> ConstraintDescriptionFinalizable } @@ -193,7 +193,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain internal var centerX: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterX) } internal var centerY: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterY) } internal var baseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Baseline) } - internal var identifier: String? + internal var label: String? @available(iOS 8.0, *) internal var firstBaseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.FirstBaseline) } @@ -491,13 +491,13 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain constant: self.constant, multiplier: self.multiplier, priority: self.priority, - identifier: self.identifier) + label: self.label) } return self.concreteConstraint! } - func identifiedAs(identifier: String) -> ConstraintDescriptionFinalizable { - self.identifier = identifier + func labeled(label: String) -> ConstraintDescriptionFinalizable { + self.label = label return self } diff --git a/Tests/Tests.swift b/Tests/Tests.swift index 7aa81c0..eea55b9 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -255,7 +255,7 @@ class SnapKitTests: XCTestCase { self.container.addSubview(view) view.snp_makeConstraints { (make) -> Void in - make.top.equalTo(self.container.snp_top).identifiedAs(identifier) + make.top.equalTo(self.container.snp_top).labeled(identifier) } let constraints = container.snp_constraints as! [NSLayoutConstraint] From 2d095654b4244668fce0c3f61c374dd92519e85b Mon Sep 17 00:00:00 2001 From: Dominik Hadl Date: Tue, 22 Mar 2016 09:59:54 +0100 Subject: [PATCH 4/7] Update deprecated code to Swift 2.2 --- Source/View+SnapKit.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/View+SnapKit.swift b/Source/View+SnapKit.swift index 8672b81..a6ed6e4 100644 --- a/Source/View+SnapKit.swift +++ b/Source/View+SnapKit.swift @@ -127,7 +127,7 @@ public extension View { :returns: the constraints made */ - public func snp_prepareConstraints(file: String = __FILE__, line: UInt = __LINE__, @noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] { + public func snp_prepareConstraints(file: String = #file, line: UInt = #line, @noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] { return ConstraintMaker.prepareConstraints(view: self, file: file, line: line, closure: closure) } @@ -136,7 +136,7 @@ public extension View { :param: closure that will be passed the `ConstraintMaker` to make the constraints with */ - public func snp_makeConstraints(file: String = __FILE__, line: UInt = __LINE__, @noescape closure: (make: ConstraintMaker) -> Void) -> Void { + public func snp_makeConstraints(file: String = #file, line: UInt = #line, @noescape closure: (make: ConstraintMaker) -> Void) -> Void { ConstraintMaker.makeConstraints(view: self, file: file, line: line, closure: closure) } @@ -147,7 +147,7 @@ public extension View { :param: closure that will be passed the `ConstraintMaker` to update the constraints with */ - public func snp_updateConstraints(file: String = __FILE__, line: UInt = __LINE__, @noescape closure: (make: ConstraintMaker) -> Void) -> Void { + public func snp_updateConstraints(file: String = #file, line: UInt = #line, @noescape closure: (make: ConstraintMaker) -> Void) -> Void { ConstraintMaker.updateConstraints(view: self, file: file, line: line, closure: closure) } @@ -156,7 +156,7 @@ public extension View { :param: closure that will be passed the `ConstraintMaker` to remake the constraints with */ - public func snp_remakeConstraints(file: String = __FILE__, line: UInt = __LINE__, @noescape closure: (make: ConstraintMaker) -> Void) -> Void { + public func snp_remakeConstraints(file: String = #file, line: UInt = #line, @noescape closure: (make: ConstraintMaker) -> Void) -> Void { ConstraintMaker.remakeConstraints(view: self, file: file, line: line, closure: closure) } From afe3db62b44032715f44ed079b2773e71420b108 Mon Sep 17 00:00:00 2001 From: Dominik Hadl Date: Tue, 22 Mar 2016 10:05:33 +0100 Subject: [PATCH 5/7] Update travis to use Xcode 7.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8565bda..af40f39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode7 +osx_image: xcode7.3 branches: only: - master From 97b5687f9bbec3d42a3b9ec1b237220dcbda9ba4 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Fri, 25 Mar 2016 16:28:14 +1300 Subject: [PATCH 6/7] Simplified issue template --- ISSUE_TEMPLATE.md | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 15d85b7..eaa5e58 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,25 +1,11 @@ ### New Issue Checklist -- [ ] I have looked at the [Documentation](http://snapkit.io/docs) -- [ ] I have read the [F.A.Q.](http://snapkit.io/faq) - -### Environment / Configuration - -##### Platform - -* [ ] OS X -* [ ] iOS - -##### Versions - +* I have looked at the [Documentation](http://snapkit.io/docs): `INSERT yes/no` +* I have read the [F.A.Q.](http://snapkit.io/faq): `INSERT yes/no` +* Platform is: `INSERT iOS/OSX/tvOS` * Platform version is: `INSERT PLATFORM VERSION` * SnapKit version is: `INSERT SNAPKIT VERSION` - -##### Integration - -- [ ] Carthage -- [ ] Cocoapods -- [ ] Manually / Other +* Integration method is: `INSERT carthage/cocoapods/manually/other` ### Issue From a6e17cb52ec117904ccc41f5bc9a5f34e3924247 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Fri, 25 Mar 2016 16:28:21 +1300 Subject: [PATCH 7/7] Versioning to 0.20.0 --- SnapKit.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index 5f69fa7..c0b19ec 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = 'SnapKit' - s.version = '0.19.1' + s.version = '0.20.0' s.license = 'MIT' s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.' s.homepage = 'https://github.com/SnapKit/SnapKit' s.authors = { 'Robert Payne' => 'robertpayne@me.com' } s.social_media_url = 'http://twitter.com/robertjpayne' - s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '0.19.1' } + s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '0.20.0' } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.10'