mirror of https://github.com/SnapKit/SnapKit
Swift 3.0 Migration
This commit is contained in:
parent
f785886d3a
commit
8355410d92
|
@ -1,12 +1,12 @@
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'SnapKit'
|
s.name = 'SnapKit'
|
||||||
s.version = '0.30.0.beta1'
|
s.version = '0.40.0.beta1'
|
||||||
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.30.0.beta1' }
|
s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '0.40.0.beta1' }
|
||||||
|
|
||||||
s.ios.deployment_target = '8.0'
|
s.ios.deployment_target = '8.0'
|
||||||
s.osx.deployment_target = '10.10'
|
s.osx.deployment_target = '10.10'
|
||||||
|
|
|
@ -495,15 +495,18 @@
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
537DCE911C35CC8800B5B899 = {
|
537DCE911C35CC8800B5B899 = {
|
||||||
CreatedOnToolsVersion = 7.2;
|
CreatedOnToolsVersion = 7.2;
|
||||||
|
LastSwiftMigration = 0800;
|
||||||
};
|
};
|
||||||
537DCEAE1C35D90A00B5B899 = {
|
537DCEAE1C35D90A00B5B899 = {
|
||||||
CreatedOnToolsVersion = 7.2;
|
CreatedOnToolsVersion = 7.2;
|
||||||
};
|
};
|
||||||
EEBCC9D719CC627D0083B827 = {
|
EEBCC9D719CC627D0083B827 = {
|
||||||
CreatedOnToolsVersion = 6.0;
|
CreatedOnToolsVersion = 6.0;
|
||||||
|
LastSwiftMigration = 0800;
|
||||||
};
|
};
|
||||||
EEBCC9E119CC627D0083B827 = {
|
EEBCC9E119CC627D0083B827 = {
|
||||||
CreatedOnToolsVersion = 6.0;
|
CreatedOnToolsVersion = 6.0;
|
||||||
|
LastSwiftMigration = 0800;
|
||||||
};
|
};
|
||||||
EECDB3791AC0C9D4006BBC11 = {
|
EECDB3791AC0C9D4006BBC11 = {
|
||||||
CreatedOnToolsVersion = 6.2;
|
CreatedOnToolsVersion = 6.2;
|
||||||
|
@ -741,6 +744,7 @@
|
||||||
SDKROOT = appletvos;
|
SDKROOT = appletvos;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
SWIFT_VERSION = 3.0;
|
||||||
TARGETED_DEVICE_FAMILY = 3;
|
TARGETED_DEVICE_FAMILY = 3;
|
||||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
@ -767,6 +771,7 @@
|
||||||
PRODUCT_NAME = SnapKit;
|
PRODUCT_NAME = SnapKit;
|
||||||
SDKROOT = appletvos;
|
SDKROOT = appletvos;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
|
SWIFT_VERSION = 3.0;
|
||||||
TARGETED_DEVICE_FAMILY = 3;
|
TARGETED_DEVICE_FAMILY = 3;
|
||||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
@ -903,6 +908,7 @@
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
SWIFT_VERSION = 3.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
VERSION_INFO_PREFIX = "";
|
VERSION_INFO_PREFIX = "";
|
||||||
};
|
};
|
||||||
|
@ -925,6 +931,7 @@
|
||||||
PRODUCT_NAME = SnapKit;
|
PRODUCT_NAME = SnapKit;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
|
SWIFT_VERSION = 3.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
VERSION_INFO_PREFIX = "";
|
VERSION_INFO_PREFIX = "";
|
||||||
};
|
};
|
||||||
|
@ -938,6 +945,7 @@
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 3.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
|
@ -949,6 +957,7 @@
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 3.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class Constraint {
|
||||||
|
|
||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
internal func installIfNeeded(updateExisting updateExisting: Bool = false) -> [NSLayoutConstraint] {
|
internal func installIfNeeded(updateExisting: Bool = false) -> [NSLayoutConstraint] {
|
||||||
let installOnView: ConstraintView?
|
let installOnView: ConstraintView?
|
||||||
|
|
||||||
if let view = self.to.view {
|
if let view = self.to.view {
|
||||||
|
@ -88,7 +88,7 @@ public class Constraint {
|
||||||
fatalError("Cannot Install Constraint. No common superview. (\(self.sourceLocation.0), \(self.sourceLocation.1))")
|
fatalError("Cannot Install Constraint. No common superview. (\(self.sourceLocation.0), \(self.sourceLocation.1))")
|
||||||
}
|
}
|
||||||
installOnView = closestSuperview
|
installOnView = closestSuperview
|
||||||
} else if self.from.attributes.isSubsetOf(ConstraintAttributes.Width + ConstraintAttributes.Height) {
|
} else if self.from.attributes.isSubset(of: ConstraintAttributes.Width + ConstraintAttributes.Height) {
|
||||||
installOnView = self.from.view
|
installOnView = self.from.view
|
||||||
} else {
|
} else {
|
||||||
guard let superview = self.from.view?.superview else {
|
guard let superview = self.from.view?.superview else {
|
||||||
|
@ -128,7 +128,7 @@ public class Constraint {
|
||||||
#else
|
#else
|
||||||
var layoutTo: AnyObject? = self.to.view
|
var layoutTo: AnyObject? = self.to.view
|
||||||
#endif
|
#endif
|
||||||
if layoutTo == nil && layoutToAttribute != .Width && layoutToAttribute != .Height {
|
if layoutTo == nil && layoutToAttribute != .width && layoutToAttribute != .height {
|
||||||
layoutTo = installOnView
|
layoutTo = installOnView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ public class Constraint {
|
||||||
if updateExisting {
|
if updateExisting {
|
||||||
|
|
||||||
// get existing constraints for this view
|
// get existing constraints for this view
|
||||||
let existingLayoutConstraints = layoutFrom.snp.installedLayoutConstraints.reverse()
|
let existingLayoutConstraints = layoutFrom.snp.installedLayoutConstraints.reversed()
|
||||||
|
|
||||||
// array that will contain only new layout constraints to keep
|
// array that will contain only new layout constraints to keep
|
||||||
var newLayoutConstraintsToKeep = [LayoutConstraint]()
|
var newLayoutConstraintsToKeep = [LayoutConstraint]()
|
||||||
|
@ -197,15 +197,15 @@ public class Constraint {
|
||||||
installOnView?.addConstraints(newLayoutConstraints)
|
installOnView?.addConstraints(newLayoutConstraints)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
NSLayoutConstraint.activateConstraints(newLayoutConstraints)
|
NSLayoutConstraint.activate(newLayoutConstraints)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// set install info
|
// set install info
|
||||||
self.installInfo = ConstraintInstallInfo(view: installOnView, layoutConstraints: NSHashTable.weakObjectsHashTable())
|
self.installInfo = ConstraintInstallInfo(view: installOnView, layoutConstraints: HashTable.weakObjects())
|
||||||
|
|
||||||
// store which layout constraints are installed for this constraint
|
// store which layout constraints are installed for this constraint
|
||||||
for layoutConstraint in newLayoutConstraints {
|
for layoutConstraint in newLayoutConstraints {
|
||||||
self.installInfo!.layoutConstraints.addObject(layoutConstraint)
|
self.installInfo!.layoutConstraints.add(layoutConstraint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the layout constraints against the layout from view
|
// store the layout constraints against the layout from view
|
||||||
|
@ -231,7 +231,7 @@ public class Constraint {
|
||||||
installedOnView.removeConstraints(installedLayoutConstraints)
|
installedOnView.removeConstraints(installedLayoutConstraints)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
NSLayoutConstraint.deactivateConstraints(installedLayoutConstraints)
|
NSLayoutConstraint.deactivate(installedLayoutConstraints)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// remove the constraints from the from item view
|
// remove the constraints from the from item view
|
||||||
|
@ -255,7 +255,7 @@ public class Constraint {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
NSLayoutConstraint.activateConstraints(layoutConstraints)
|
NSLayoutConstraint.activate(layoutConstraints)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func deactivateIfNeeded() {
|
internal func deactivateIfNeeded() {
|
||||||
|
@ -270,7 +270,7 @@ public class Constraint {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
|
NSLayoutConstraint.deactivate(layoutConstraints)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -278,16 +278,16 @@ public class Constraint {
|
||||||
private final class ConstraintInstallInfo {
|
private final class ConstraintInstallInfo {
|
||||||
|
|
||||||
private weak var view: ConstraintView? = nil
|
private weak var view: ConstraintView? = nil
|
||||||
private let layoutConstraints: NSHashTable
|
private let layoutConstraints: HashTable<AnyObject>
|
||||||
|
|
||||||
private init(view: ConstraintView?, layoutConstraints: NSHashTable) {
|
private init(view: ConstraintView?, layoutConstraints: HashTable<AnyObject>) {
|
||||||
self.view = view
|
self.view = view
|
||||||
self.layoutConstraints = layoutConstraints
|
self.layoutConstraints = layoutConstraints
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func closestCommonSuperviewFromView(fromView: ConstraintView?, toView: ConstraintView?) -> ConstraintView? {
|
private func closestCommonSuperviewFromView(_ fromView: ConstraintView?, toView: ConstraintView?) -> ConstraintView? {
|
||||||
var views = Set<ConstraintView>()
|
var views = Set<ConstraintView>()
|
||||||
var fromView = fromView
|
var fromView = fromView
|
||||||
var toView = toView
|
var toView = toView
|
||||||
|
@ -315,6 +315,6 @@ private func ==(lhs: Constraint, rhs: Constraint) -> Bool {
|
||||||
return (lhs.from == rhs.from &&
|
return (lhs.from == rhs.from &&
|
||||||
lhs.to == rhs.to &&
|
lhs.to == rhs.to &&
|
||||||
lhs.relation == rhs.relation &&
|
lhs.relation == rhs.relation &&
|
||||||
lhs.multiplier == rhs.multiplier &&
|
lhs.multiplier.constraintMultiplierTargetValue == rhs.multiplier.constraintMultiplierTargetValue &&
|
||||||
lhs.priority == rhs.priority)
|
lhs.priority.constraintPriorityTargetValue == rhs.priority.constraintPriorityTargetValue)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
internal struct ConstraintAttributes: OptionSet, Boolean {
|
||||||
|
|
||||||
internal init(rawValue: UInt) {
|
internal init(rawValue: UInt) {
|
||||||
self.rawValue = rawValue
|
self.rawValue = rawValue
|
||||||
|
@ -46,8 +46,8 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
||||||
internal var boolValue: Bool { return self.rawValue != 0 }
|
internal var boolValue: Bool { return self.rawValue != 0 }
|
||||||
|
|
||||||
internal func toRaw() -> UInt { return self.rawValue }
|
internal func toRaw() -> UInt { return self.rawValue }
|
||||||
internal static func fromRaw(raw: UInt) -> ConstraintAttributes? { return self.init(raw) }
|
internal static func fromRaw(_ raw: UInt) -> ConstraintAttributes? { return self.init(raw) }
|
||||||
internal static func fromMask(raw: UInt) -> ConstraintAttributes { return self.init(raw) }
|
internal static func fromMask(_ raw: UInt) -> ConstraintAttributes { return self.init(raw) }
|
||||||
|
|
||||||
// normal
|
// normal
|
||||||
|
|
||||||
|
@ -98,37 +98,37 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
||||||
internal var layoutAttributes:[NSLayoutAttribute] {
|
internal var layoutAttributes:[NSLayoutAttribute] {
|
||||||
var attrs = [NSLayoutAttribute]()
|
var attrs = [NSLayoutAttribute]()
|
||||||
if (self.contains(ConstraintAttributes.Left)) {
|
if (self.contains(ConstraintAttributes.Left)) {
|
||||||
attrs.append(.Left)
|
attrs.append(.left)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.Top)) {
|
if (self.contains(ConstraintAttributes.Top)) {
|
||||||
attrs.append(.Top)
|
attrs.append(.top)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.Right)) {
|
if (self.contains(ConstraintAttributes.Right)) {
|
||||||
attrs.append(.Right)
|
attrs.append(.right)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.Bottom)) {
|
if (self.contains(ConstraintAttributes.Bottom)) {
|
||||||
attrs.append(.Bottom)
|
attrs.append(.bottom)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.Leading)) {
|
if (self.contains(ConstraintAttributes.Leading)) {
|
||||||
attrs.append(.Leading)
|
attrs.append(.leading)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.Trailing)) {
|
if (self.contains(ConstraintAttributes.Trailing)) {
|
||||||
attrs.append(.Trailing)
|
attrs.append(.trailing)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.Width)) {
|
if (self.contains(ConstraintAttributes.Width)) {
|
||||||
attrs.append(.Width)
|
attrs.append(.width)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.Height)) {
|
if (self.contains(ConstraintAttributes.Height)) {
|
||||||
attrs.append(.Height)
|
attrs.append(.height)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.CenterX)) {
|
if (self.contains(ConstraintAttributes.CenterX)) {
|
||||||
attrs.append(.CenterX)
|
attrs.append(.centerX)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.CenterY)) {
|
if (self.contains(ConstraintAttributes.CenterY)) {
|
||||||
attrs.append(.CenterY)
|
attrs.append(.centerY)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.Baseline)) {
|
if (self.contains(ConstraintAttributes.Baseline)) {
|
||||||
attrs.append(.Baseline)
|
attrs.append(.lastBaseline)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if os(iOS) || os(tvOS)
|
#if os(iOS) || os(tvOS)
|
||||||
|
@ -138,31 +138,31 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (self.contains(ConstraintAttributes.FirstBaseline)) {
|
if (self.contains(ConstraintAttributes.FirstBaseline)) {
|
||||||
attrs.append(.FirstBaseline)
|
attrs.append(.firstBaseline)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.LeftMargin)) {
|
if (self.contains(ConstraintAttributes.LeftMargin)) {
|
||||||
attrs.append(.LeftMargin)
|
attrs.append(.leftMargin)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.RightMargin)) {
|
if (self.contains(ConstraintAttributes.RightMargin)) {
|
||||||
attrs.append(.RightMargin)
|
attrs.append(.rightMargin)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.TopMargin)) {
|
if (self.contains(ConstraintAttributes.TopMargin)) {
|
||||||
attrs.append(.TopMargin)
|
attrs.append(.topMargin)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.BottomMargin)) {
|
if (self.contains(ConstraintAttributes.BottomMargin)) {
|
||||||
attrs.append(.BottomMargin)
|
attrs.append(.bottomMargin)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.LeadingMargin)) {
|
if (self.contains(ConstraintAttributes.LeadingMargin)) {
|
||||||
attrs.append(.LeadingMargin)
|
attrs.append(.leadingMargin)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.TrailingMargin)) {
|
if (self.contains(ConstraintAttributes.TrailingMargin)) {
|
||||||
attrs.append(.TrailingMargin)
|
attrs.append(.trailingMargin)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.CenterXWithinMargins)) {
|
if (self.contains(ConstraintAttributes.CenterXWithinMargins)) {
|
||||||
attrs.append(.CenterXWithinMargins)
|
attrs.append(.centerXWithinMargins)
|
||||||
}
|
}
|
||||||
if (self.contains(ConstraintAttributes.CenterYWithinMargins)) {
|
if (self.contains(ConstraintAttributes.CenterYWithinMargins)) {
|
||||||
attrs.append(.CenterYWithinMargins)
|
attrs.append(.centerYWithinMargins)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -174,12 +174,12 @@ internal func + (left: ConstraintAttributes, right: ConstraintAttributes) -> Con
|
||||||
return left.union(right)
|
return left.union(right)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func +=(inout left: ConstraintAttributes, right: ConstraintAttributes) {
|
internal func +=(left: inout ConstraintAttributes, right: ConstraintAttributes) {
|
||||||
left.unionInPlace(right)
|
left.formUnion(right)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func -=(inout left: ConstraintAttributes, right: ConstraintAttributes) {
|
internal func -=(left: inout ConstraintAttributes, right: ConstraintAttributes) {
|
||||||
left.subtractInPlace(right)
|
left.subtract(right)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func ==(left: ConstraintAttributes, right: ConstraintAttributes) -> Bool {
|
internal func ==(left: ConstraintAttributes, right: ConstraintAttributes) -> Bool {
|
||||||
|
|
|
@ -32,6 +32,6 @@
|
||||||
|
|
||||||
public struct ConstraintConfig {
|
public struct ConstraintConfig {
|
||||||
|
|
||||||
public static var interfaceLayoutDirection: ConstraintInterfaceLayoutDirection = .LeftToRight
|
public static var interfaceLayoutDirection: ConstraintInterfaceLayoutDirection = .leftToRight
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ extension ConstraintInsets: ConstraintConstantTarget {
|
||||||
|
|
||||||
extension ConstraintConstantTarget {
|
extension ConstraintConstantTarget {
|
||||||
|
|
||||||
internal func layoutConstantForLayoutAttribute(layoutAttribute: NSLayoutAttribute) -> CGFloat {
|
internal func layoutConstantForLayoutAttribute(_ layoutAttribute: NSLayoutAttribute) -> CGFloat {
|
||||||
if let value = self as? Float {
|
if let value = self as? Float {
|
||||||
return CGFloat(value)
|
return CGFloat(value)
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,9 @@ extension ConstraintConstantTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let value = self as? CGSize {
|
if let value = self as? CGSize {
|
||||||
if layoutAttribute == .Width {
|
if layoutAttribute == .width {
|
||||||
return value.width
|
return value.width
|
||||||
} else if layoutAttribute == .Height {
|
} else if layoutAttribute == .height {
|
||||||
return value.height
|
return value.height
|
||||||
} else {
|
} else {
|
||||||
return 0.0
|
return 0.0
|
||||||
|
@ -77,11 +77,11 @@ extension ConstraintConstantTarget {
|
||||||
if let value = self as? CGPoint {
|
if let value = self as? CGPoint {
|
||||||
#if os(iOS) || os(tvOS)
|
#if os(iOS) || os(tvOS)
|
||||||
switch layoutAttribute {
|
switch layoutAttribute {
|
||||||
case .Left, .Right, .Leading, .Trailing, .CenterX, .LeftMargin, .RightMargin, .LeadingMargin, .TrailingMargin, .CenterXWithinMargins:
|
case .left, .right, .leading, .trailing, .centerX, .leftMargin, .rightMargin, .leadingMargin, .trailingMargin, .centerXWithinMargins:
|
||||||
return value.x
|
return value.x
|
||||||
case .Top, .Bottom, .CenterY, .TopMargin, .BottomMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline:
|
case .top, .bottom, .centerY, .topMargin, .bottomMargin, .centerYWithinMargins, .lastBaseline, .firstBaseline:
|
||||||
return value.y
|
return value.y
|
||||||
case .Width, .Height, .NotAnAttribute:
|
case .width, .height, .notAnAttribute:
|
||||||
return 0.0
|
return 0.0
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -99,23 +99,23 @@ extension ConstraintConstantTarget {
|
||||||
if let value = self as? ConstraintInsets {
|
if let value = self as? ConstraintInsets {
|
||||||
#if os(iOS) || os(tvOS)
|
#if os(iOS) || os(tvOS)
|
||||||
switch layoutAttribute {
|
switch layoutAttribute {
|
||||||
case .Left, .LeftMargin, .CenterX, .CenterXWithinMargins:
|
case .left, .leftMargin, .centerX, .centerXWithinMargins:
|
||||||
return value.left
|
return value.left
|
||||||
case .Top, .TopMargin, .CenterY, .CenterYWithinMargins, .Baseline, .FirstBaseline:
|
case .top, .topMargin, .centerY, .centerYWithinMargins, .lastBaseline, .firstBaseline:
|
||||||
return value.top
|
return value.top
|
||||||
case .Right, .RightMargin:
|
case .right, .rightMargin:
|
||||||
return value.right
|
return value.right
|
||||||
case .Bottom, .BottomMargin:
|
case .bottom, .bottomMargin:
|
||||||
return value.bottom
|
return value.bottom
|
||||||
case .Leading, .LeadingMargin:
|
case .leading, .leadingMargin:
|
||||||
return (ConstraintConfig.interfaceLayoutDirection == .LeftToRight) ? value.left : -value.right
|
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : -value.right
|
||||||
case .Trailing, .TrailingMargin:
|
case .trailing, .trailingMargin:
|
||||||
return (ConstraintConfig.interfaceLayoutDirection == .LeftToRight) ? value.right : -value.left
|
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.right : -value.left
|
||||||
case .Width:
|
case .width:
|
||||||
return -value.left + value.right
|
return -value.left + value.right
|
||||||
case .Height:
|
case .height:
|
||||||
return -value.top + value.bottom
|
return -value.top + value.bottom
|
||||||
case .NotAnAttribute:
|
case .notAnAttribute:
|
||||||
return 0.0
|
return 0.0
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -145,4 +145,4 @@ extension ConstraintConstantTarget {
|
||||||
return 0.0
|
return 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,13 +129,13 @@ public class ConstraintMaker {
|
||||||
self.view.translatesAutoresizingMaskIntoConstraints = false
|
self.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func makeExtendableWithAttributes(attributes: ConstraintAttributes) -> ConstraintMakerExtendable {
|
internal func makeExtendableWithAttributes(_ attributes: ConstraintAttributes) -> ConstraintMakerExtendable {
|
||||||
let description = ConstraintDescription(view: self.view, attributes: attributes)
|
let description = ConstraintDescription(view: self.view, attributes: attributes)
|
||||||
self.descriptions.append(description)
|
self.descriptions.append(description)
|
||||||
return ConstraintMakerExtendable(description)
|
return ConstraintMakerExtendable(description)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static func prepareConstraints(view view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
internal static func prepareConstraints(view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
let maker = ConstraintMaker(view: view)
|
let maker = ConstraintMaker(view: view)
|
||||||
closure(make: maker)
|
closure(make: maker)
|
||||||
let constraints = maker.descriptions
|
let constraints = maker.descriptions
|
||||||
|
@ -145,7 +145,7 @@ public class ConstraintMaker {
|
||||||
return constraints
|
return constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static func makeConstraints(view view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
internal static func makeConstraints(view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
||||||
let maker = ConstraintMaker(view: view)
|
let maker = ConstraintMaker(view: view)
|
||||||
closure(make: maker)
|
closure(make: maker)
|
||||||
let constraints = maker.descriptions
|
let constraints = maker.descriptions
|
||||||
|
@ -157,12 +157,12 @@ public class ConstraintMaker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static func remakeConstraints(view view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
internal static func remakeConstraints(view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
||||||
self.removeConstraints(view: view)
|
self.removeConstraints(view: view)
|
||||||
self.makeConstraints(view: view, closure: closure)
|
self.makeConstraints(view: view, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static func updateConstraints(view view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
internal static func updateConstraints(view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
||||||
let maker = ConstraintMaker(view: view)
|
let maker = ConstraintMaker(view: view)
|
||||||
closure(make: maker)
|
closure(make: maker)
|
||||||
let constraints = maker.descriptions
|
let constraints = maker.descriptions
|
||||||
|
@ -174,7 +174,7 @@ public class ConstraintMaker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static func removeConstraints(view view: ConstraintView) {
|
internal static func removeConstraints(view: ConstraintView) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,21 +30,21 @@
|
||||||
|
|
||||||
public class ConstraintMakerEditable: ConstraintMakerPriortizable {
|
public class ConstraintMakerEditable: ConstraintMakerPriortizable {
|
||||||
|
|
||||||
public func multipliedBy(amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
||||||
self.description.multiplier = amount
|
self.description.multiplier = amount
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
public func dividedBy(amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
public func dividedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
||||||
return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue)
|
return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func offset(amount: ConstraintOffsetTarget) -> ConstraintMakerEditable {
|
public func offset(_ amount: ConstraintOffsetTarget) -> ConstraintMakerEditable {
|
||||||
self.description.constant = amount
|
self.description.constant = amount
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
public func inset(amount: ConstraintInsetTarget) -> ConstraintMakerEditable {
|
public func inset(_ amount: ConstraintInsetTarget) -> ConstraintMakerEditable {
|
||||||
let insets: ConstraintInsets
|
let insets: ConstraintInsets
|
||||||
|
|
||||||
if let amount = amount as? ConstraintInsets {
|
if let amount = amount as? ConstraintInsets {
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
public class ConstraintMakerPriortizable: ConstraintMakerFinalizable {
|
public class ConstraintMakerPriortizable: ConstraintMakerFinalizable {
|
||||||
|
|
||||||
public func priority(amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable {
|
public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable {
|
||||||
self.description.priority = amount
|
self.description.priority = amount
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class ConstraintMakerRelatable {
|
||||||
self.description = description
|
self.description = description
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func relatedTo(other: ConstraintRelatableTarget, relation: ConstraintRelation, file: String, line: UInt) -> ConstraintMakerEditable {
|
internal func relatedTo(_ other: ConstraintRelatableTarget, relation: ConstraintRelation, file: String, line: UInt) -> ConstraintMakerEditable {
|
||||||
let related: ConstraintItem
|
let related: ConstraintItem
|
||||||
let constant: ConstraintConstantTarget
|
let constant: ConstraintConstantTarget
|
||||||
|
|
||||||
|
@ -67,16 +67,16 @@ public class ConstraintMakerRelatable {
|
||||||
return editable
|
return editable
|
||||||
}
|
}
|
||||||
|
|
||||||
public func equalTo(other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
public func equalTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
return self.relatedTo(other, relation: .Equal, file: file, line: line)
|
return self.relatedTo(other, relation: .equal, file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func lessThanOrEqualTo(other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
public func lessThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
return self.relatedTo(other, relation: .LessThanOrEqual, file: file, line: line)
|
return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func greaterThanOrEqualTo(other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
public func greaterThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
return self.relatedTo(other, relation: .GreaterThanOrEqual, file: file, line: line)
|
return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,3 @@ extension CGFloat: ConstraintMultiplierTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func ==(lhs: ConstraintMultiplierTarget, rhs: ConstraintMultiplierTarget) -> Bool {
|
|
||||||
return lhs.constraintMultiplierTargetValue == rhs.constraintMultiplierTargetValue
|
|
||||||
}
|
|
||||||
|
|
|
@ -73,7 +73,3 @@ extension CGFloat: ConstraintPriorityTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func ==(lhs: ConstraintPriorityTarget, rhs: ConstraintPriorityTarget) -> Bool {
|
|
||||||
return lhs.constraintPriorityTargetValue == rhs.constraintPriorityTargetValue
|
|
||||||
}
|
|
||||||
|
|
|
@ -29,19 +29,19 @@
|
||||||
|
|
||||||
|
|
||||||
internal enum ConstraintRelation: Int {
|
internal enum ConstraintRelation: Int {
|
||||||
case Equal = 1
|
case equal = 1
|
||||||
case LessThanOrEqual
|
case lessThanOrEqual
|
||||||
case GreaterThanOrEqual
|
case greaterThanOrEqual
|
||||||
|
|
||||||
internal var layoutRelation: NSLayoutRelation {
|
internal var layoutRelation: NSLayoutRelation {
|
||||||
get {
|
get {
|
||||||
switch(self) {
|
switch(self) {
|
||||||
case .Equal:
|
case .equal:
|
||||||
return .Equal
|
return .equal
|
||||||
case .LessThanOrEqual:
|
case .lessThanOrEqual:
|
||||||
return .LessThanOrEqual
|
return .lessThanOrEqual
|
||||||
case .GreaterThanOrEqual:
|
case .greaterThanOrEqual:
|
||||||
return .GreaterThanOrEqual
|
return .greaterThanOrEqual
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,102 +30,102 @@
|
||||||
|
|
||||||
public extension ConstraintView {
|
public extension ConstraintView {
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_left: ConstraintItem { return self.snp.left }
|
public var snp_left: ConstraintItem { return self.snp.left }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_top: ConstraintItem { return self.snp.top }
|
public var snp_top: ConstraintItem { return self.snp.top }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_right: ConstraintItem { return self.snp.right }
|
public var snp_right: ConstraintItem { return self.snp.right }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_bottom: ConstraintItem { return self.snp.bottom }
|
public var snp_bottom: ConstraintItem { return self.snp.bottom }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_leading: ConstraintItem { return self.snp.leading }
|
public var snp_leading: ConstraintItem { return self.snp.leading }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_trailing: ConstraintItem { return self.snp.trailing }
|
public var snp_trailing: ConstraintItem { return self.snp.trailing }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_width: ConstraintItem { return self.snp.width }
|
public var snp_width: ConstraintItem { return self.snp.width }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_height: ConstraintItem { return self.snp.height }
|
public var snp_height: ConstraintItem { return self.snp.height }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_centerX: ConstraintItem { return self.snp.centerX }
|
public var snp_centerX: ConstraintItem { return self.snp.centerX }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_centerY: ConstraintItem { return self.snp.centerY }
|
public var snp_centerY: ConstraintItem { return self.snp.centerY }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_baseline: ConstraintItem { return self.snp.baseline }
|
public var snp_baseline: ConstraintItem { return self.snp.baseline }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline }
|
public var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_leftMargin: ConstraintItem { return self.snp.leftMargin }
|
public var snp_leftMargin: ConstraintItem { return self.snp.leftMargin }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_topMargin: ConstraintItem { return self.snp.topMargin }
|
public var snp_topMargin: ConstraintItem { return self.snp.topMargin }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_rightMargin: ConstraintItem { return self.snp.rightMargin }
|
public var snp_rightMargin: ConstraintItem { return self.snp.rightMargin }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin }
|
public var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin }
|
public var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin }
|
public var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins }
|
public var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins }
|
public var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_edges: ConstraintItem { return self.snp.edges }
|
public var snp_edges: ConstraintItem { return self.snp.edges }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_size: ConstraintItem { return self.snp.size }
|
public var snp_size: ConstraintItem { return self.snp.size }
|
||||||
|
|
||||||
@available(*, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(*, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_center: ConstraintItem { return self.snp.center }
|
public var snp_center: ConstraintItem { return self.snp.center }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_margins: ConstraintItem { return self.snp.margins }
|
public var snp_margins: ConstraintItem { return self.snp.margins }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins }
|
public var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins }
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public func snp_prepareConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
public func snp_prepareConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
return self.snp.prepareConstraints(closure: closure)
|
return self.snp.prepareConstraints(closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public func snp_makeConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
public func snp_makeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||||
self.snp.makeConstraints(closure: closure)
|
self.snp.makeConstraints(closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public func snp_remakeConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
public func snp_remakeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||||
self.snp.remakeConstraints(closure: closure)
|
self.snp.remakeConstraints(closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public func snp_updateConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
public func snp_updateConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||||
self.snp.updateConstraints(closure: closure)
|
self.snp.updateConstraints(closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public func snp_removeConstraints() {
|
public func snp_removeConstraints() {
|
||||||
self.snp.removeConstraints()
|
self.snp.removeConstraints()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,22 +27,22 @@
|
||||||
|
|
||||||
public extension ConstraintViewController {
|
public extension ConstraintViewController {
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var topLayoutGuideTop: ConstraintItem {
|
public var topLayoutGuideTop: ConstraintItem {
|
||||||
return self.snp.topLayoutGuideTop
|
return self.snp.topLayoutGuideTop
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var topLayoutGuideBottom: ConstraintItem {
|
public var topLayoutGuideBottom: ConstraintItem {
|
||||||
return self.snp.topLayoutGuideBottom
|
return self.snp.topLayoutGuideBottom
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var bottomLayoutGuideTop: ConstraintItem {
|
public var bottomLayoutGuideTop: ConstraintItem {
|
||||||
return self.snp.bottomLayoutGuideTop
|
return self.snp.bottomLayoutGuideTop
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||||
public var bottomLayoutGuideBottom: ConstraintItem {
|
public var bottomLayoutGuideBottom: ConstraintItem {
|
||||||
return self.snp.bottomLayoutGuideBottom
|
return self.snp.bottomLayoutGuideBottom
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,19 +141,19 @@ public struct ConstraintViewDSL {
|
||||||
return ConstraintItem(target: self.view, attributes: ConstraintAttributes.CenterWithinMargins)
|
return ConstraintItem(target: self.view, attributes: ConstraintAttributes.CenterWithinMargins)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func prepareConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
public func prepareConstraints(closure: @noescape (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
return ConstraintMaker.prepareConstraints(view: self.view, closure: closure)
|
return ConstraintMaker.prepareConstraints(view: self.view, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func makeConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
public func makeConstraints(closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||||
ConstraintMaker.makeConstraints(view: self.view, closure: closure)
|
ConstraintMaker.makeConstraints(view: self.view, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func remakeConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
public func remakeConstraints(closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||||
ConstraintMaker.remakeConstraints(view: self.view, closure: closure)
|
ConstraintMaker.remakeConstraints(view: self.view, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
public func updateConstraints(closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||||
ConstraintMaker.updateConstraints(view: self.view, closure: closure)
|
ConstraintMaker.updateConstraints(view: self.view, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,13 +180,13 @@ public struct ConstraintViewDSL {
|
||||||
return objc_getAssociatedObject(self.view, &installedLayoutConstraintsKey) as? [LayoutConstraint] ?? []
|
return objc_getAssociatedObject(self.view, &installedLayoutConstraintsKey) as? [LayoutConstraint] ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func appendInstalledLayoutConstraints(layoutConstraints: [LayoutConstraint]) {
|
internal func appendInstalledLayoutConstraints(_ layoutConstraints: [LayoutConstraint]) {
|
||||||
var newValue = self.installedLayoutConstraints
|
var newValue = self.installedLayoutConstraints
|
||||||
newValue += layoutConstraints
|
newValue += layoutConstraints
|
||||||
objc_setAssociatedObject(self.view, &installedLayoutConstraintsKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
objc_setAssociatedObject(self.view, &installedLayoutConstraintsKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func removeInstalledLayoutConstraints(layoutConstraints: [LayoutConstraint]) {
|
internal func removeInstalledLayoutConstraints(_ layoutConstraints: [LayoutConstraint]) {
|
||||||
let newValue = self.installedLayoutConstraints.filter { !layoutConstraints.contains($0) }
|
let newValue = self.installedLayoutConstraints.filter { !layoutConstraints.contains($0) }
|
||||||
objc_setAssociatedObject(self.view, &installedLayoutConstraintsKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
objc_setAssociatedObject(self.view, &installedLayoutConstraintsKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public extension LayoutConstraint {
|
||||||
description += descriptionForObject(self)
|
description += descriptionForObject(self)
|
||||||
|
|
||||||
description += " \(descriptionForObject(self.firstItem))"
|
description += " \(descriptionForObject(self.firstItem))"
|
||||||
if self.firstAttribute != .NotAnAttribute {
|
if self.firstAttribute != .notAnAttribute {
|
||||||
description += ".\(descriptionForAttribute(self.firstAttribute))"
|
description += ".\(descriptionForAttribute(self.firstAttribute))"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public extension LayoutConstraint {
|
||||||
description += " \(descriptionForObject(secondItem))"
|
description += " \(descriptionForObject(secondItem))"
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.secondAttribute != .NotAnAttribute {
|
if self.secondAttribute != .notAnAttribute {
|
||||||
description += ".\(descriptionForAttribute(self.secondAttribute))"
|
description += ".\(descriptionForAttribute(self.secondAttribute))"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public extension LayoutConstraint {
|
||||||
description += " * \(self.multiplier)"
|
description += " * \(self.multiplier)"
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.secondAttribute == .NotAnAttribute {
|
if self.secondAttribute == .notAnAttribute {
|
||||||
description += " \(self.constant)"
|
description += " \(self.constant)"
|
||||||
} else {
|
} else {
|
||||||
if self.constant > 0.0 {
|
if self.constant > 0.0 {
|
||||||
|
@ -74,38 +74,38 @@ public extension LayoutConstraint {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func descriptionForRelation(relation: NSLayoutRelation) -> String {
|
private func descriptionForRelation(_ relation: NSLayoutRelation) -> String {
|
||||||
switch relation {
|
switch relation {
|
||||||
case .Equal: return "=="
|
case .equal: return "=="
|
||||||
case .GreaterThanOrEqual: return ">="
|
case .greaterThanOrEqual: return ">="
|
||||||
case .LessThanOrEqual: return "<="
|
case .lessThanOrEqual: return "<="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func descriptionForAttribute(attribute: NSLayoutAttribute) -> String {
|
private func descriptionForAttribute(_ attribute: NSLayoutAttribute) -> String {
|
||||||
#if os(iOS) || os(tvOS)
|
#if os(iOS) || os(tvOS)
|
||||||
switch attribute {
|
switch attribute {
|
||||||
case .NotAnAttribute: return "notAnAttribute"
|
case .notAnAttribute: return "notAnAttribute"
|
||||||
case .Top: return "top"
|
case .top: return "top"
|
||||||
case .Left: return "left"
|
case .left: return "left"
|
||||||
case .Bottom: return "bottom"
|
case .bottom: return "bottom"
|
||||||
case .Right: return "right"
|
case .right: return "right"
|
||||||
case .Leading: return "leading"
|
case .leading: return "leading"
|
||||||
case .Trailing: return "trailing"
|
case .trailing: return "trailing"
|
||||||
case .Width: return "width"
|
case .width: return "width"
|
||||||
case .Height: return "height"
|
case .height: return "height"
|
||||||
case .CenterX: return "centerX"
|
case .centerX: return "centerX"
|
||||||
case .CenterY: return "centerY"
|
case .centerY: return "centerY"
|
||||||
case .Baseline: return "baseline"
|
case .lastBaseline: return "baseline"
|
||||||
case .FirstBaseline: return "firstBaseline"
|
case .firstBaseline: return "firstBaseline"
|
||||||
case .TopMargin: return "topMargin"
|
case .topMargin: return "topMargin"
|
||||||
case .LeftMargin: return "leftMargin"
|
case .leftMargin: return "leftMargin"
|
||||||
case .BottomMargin: return "bottomMargin"
|
case .bottomMargin: return "bottomMargin"
|
||||||
case .RightMargin: return "rightMargin"
|
case .rightMargin: return "rightMargin"
|
||||||
case .LeadingMargin: return "leadingMargin"
|
case .leadingMargin: return "leadingMargin"
|
||||||
case .TrailingMargin: return "trailingMargin"
|
case .trailingMargin: return "trailingMargin"
|
||||||
case .CenterXWithinMargins: return "centerXWithinMargins"
|
case .centerXWithinMargins: return "centerXWithinMargins"
|
||||||
case .CenterYWithinMargins: return "centerYWithinMargins"
|
case .centerYWithinMargins: return "centerYWithinMargins"
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
switch attribute {
|
switch attribute {
|
||||||
|
@ -126,8 +126,8 @@ private func descriptionForAttribute(attribute: NSLayoutAttribute) -> String {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private func descriptionForObject(object: AnyObject) -> String {
|
private func descriptionForObject(_ object: AnyObject) -> String {
|
||||||
let pointerDescription = NSString(format: "%p", ObjectIdentifier(object).uintValue)
|
let pointerDescription = NSString(format: "%p", UInt(ObjectIdentifier(object)))
|
||||||
var desc = ""
|
var desc = ""
|
||||||
|
|
||||||
desc += object.dynamicType.description()
|
desc += object.dynamicType.description()
|
||||||
|
@ -146,4 +146,4 @@ private func descriptionForObject(object: AnyObject) -> String {
|
||||||
|
|
||||||
desc += ""
|
desc += ""
|
||||||
return desc
|
return desc
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue