mirror of https://github.com/SnapKit/SnapKit
Merge branch 'develop' of github.com:SnapKit/SnapKit
# Conflicts: # ISSUE_TEMPLATE.md
This commit is contained in:
commit
0c3f83784d
|
@ -1,5 +1,5 @@
|
||||||
language: objective-c
|
language: objective-c
|
||||||
osx_image: xcode7
|
osx_image: xcode7.3
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
|
@ -1,25 +1,11 @@
|
||||||
### New Issue Checklist
|
### New Issue Checklist
|
||||||
|
|
||||||
- [ ] I have looked at the [Documentation](http://snapkit.io/docs)
|
* I have looked at the [Documentation](http://snapkit.io/docs): `INSERT yes/no`
|
||||||
- [ ] I have read the [F.A.Q.](http://snapkit.io/faq)
|
* I have read the [F.A.Q.](http://snapkit.io/faq): `INSERT yes/no`
|
||||||
|
* Platform is: `INSERT iOS/OSX/tvOS`
|
||||||
### Environment / Configuration
|
|
||||||
|
|
||||||
##### Platform
|
|
||||||
|
|
||||||
* [ ] OS X
|
|
||||||
* [ ] iOS
|
|
||||||
|
|
||||||
##### Versions
|
|
||||||
|
|
||||||
* Platform version is: `INSERT PLATFORM VERSION`
|
* Platform version is: `INSERT PLATFORM VERSION`
|
||||||
* SnapKit version is: `INSERT SNAPKIT VERSION`
|
* SnapKit version is: `INSERT SNAPKIT VERSION`
|
||||||
|
* Integration method is: `INSERT carthage/cocoapods/manually/other`
|
||||||
##### Integration
|
|
||||||
|
|
||||||
- [ ] Carthage
|
|
||||||
- [ ] Cocoapods
|
|
||||||
- [ ] Manually / Other
|
|
||||||
|
|
||||||
### Issue
|
### Issue
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'SnapKit'
|
s.name = 'SnapKit'
|
||||||
s.version = '0.19.1'
|
s.version = '0.20.0'
|
||||||
s.license = 'MIT'
|
s.license = 'MIT'
|
||||||
s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.'
|
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.homepage = 'https://github.com/SnapKit/SnapKit'
|
||||||
s.authors = { 'Robert Payne' => 'robertpayne@me.com' }
|
s.authors = { 'Robert Payne' => 'robertpayne@me.com' }
|
||||||
s.social_media_url = 'http://twitter.com/robertjpayne'
|
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.ios.deployment_target = '8.0'
|
||||||
s.osx.deployment_target = '10.10'
|
s.osx.deployment_target = '10.10'
|
||||||
|
|
|
@ -193,15 +193,18 @@ internal class ConcreteConstraint: Constraint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private let label: String?
|
||||||
|
|
||||||
private var installInfo: ConcreteConstraintInstallInfo? = nil
|
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, label: String? = nil) {
|
||||||
self.fromItem = fromItem
|
self.fromItem = fromItem
|
||||||
self.toItem = toItem
|
self.toItem = toItem
|
||||||
self.relation = relation
|
self.relation = relation
|
||||||
self.constant = constant
|
self.constant = constant
|
||||||
self.multiplier = multiplier
|
self.multiplier = multiplier
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
|
self.label = label
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func installOnView(updateExisting updateExisting: Bool = false, file: String? = nil, line: UInt? = nil) -> [LayoutConstraint] {
|
internal func installOnView(updateExisting updateExisting: Bool = false, file: String? = nil, line: UInt? = nil) -> [LayoutConstraint] {
|
||||||
|
@ -269,6 +272,7 @@ internal class ConcreteConstraint: Constraint {
|
||||||
attribute: layoutToAttribute,
|
attribute: layoutToAttribute,
|
||||||
multiplier: CGFloat(self.multiplier),
|
multiplier: CGFloat(self.multiplier),
|
||||||
constant: layoutConstant)
|
constant: layoutConstant)
|
||||||
|
layoutConstraint.identifier = self.label
|
||||||
|
|
||||||
// set priority
|
// set priority
|
||||||
layoutConstraint.priority = self.priority
|
layoutConstraint.priority = self.priority
|
||||||
|
|
|
@ -34,6 +34,8 @@ public protocol ConstraintDescriptionFinalizable: class {
|
||||||
|
|
||||||
var constraint: Constraint { get }
|
var constraint: Constraint { get }
|
||||||
|
|
||||||
|
func labeled(label: String) -> ConstraintDescriptionFinalizable
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,6 +193,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
internal var centerX: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterX) }
|
internal var centerX: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterX) }
|
||||||
internal var centerY: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterY) }
|
internal var centerY: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterY) }
|
||||||
internal var baseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Baseline) }
|
internal var baseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Baseline) }
|
||||||
|
internal var label: String?
|
||||||
|
|
||||||
@available(iOS 8.0, *)
|
@available(iOS 8.0, *)
|
||||||
internal var firstBaseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.FirstBaseline) }
|
internal var firstBaseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.FirstBaseline) }
|
||||||
|
@ -487,11 +490,17 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
relation: self.relation!,
|
relation: self.relation!,
|
||||||
constant: self.constant,
|
constant: self.constant,
|
||||||
multiplier: self.multiplier,
|
multiplier: self.multiplier,
|
||||||
priority: self.priority)
|
priority: self.priority,
|
||||||
|
label: self.label)
|
||||||
}
|
}
|
||||||
return self.concreteConstraint!
|
return self.concreteConstraint!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func labeled(label: String) -> ConstraintDescriptionFinalizable {
|
||||||
|
self.label = label
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
private let fromItem: ConstraintItem
|
private let fromItem: ConstraintItem
|
||||||
|
|
|
@ -127,7 +127,7 @@ public extension View {
|
||||||
|
|
||||||
:returns: the constraints made
|
: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)
|
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
|
: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)
|
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
|
: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)
|
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
|
: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)
|
ConstraintMaker.remakeConstraints(view: self, file: file, line: line, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -249,4 +249,17 @@ class SnapKitTests: XCTestCase {
|
||||||
XCTAssertEqual(constraints[1].constant, 50, "Should be 50")
|
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).labeled(identifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
let constraints = container.snp_constraints as! [NSLayoutConstraint]
|
||||||
|
XCTAssertEqual(constraints[0].identifier, identifier, "Identifier should be 'Test'")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue