mirror of https://github.com/SnapKit/SnapKit
Tweaks for OSX support
This commit is contained in:
parent
514ec79042
commit
2764642a2d
|
@ -80,9 +80,9 @@
|
|||
EE235FC01C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBE1C5785DC00C08960 /* ConstraintViewDSL.swift */; };
|
||||
EE235FC11C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBE1C5785DC00C08960 /* ConstraintViewDSL.swift */; };
|
||||
EE235FC21C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBE1C5785DC00C08960 /* ConstraintViewDSL.swift */; };
|
||||
EE235FC31C5785DC00C08960 /* UILayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBF1C5785DC00C08960 /* UILayoutSupportDSL.swift */; };
|
||||
EE235FC41C5785DC00C08960 /* UILayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBF1C5785DC00C08960 /* UILayoutSupportDSL.swift */; };
|
||||
EE235FC51C5785DC00C08960 /* UILayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBF1C5785DC00C08960 /* UILayoutSupportDSL.swift */; };
|
||||
EE235FC31C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBF1C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift */; };
|
||||
EE235FC41C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBF1C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift */; };
|
||||
EE235FC51C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FBF1C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift */; };
|
||||
EE235FC81C5785E200C08960 /* ConstraintView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */; };
|
||||
EE235FC91C5785E200C08960 /* ConstraintView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */; };
|
||||
EE235FCA1C5785E200C08960 /* ConstraintView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */; };
|
||||
|
@ -94,10 +94,10 @@
|
|||
EECDB3931AC0CB52006BBC11 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; };
|
||||
EECDB3941AC0CB52006BBC11 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; };
|
||||
EECDB39D1AC0CC03006BBC11 /* SnapKit.h in Headers */ = {isa = PBXBuildFile; fileRef = EECDB3661AC0C95C006BBC11 /* SnapKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
EEF68F9E1D78492400980C26 /* UILayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* UILayoutGuideDSL.swift */; };
|
||||
EEF68F9E1D78492400980C26 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */; };
|
||||
EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */; };
|
||||
EEF68FAB1D784E3800980C26 /* UILayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* UILayoutGuideDSL.swift */; };
|
||||
EEF68FAC1D784E3800980C26 /* UILayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* UILayoutGuideDSL.swift */; };
|
||||
EEF68FAB1D784E3800980C26 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */; };
|
||||
EEF68FAC1D784E3800980C26 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */; };
|
||||
EEF68FAD1D784E3A00980C26 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */; };
|
||||
EEF68FAE1D784E3B00980C26 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */; };
|
||||
EEF68FB01D784FB100980C26 /* UILayoutGuide+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FAF1D784FB100980C26 /* UILayoutGuide+Extensions.swift */; };
|
||||
|
@ -106,6 +106,12 @@
|
|||
EEF68FB41D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */; };
|
||||
EEF68FB51D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */; };
|
||||
EEF68FB61D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */; };
|
||||
EEF68FBC1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */; };
|
||||
EEF68FBD1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */; };
|
||||
EEF68FBE1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */; };
|
||||
EEF68FC01D7865AA00980C26 /* ConstraintLayoutSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FBF1D7865AA00980C26 /* ConstraintLayoutSupport.swift */; };
|
||||
EEF68FC11D7865AA00980C26 /* ConstraintLayoutSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FBF1D7865AA00980C26 /* ConstraintLayoutSupport.swift */; };
|
||||
EEF68FC21D7865AA00980C26 /* ConstraintLayoutSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FBF1D7865AA00980C26 /* ConstraintLayoutSupport.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
@ -145,7 +151,7 @@
|
|||
EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerRelatable.swift; sourceTree = "<group>"; };
|
||||
EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerExtendable.swift; sourceTree = "<group>"; };
|
||||
EE235FBE1C5785DC00C08960 /* ConstraintViewDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintViewDSL.swift; sourceTree = "<group>"; };
|
||||
EE235FBF1C5785DC00C08960 /* UILayoutSupportDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UILayoutSupportDSL.swift; sourceTree = "<group>"; };
|
||||
EE235FBF1C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutSupportDSL.swift; sourceTree = "<group>"; };
|
||||
EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintView+Extensions.swift"; sourceTree = "<group>"; };
|
||||
EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; };
|
||||
|
@ -157,10 +163,12 @@
|
|||
EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
|
||||
EECDB37A1AC0C9D4006BBC11 /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EECDB3841AC0C9D4006BBC11 /* SnapKit OSX Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SnapKit OSX Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EEF68F9D1D78492400980C26 /* UILayoutGuideDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UILayoutGuideDSL.swift; sourceTree = "<group>"; };
|
||||
EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuideDSL.swift; sourceTree = "<group>"; };
|
||||
EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDSL.swift; sourceTree = "<group>"; };
|
||||
EEF68FAF1D784FB100980C26 /* UILayoutGuide+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILayoutGuide+Extensions.swift"; sourceTree = "<group>"; };
|
||||
EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILayoutSupport+Extensions.swift"; sourceTree = "<group>"; };
|
||||
EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuide.swift; sourceTree = "<group>"; };
|
||||
EEF68FBF1D7865AA00980C26 /* ConstraintLayoutSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutSupport.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -252,8 +260,8 @@
|
|||
children = (
|
||||
EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */,
|
||||
EE235FBE1C5785DC00C08960 /* ConstraintViewDSL.swift */,
|
||||
EEF68F9D1D78492400980C26 /* UILayoutGuideDSL.swift */,
|
||||
EE235FBF1C5785DC00C08960 /* UILayoutSupportDSL.swift */,
|
||||
EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */,
|
||||
EE235FBF1C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift */,
|
||||
);
|
||||
name = DSLs;
|
||||
sourceTree = "<group>";
|
||||
|
@ -292,6 +300,8 @@
|
|||
EE235F641C5785C600C08960 /* ConstraintInsets.swift */,
|
||||
EE235F651C5785C600C08960 /* ConstraintConfig.swift */,
|
||||
EE235F661C5785C600C08960 /* ConstraintView.swift */,
|
||||
EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */,
|
||||
EEF68FBF1D7865AA00980C26 /* ConstraintLayoutSupport.swift */,
|
||||
EE235F681C5785C600C08960 /* ConstraintRelation.swift */,
|
||||
EE235F6A1C5785C600C08960 /* ConstraintAttributes.swift */,
|
||||
EE235F6B1C5785C600C08960 /* ConstraintItem.swift */,
|
||||
|
@ -602,14 +612,16 @@
|
|||
EE235FB91C5785D400C08960 /* ConstraintMakerRelatable.swift in Sources */,
|
||||
EE235F861C5785C600C08960 /* ConstraintAttributes.swift in Sources */,
|
||||
EE235FA11C5785CE00C08960 /* ConstraintOffsetTarget.swift in Sources */,
|
||||
EEF68FAB1D784E3800980C26 /* UILayoutGuideDSL.swift in Sources */,
|
||||
EEF68FAB1D784E3800980C26 /* ConstraintLayoutGuideDSL.swift in Sources */,
|
||||
EE235FB61C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */,
|
||||
EEF68FBD1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */,
|
||||
EE235FAD1C5785D400C08960 /* ConstraintMaker.swift in Sources */,
|
||||
EE235F951C5785CE00C08960 /* ConstraintRelatableTarget.swift in Sources */,
|
||||
EE235FBC1C5785D400C08960 /* ConstraintMakerExtendable.swift in Sources */,
|
||||
EEF68FAD1D784E3A00980C26 /* ConstraintDSL.swift in Sources */,
|
||||
EE235F891C5785C600C08960 /* ConstraintItem.swift in Sources */,
|
||||
EE235F9B1C5785CE00C08960 /* ConstraintPriorityTarget.swift in Sources */,
|
||||
EEF68FC11D7865AA00980C26 /* ConstraintLayoutSupport.swift in Sources */,
|
||||
EEF68FB11D784FB100980C26 /* UILayoutGuide+Extensions.swift in Sources */,
|
||||
EE235F771C5785C600C08960 /* ConstraintConfig.swift in Sources */,
|
||||
EE235F6E1C5785C600C08960 /* Constraint.swift in Sources */,
|
||||
|
@ -620,7 +632,7 @@
|
|||
EE235F9E1C5785CE00C08960 /* ConstraintMultiplierTarget.swift in Sources */,
|
||||
EE235FC11C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */,
|
||||
EE235F601C5785BC00C08960 /* Debugging.swift in Sources */,
|
||||
EE235FC41C5785DC00C08960 /* UILayoutSupportDSL.swift in Sources */,
|
||||
EE235FC41C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */,
|
||||
EE235F801C5785C600C08960 /* ConstraintRelation.swift in Sources */,
|
||||
EEF68FB51D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */,
|
||||
EE235F711C5785C600C08960 /* ConstraintDescription.swift in Sources */,
|
||||
|
@ -646,14 +658,16 @@
|
|||
EE235FB81C5785D400C08960 /* ConstraintMakerRelatable.swift in Sources */,
|
||||
EE235F851C5785C600C08960 /* ConstraintAttributes.swift in Sources */,
|
||||
EE235FA01C5785CE00C08960 /* ConstraintOffsetTarget.swift in Sources */,
|
||||
EEF68F9E1D78492400980C26 /* UILayoutGuideDSL.swift in Sources */,
|
||||
EEF68F9E1D78492400980C26 /* ConstraintLayoutGuideDSL.swift in Sources */,
|
||||
EE235FB51C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */,
|
||||
EEF68FBC1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */,
|
||||
EE235FAC1C5785D400C08960 /* ConstraintMaker.swift in Sources */,
|
||||
EE235F941C5785CE00C08960 /* ConstraintRelatableTarget.swift in Sources */,
|
||||
EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */,
|
||||
EE235FBB1C5785D400C08960 /* ConstraintMakerExtendable.swift in Sources */,
|
||||
EE235F881C5785C600C08960 /* ConstraintItem.swift in Sources */,
|
||||
EE235F9A1C5785CE00C08960 /* ConstraintPriorityTarget.swift in Sources */,
|
||||
EEF68FC01D7865AA00980C26 /* ConstraintLayoutSupport.swift in Sources */,
|
||||
EEF68FB01D784FB100980C26 /* UILayoutGuide+Extensions.swift in Sources */,
|
||||
EE235F761C5785C600C08960 /* ConstraintConfig.swift in Sources */,
|
||||
EE235F6D1C5785C600C08960 /* Constraint.swift in Sources */,
|
||||
|
@ -664,7 +678,7 @@
|
|||
EE235F9D1C5785CE00C08960 /* ConstraintMultiplierTarget.swift in Sources */,
|
||||
EE235FC01C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */,
|
||||
EE235F5F1C5785BC00C08960 /* Debugging.swift in Sources */,
|
||||
EE235FC31C5785DC00C08960 /* UILayoutSupportDSL.swift in Sources */,
|
||||
EE235FC31C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */,
|
||||
EE235F7F1C5785C600C08960 /* ConstraintRelation.swift in Sources */,
|
||||
EEF68FB41D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */,
|
||||
EE235F701C5785C600C08960 /* ConstraintDescription.swift in Sources */,
|
||||
|
@ -690,14 +704,16 @@
|
|||
EE235FBA1C5785D400C08960 /* ConstraintMakerRelatable.swift in Sources */,
|
||||
EE235F871C5785C600C08960 /* ConstraintAttributes.swift in Sources */,
|
||||
EE235FA21C5785CE00C08960 /* ConstraintOffsetTarget.swift in Sources */,
|
||||
EEF68FAC1D784E3800980C26 /* UILayoutGuideDSL.swift in Sources */,
|
||||
EEF68FAC1D784E3800980C26 /* ConstraintLayoutGuideDSL.swift in Sources */,
|
||||
EE235FB71C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */,
|
||||
EEF68FBE1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */,
|
||||
EE235FAE1C5785D400C08960 /* ConstraintMaker.swift in Sources */,
|
||||
EE235F961C5785CE00C08960 /* ConstraintRelatableTarget.swift in Sources */,
|
||||
EE235FBD1C5785D400C08960 /* ConstraintMakerExtendable.swift in Sources */,
|
||||
EEF68FAE1D784E3B00980C26 /* ConstraintDSL.swift in Sources */,
|
||||
EE235F8A1C5785C600C08960 /* ConstraintItem.swift in Sources */,
|
||||
EE235F9C1C5785CE00C08960 /* ConstraintPriorityTarget.swift in Sources */,
|
||||
EEF68FC21D7865AA00980C26 /* ConstraintLayoutSupport.swift in Sources */,
|
||||
EEF68FB21D784FB100980C26 /* UILayoutGuide+Extensions.swift in Sources */,
|
||||
EE235F781C5785C600C08960 /* ConstraintConfig.swift in Sources */,
|
||||
EE235F6F1C5785C600C08960 /* Constraint.swift in Sources */,
|
||||
|
@ -708,7 +724,7 @@
|
|||
EE235F9F1C5785CE00C08960 /* ConstraintMultiplierTarget.swift in Sources */,
|
||||
EE235FC21C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */,
|
||||
EE235F611C5785BC00C08960 /* Debugging.swift in Sources */,
|
||||
EE235FC51C5785DC00C08960 /* UILayoutSupportDSL.swift in Sources */,
|
||||
EE235FC51C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */,
|
||||
EE235F811C5785C600C08960 /* ConstraintRelation.swift in Sources */,
|
||||
EEF68FB61D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */,
|
||||
EE235F721C5785C600C08960 /* ConstraintDescription.swift in Sources */,
|
||||
|
|
|
@ -81,41 +81,49 @@ public class Constraint {
|
|||
for layoutFromAttribute in layoutFromAttributes {
|
||||
// get layout to attribute
|
||||
let layoutToAttribute: NSLayoutAttribute
|
||||
if layoutToAttributes.count > 1 {
|
||||
if self.from.attributes == .edges && self.to.attributes == .margins {
|
||||
switch layoutFromAttribute {
|
||||
case .left:
|
||||
layoutToAttribute = .leftMargin
|
||||
case .right:
|
||||
layoutToAttribute = .rightMargin
|
||||
case .top:
|
||||
layoutToAttribute = .topMargin
|
||||
case .bottom:
|
||||
layoutToAttribute = .bottomMargin
|
||||
default:
|
||||
fatalError()
|
||||
#if os(iOS) || os(tvOS)
|
||||
if layoutToAttributes.count > 1 {
|
||||
if self.from.attributes == .edges && self.to.attributes == .margins {
|
||||
switch layoutFromAttribute {
|
||||
case .left:
|
||||
layoutToAttribute = .leftMargin
|
||||
case .right:
|
||||
layoutToAttribute = .rightMargin
|
||||
case .top:
|
||||
layoutToAttribute = .topMargin
|
||||
case .bottom:
|
||||
layoutToAttribute = .bottomMargin
|
||||
default:
|
||||
fatalError()
|
||||
}
|
||||
} else if self.from.attributes == .margins && self.to.attributes == .edges {
|
||||
switch layoutFromAttribute {
|
||||
case .leftMargin:
|
||||
layoutToAttribute = .left
|
||||
case .rightMargin:
|
||||
layoutToAttribute = .right
|
||||
case .topMargin:
|
||||
layoutToAttribute = .top
|
||||
case .bottomMargin:
|
||||
layoutToAttribute = .bottom
|
||||
default:
|
||||
fatalError()
|
||||
}
|
||||
} else {
|
||||
layoutToAttribute = layoutToAttributes[0]
|
||||
}
|
||||
} else if self.from.attributes == .margins && self.to.attributes == .edges {
|
||||
switch layoutFromAttribute {
|
||||
case .leftMargin:
|
||||
layoutToAttribute = .left
|
||||
case .rightMargin:
|
||||
layoutToAttribute = .right
|
||||
case .topMargin:
|
||||
layoutToAttribute = .top
|
||||
case .bottomMargin:
|
||||
layoutToAttribute = .bottom
|
||||
default:
|
||||
fatalError()
|
||||
}
|
||||
} else {
|
||||
} else if layoutToAttributes.count == 1 {
|
||||
layoutToAttribute = layoutToAttributes[0]
|
||||
} else {
|
||||
layoutToAttribute = layoutFromAttribute
|
||||
}
|
||||
} else if layoutToAttributes.count == 1 {
|
||||
layoutToAttribute = layoutToAttributes[0]
|
||||
} else {
|
||||
layoutToAttribute = layoutFromAttribute
|
||||
}
|
||||
#else
|
||||
if layoutToAttributes.count > 0 {
|
||||
layoutToAttribute = layoutToAttributes[0]
|
||||
} else {
|
||||
layoutToAttribute = layoutFromAttribute
|
||||
}
|
||||
#endif
|
||||
|
||||
// get layout constant
|
||||
let layoutConstant: CGFloat = self.constant.constraintConstantTargetValueFor(layoutAttribute: layoutToAttribute)
|
||||
|
|
|
@ -124,17 +124,17 @@ extension ConstraintConstantTarget {
|
|||
case .top, .centerY, .lastBaseline, .firstBaseline:
|
||||
return value.top
|
||||
case .right:
|
||||
return value.right
|
||||
return -value.right
|
||||
case .bottom:
|
||||
return value.bottom
|
||||
return -value.bottom
|
||||
case .leading:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : -value.right
|
||||
case .trailing:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.right : -value.left
|
||||
case .width:
|
||||
return -value.left + value.right
|
||||
return -(value.left + value.right)
|
||||
case .height:
|
||||
return -value.top + value.bottom
|
||||
return -(value.top + value.bottom)
|
||||
case .notAnAttribute:
|
||||
return 0.0
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// SnapKit
|
||||
//
|
||||
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
import UIKit
|
||||
#else
|
||||
import AppKit
|
||||
#endif
|
||||
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
@available(iOS 9.0, *)
|
||||
public typealias ConstraintLayoutGuide = UILayoutGuide
|
||||
#else
|
||||
public class ConstraintLayoutGuide {}
|
||||
#endif
|
|
@ -29,15 +29,15 @@
|
|||
|
||||
|
||||
@available(iOS 9.0, *)
|
||||
public struct UILayoutGuideDSL: ConstraintAttributesDSL {
|
||||
public struct ConstraintLayoutGuideDSL: ConstraintAttributesDSL {
|
||||
|
||||
public var target: AnyObject? {
|
||||
return self.guide
|
||||
}
|
||||
|
||||
internal let guide: UILayoutGuide
|
||||
internal let guide: ConstraintLayoutGuide
|
||||
|
||||
internal init(guide: UILayoutGuide) {
|
||||
internal init(guide: ConstraintLayoutGuide) {
|
||||
self.guide = guide
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// SnapKit
|
||||
//
|
||||
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
import UIKit
|
||||
#else
|
||||
import AppKit
|
||||
#endif
|
||||
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
@available(iOS 8.0, *)
|
||||
public typealias ConstraintLayoutSupport = UILayoutSupport
|
||||
#else
|
||||
public class ConstraintLayoutSupport {}
|
||||
#endif
|
|
@ -29,15 +29,15 @@
|
|||
|
||||
|
||||
@available(iOS 8.0, *)
|
||||
public struct UILayoutSupportDSL: ConstraintDSL {
|
||||
public struct ConstraintLayoutSupportDSL: ConstraintDSL {
|
||||
|
||||
public var target: AnyObject? {
|
||||
return self.support
|
||||
}
|
||||
|
||||
internal let support: UILayoutSupport
|
||||
internal let support: ConstraintLayoutSupport
|
||||
|
||||
internal init(support: UILayoutSupport) {
|
||||
internal init(support: ConstraintLayoutSupport) {
|
||||
self.support = support
|
||||
|
||||
}
|
|
@ -27,10 +27,10 @@
|
|||
|
||||
|
||||
@available(iOS 9.0, *)
|
||||
public extension UILayoutGuide {
|
||||
public extension ConstraintLayoutGuide {
|
||||
|
||||
public var snp: UILayoutGuideDSL {
|
||||
return UILayoutGuideDSL(guide: self)
|
||||
public var snp: ConstraintLayoutGuideDSL {
|
||||
return ConstraintLayoutGuideDSL(guide: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
|
||||
|
||||
@available(iOS 8.0, *)
|
||||
public extension UILayoutSupport {
|
||||
public extension ConstraintLayoutSupport {
|
||||
|
||||
public var snp: UILayoutSupportDSL {
|
||||
return UILayoutSupportDSL(support: self)
|
||||
public var snp: ConstraintLayoutSupportDSL {
|
||||
return ConstraintLayoutSupportDSL(support: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,24 +29,6 @@ class SnapKitTests: XCTestCase {
|
|||
super.tearDown()
|
||||
}
|
||||
|
||||
func testLayoutGuideConstraints() {
|
||||
#if os(iOS) || os(tvOS)
|
||||
let vc = UIViewController()
|
||||
vc.view = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
|
||||
|
||||
vc.view.addSubview(self.container)
|
||||
|
||||
self.container.snp.makeConstraints { (make) -> Void in
|
||||
make.top.equalTo(vc.topLayoutGuide.snp.bottom)
|
||||
make.bottom.equalTo(vc.bottomLayoutGuide.snp.top)
|
||||
}
|
||||
|
||||
print(vc.view.snp_constraints)
|
||||
|
||||
XCTAssertEqual(vc.view.snp_constraints.count, 6, "Should have 6 constraints installed")
|
||||
#endif
|
||||
}
|
||||
|
||||
func testMakeConstraints() {
|
||||
let v1 = View()
|
||||
let v2 = View()
|
||||
|
@ -324,12 +306,12 @@ class SnapKitTests: XCTestCase {
|
|||
XCTAssertEqual(constraints[3].constant, -50, "Should be -50")
|
||||
}
|
||||
|
||||
func testUIEdgeInsetsAsImpliedEqualToConstraints() {
|
||||
func testConstraintInsetsAsImpliedEqualToConstraints() {
|
||||
let view = View()
|
||||
self.container.addSubview(view)
|
||||
|
||||
view.snp.makeConstraints { (make) -> Void in
|
||||
make.edges.equalTo(UIEdgeInsets(top: 25, left: 25, bottom: 25, right: 25))
|
||||
make.edges.equalTo(ConstraintInsets(top: 25, left: 25, bottom: 25, right: 25))
|
||||
}
|
||||
|
||||
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints")
|
||||
|
@ -343,12 +325,12 @@ class SnapKitTests: XCTestCase {
|
|||
XCTAssertEqual(constraints[3].constant, -25, "Should be -25")
|
||||
}
|
||||
|
||||
func testUIEdgeInsetsAsConstraintsConstant() {
|
||||
func testConstraintInsetsAsConstraintsConstant() {
|
||||
let view = View()
|
||||
self.container.addSubview(view)
|
||||
|
||||
view.snp.makeConstraints { (make) -> Void in
|
||||
make.edges.equalTo(self.container).inset(UIEdgeInsets(top: 25, left: 25, bottom: 25, right: 25))
|
||||
make.edges.equalTo(self.container).inset(ConstraintInsets(top: 25, left: 25, bottom: 25, right: 25))
|
||||
}
|
||||
|
||||
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints")
|
||||
|
@ -418,6 +400,7 @@ class SnapKitTests: XCTestCase {
|
|||
XCTAssertEqual(constraints[0].identifier, identifier, "Identifier should be 'Test'")
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
func testEdgesToMargins() {
|
||||
var fromAttributes = Set<NSLayoutAttribute>()
|
||||
var toAttributes = Set<NSLayoutAttribute>()
|
||||
|
@ -458,4 +441,21 @@ class SnapKitTests: XCTestCase {
|
|||
|
||||
}
|
||||
|
||||
func testLayoutGuideConstraints() {
|
||||
let vc = UIViewController()
|
||||
vc.view = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
|
||||
|
||||
vc.view.addSubview(self.container)
|
||||
|
||||
self.container.snp.makeConstraints { (make) -> Void in
|
||||
make.top.equalTo(vc.topLayoutGuide.snp.bottom)
|
||||
make.bottom.equalTo(vc.bottomLayoutGuide.snp.top)
|
||||
}
|
||||
|
||||
print(vc.view.snp_constraints)
|
||||
|
||||
XCTAssertEqual(vc.view.snp_constraints.count, 6, "Should have 6 constraints installed")
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue