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|
|
||||
s.name = 'SnapKit'
|
||||
s.version = '0.30.0.beta1'
|
||||
s.version = '0.40.0.beta1'
|
||||
s.license = 'MIT'
|
||||
s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.'
|
||||
s.homepage = 'https://github.com/SnapKit/SnapKit'
|
||||
s.authors = { 'Robert Payne' => 'robertpayne@me.com' }
|
||||
s.social_media_url = 'http://twitter.com/robertjpayne'
|
||||
s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '0.30.0.beta1' }
|
||||
s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '0.40.0.beta1' }
|
||||
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.10'
|
||||
|
|
|
@ -495,15 +495,18 @@
|
|||
TargetAttributes = {
|
||||
537DCE911C35CC8800B5B899 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
537DCEAE1C35D90A00B5B899 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
};
|
||||
EEBCC9D719CC627D0083B827 = {
|
||||
CreatedOnToolsVersion = 6.0;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
EEBCC9E119CC627D0083B827 = {
|
||||
CreatedOnToolsVersion = 6.0;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
EECDB3791AC0C9D4006BBC11 = {
|
||||
CreatedOnToolsVersion = 6.2;
|
||||
|
@ -741,6 +744,7 @@
|
|||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
|
@ -767,6 +771,7 @@
|
|||
PRODUCT_NAME = SnapKit;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 3.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
|
@ -903,6 +908,7 @@
|
|||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -925,6 +931,7 @@
|
|||
PRODUCT_NAME = SnapKit;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||
SWIFT_VERSION = 3.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -938,6 +945,7 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -949,6 +957,7 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
@ -80,7 +80,7 @@ public class Constraint {
|
|||
|
||||
// MARK: Internal
|
||||
|
||||
internal func installIfNeeded(updateExisting updateExisting: Bool = false) -> [NSLayoutConstraint] {
|
||||
internal func installIfNeeded(updateExisting: Bool = false) -> [NSLayoutConstraint] {
|
||||
let installOnView: ConstraintView?
|
||||
|
||||
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))")
|
||||
}
|
||||
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
|
||||
} else {
|
||||
guard let superview = self.from.view?.superview else {
|
||||
|
@ -128,7 +128,7 @@ public class Constraint {
|
|||
#else
|
||||
var layoutTo: AnyObject? = self.to.view
|
||||
#endif
|
||||
if layoutTo == nil && layoutToAttribute != .Width && layoutToAttribute != .Height {
|
||||
if layoutTo == nil && layoutToAttribute != .width && layoutToAttribute != .height {
|
||||
layoutTo = installOnView
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class Constraint {
|
|||
if updateExisting {
|
||||
|
||||
// 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
|
||||
var newLayoutConstraintsToKeep = [LayoutConstraint]()
|
||||
|
@ -197,15 +197,15 @@ public class Constraint {
|
|||
installOnView?.addConstraints(newLayoutConstraints)
|
||||
}
|
||||
#else
|
||||
NSLayoutConstraint.activateConstraints(newLayoutConstraints)
|
||||
NSLayoutConstraint.activate(newLayoutConstraints)
|
||||
#endif
|
||||
|
||||
// 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
|
||||
for layoutConstraint in newLayoutConstraints {
|
||||
self.installInfo!.layoutConstraints.addObject(layoutConstraint)
|
||||
self.installInfo!.layoutConstraints.add(layoutConstraint)
|
||||
}
|
||||
|
||||
// store the layout constraints against the layout from view
|
||||
|
@ -231,7 +231,7 @@ public class Constraint {
|
|||
installedOnView.removeConstraints(installedLayoutConstraints)
|
||||
}
|
||||
#else
|
||||
NSLayoutConstraint.deactivateConstraints(installedLayoutConstraints)
|
||||
NSLayoutConstraint.deactivate(installedLayoutConstraints)
|
||||
#endif
|
||||
|
||||
// remove the constraints from the from item view
|
||||
|
@ -255,7 +255,7 @@ public class Constraint {
|
|||
return
|
||||
}
|
||||
|
||||
NSLayoutConstraint.activateConstraints(layoutConstraints)
|
||||
NSLayoutConstraint.activate(layoutConstraints)
|
||||
}
|
||||
|
||||
internal func deactivateIfNeeded() {
|
||||
|
@ -270,7 +270,7 @@ public class Constraint {
|
|||
return
|
||||
}
|
||||
|
||||
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
|
||||
NSLayoutConstraint.deactivate(layoutConstraints)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -278,16 +278,16 @@ public class Constraint {
|
|||
private final class ConstraintInstallInfo {
|
||||
|
||||
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.layoutConstraints = layoutConstraints
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private func closestCommonSuperviewFromView(fromView: ConstraintView?, toView: ConstraintView?) -> ConstraintView? {
|
||||
private func closestCommonSuperviewFromView(_ fromView: ConstraintView?, toView: ConstraintView?) -> ConstraintView? {
|
||||
var views = Set<ConstraintView>()
|
||||
var fromView = fromView
|
||||
var toView = toView
|
||||
|
@ -315,6 +315,6 @@ private func ==(lhs: Constraint, rhs: Constraint) -> Bool {
|
|||
return (lhs.from == rhs.from &&
|
||||
lhs.to == rhs.to &&
|
||||
lhs.relation == rhs.relation &&
|
||||
lhs.multiplier == rhs.multiplier &&
|
||||
lhs.priority == rhs.priority)
|
||||
lhs.multiplier.constraintMultiplierTargetValue == rhs.multiplier.constraintMultiplierTargetValue &&
|
||||
lhs.priority.constraintPriorityTargetValue == rhs.priority.constraintPriorityTargetValue)
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
||||
internal struct ConstraintAttributes: OptionSet, Boolean {
|
||||
|
||||
internal init(rawValue: UInt) {
|
||||
self.rawValue = rawValue
|
||||
|
@ -46,8 +46,8 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
|||
internal var boolValue: Bool { return self.rawValue != 0 }
|
||||
|
||||
internal func toRaw() -> UInt { return self.rawValue }
|
||||
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 fromRaw(_ raw: UInt) -> ConstraintAttributes? { return self.init(raw) }
|
||||
internal static func fromMask(_ raw: UInt) -> ConstraintAttributes { return self.init(raw) }
|
||||
|
||||
// normal
|
||||
|
||||
|
@ -98,37 +98,37 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
|||
internal var layoutAttributes:[NSLayoutAttribute] {
|
||||
var attrs = [NSLayoutAttribute]()
|
||||
if (self.contains(ConstraintAttributes.Left)) {
|
||||
attrs.append(.Left)
|
||||
attrs.append(.left)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.Top)) {
|
||||
attrs.append(.Top)
|
||||
attrs.append(.top)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.Right)) {
|
||||
attrs.append(.Right)
|
||||
attrs.append(.right)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.Bottom)) {
|
||||
attrs.append(.Bottom)
|
||||
attrs.append(.bottom)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.Leading)) {
|
||||
attrs.append(.Leading)
|
||||
attrs.append(.leading)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.Trailing)) {
|
||||
attrs.append(.Trailing)
|
||||
attrs.append(.trailing)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.Width)) {
|
||||
attrs.append(.Width)
|
||||
attrs.append(.width)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.Height)) {
|
||||
attrs.append(.Height)
|
||||
attrs.append(.height)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.CenterX)) {
|
||||
attrs.append(.CenterX)
|
||||
attrs.append(.centerX)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.CenterY)) {
|
||||
attrs.append(.CenterY)
|
||||
attrs.append(.centerY)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.Baseline)) {
|
||||
attrs.append(.Baseline)
|
||||
attrs.append(.lastBaseline)
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
|
@ -138,31 +138,31 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
|||
}
|
||||
#endif
|
||||
if (self.contains(ConstraintAttributes.FirstBaseline)) {
|
||||
attrs.append(.FirstBaseline)
|
||||
attrs.append(.firstBaseline)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.LeftMargin)) {
|
||||
attrs.append(.LeftMargin)
|
||||
attrs.append(.leftMargin)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.RightMargin)) {
|
||||
attrs.append(.RightMargin)
|
||||
attrs.append(.rightMargin)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.TopMargin)) {
|
||||
attrs.append(.TopMargin)
|
||||
attrs.append(.topMargin)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.BottomMargin)) {
|
||||
attrs.append(.BottomMargin)
|
||||
attrs.append(.bottomMargin)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.LeadingMargin)) {
|
||||
attrs.append(.LeadingMargin)
|
||||
attrs.append(.leadingMargin)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.TrailingMargin)) {
|
||||
attrs.append(.TrailingMargin)
|
||||
attrs.append(.trailingMargin)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.CenterXWithinMargins)) {
|
||||
attrs.append(.CenterXWithinMargins)
|
||||
attrs.append(.centerXWithinMargins)
|
||||
}
|
||||
if (self.contains(ConstraintAttributes.CenterYWithinMargins)) {
|
||||
attrs.append(.CenterYWithinMargins)
|
||||
attrs.append(.centerYWithinMargins)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -174,12 +174,12 @@ internal func + (left: ConstraintAttributes, right: ConstraintAttributes) -> Con
|
|||
return left.union(right)
|
||||
}
|
||||
|
||||
internal func +=(inout left: ConstraintAttributes, right: ConstraintAttributes) {
|
||||
left.unionInPlace(right)
|
||||
internal func +=(left: inout ConstraintAttributes, right: ConstraintAttributes) {
|
||||
left.formUnion(right)
|
||||
}
|
||||
|
||||
internal func -=(inout left: ConstraintAttributes, right: ConstraintAttributes) {
|
||||
left.subtractInPlace(right)
|
||||
internal func -=(left: inout ConstraintAttributes, right: ConstraintAttributes) {
|
||||
left.subtract(right)
|
||||
}
|
||||
|
||||
internal func ==(left: ConstraintAttributes, right: ConstraintAttributes) -> Bool {
|
||||
|
|
|
@ -32,6 +32,6 @@
|
|||
|
||||
public struct ConstraintConfig {
|
||||
|
||||
public static var interfaceLayoutDirection: ConstraintInterfaceLayoutDirection = .LeftToRight
|
||||
public static var interfaceLayoutDirection: ConstraintInterfaceLayoutDirection = .leftToRight
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ extension ConstraintInsets: ConstraintConstantTarget {
|
|||
|
||||
extension ConstraintConstantTarget {
|
||||
|
||||
internal func layoutConstantForLayoutAttribute(layoutAttribute: NSLayoutAttribute) -> CGFloat {
|
||||
internal func layoutConstantForLayoutAttribute(_ layoutAttribute: NSLayoutAttribute) -> CGFloat {
|
||||
if let value = self as? Float {
|
||||
return CGFloat(value)
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ extension ConstraintConstantTarget {
|
|||
}
|
||||
|
||||
if let value = self as? CGSize {
|
||||
if layoutAttribute == .Width {
|
||||
if layoutAttribute == .width {
|
||||
return value.width
|
||||
} else if layoutAttribute == .Height {
|
||||
} else if layoutAttribute == .height {
|
||||
return value.height
|
||||
} else {
|
||||
return 0.0
|
||||
|
@ -77,11 +77,11 @@ extension ConstraintConstantTarget {
|
|||
if let value = self as? CGPoint {
|
||||
#if os(iOS) || os(tvOS)
|
||||
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
|
||||
case .Top, .Bottom, .CenterY, .TopMargin, .BottomMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline:
|
||||
case .top, .bottom, .centerY, .topMargin, .bottomMargin, .centerYWithinMargins, .lastBaseline, .firstBaseline:
|
||||
return value.y
|
||||
case .Width, .Height, .NotAnAttribute:
|
||||
case .width, .height, .notAnAttribute:
|
||||
return 0.0
|
||||
}
|
||||
#else
|
||||
|
@ -99,23 +99,23 @@ extension ConstraintConstantTarget {
|
|||
if let value = self as? ConstraintInsets {
|
||||
#if os(iOS) || os(tvOS)
|
||||
switch layoutAttribute {
|
||||
case .Left, .LeftMargin, .CenterX, .CenterXWithinMargins:
|
||||
case .left, .leftMargin, .centerX, .centerXWithinMargins:
|
||||
return value.left
|
||||
case .Top, .TopMargin, .CenterY, .CenterYWithinMargins, .Baseline, .FirstBaseline:
|
||||
case .top, .topMargin, .centerY, .centerYWithinMargins, .lastBaseline, .firstBaseline:
|
||||
return value.top
|
||||
case .Right, .RightMargin:
|
||||
case .right, .rightMargin:
|
||||
return value.right
|
||||
case .Bottom, .BottomMargin:
|
||||
case .bottom, .bottomMargin:
|
||||
return value.bottom
|
||||
case .Leading, .LeadingMargin:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .LeftToRight) ? value.left : -value.right
|
||||
case .Trailing, .TrailingMargin:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .LeftToRight) ? value.right : -value.left
|
||||
case .Width:
|
||||
case .leading, .leadingMargin:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : -value.right
|
||||
case .trailing, .trailingMargin:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.right : -value.left
|
||||
case .width:
|
||||
return -value.left + value.right
|
||||
case .Height:
|
||||
case .height:
|
||||
return -value.top + value.bottom
|
||||
case .NotAnAttribute:
|
||||
case .notAnAttribute:
|
||||
return 0.0
|
||||
}
|
||||
#else
|
||||
|
@ -145,4 +145,4 @@ extension ConstraintConstantTarget {
|
|||
return 0.0
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,13 +129,13 @@ public class ConstraintMaker {
|
|||
self.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
|
||||
internal func makeExtendableWithAttributes(attributes: ConstraintAttributes) -> ConstraintMakerExtendable {
|
||||
internal func makeExtendableWithAttributes(_ attributes: ConstraintAttributes) -> ConstraintMakerExtendable {
|
||||
let description = ConstraintDescription(view: self.view, attributes: attributes)
|
||||
self.descriptions.append(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)
|
||||
closure(make: maker)
|
||||
let constraints = maker.descriptions
|
||||
|
@ -145,7 +145,7 @@ public class ConstraintMaker {
|
|||
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)
|
||||
closure(make: maker)
|
||||
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.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)
|
||||
closure(make: maker)
|
||||
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 func multipliedBy(amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
||||
public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
||||
self.description.multiplier = amount
|
||||
return self
|
||||
}
|
||||
|
||||
public func dividedBy(amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
||||
public func dividedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
||||
return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue)
|
||||
}
|
||||
|
||||
public func offset(amount: ConstraintOffsetTarget) -> ConstraintMakerEditable {
|
||||
public func offset(_ amount: ConstraintOffsetTarget) -> ConstraintMakerEditable {
|
||||
self.description.constant = amount
|
||||
return self
|
||||
}
|
||||
|
||||
public func inset(amount: ConstraintInsetTarget) -> ConstraintMakerEditable {
|
||||
public func inset(_ amount: ConstraintInsetTarget) -> ConstraintMakerEditable {
|
||||
let insets: ConstraintInsets
|
||||
|
||||
if let amount = amount as? ConstraintInsets {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
public class ConstraintMakerPriortizable: ConstraintMakerFinalizable {
|
||||
|
||||
public func priority(amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable {
|
||||
public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable {
|
||||
self.description.priority = amount
|
||||
return self
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ConstraintMakerRelatable {
|
|||
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 constant: ConstraintConstantTarget
|
||||
|
||||
|
@ -67,16 +67,16 @@ public class ConstraintMakerRelatable {
|
|||
return editable
|
||||
}
|
||||
|
||||
public func equalTo(other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||
return self.relatedTo(other, relation: .Equal, file: file, line: line)
|
||||
public func equalTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||
return self.relatedTo(other, relation: .equal, file: file, line: line)
|
||||
}
|
||||
|
||||
public func lessThanOrEqualTo(other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||
return self.relatedTo(other, relation: .LessThanOrEqual, file: file, line: line)
|
||||
public func lessThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||
return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line)
|
||||
}
|
||||
|
||||
public func greaterThanOrEqualTo(other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
||||
return self.relatedTo(other, relation: .GreaterThanOrEqual, file: file, line: line)
|
||||
public func greaterThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
||||
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 {
|
||||
case Equal = 1
|
||||
case LessThanOrEqual
|
||||
case GreaterThanOrEqual
|
||||
case equal = 1
|
||||
case lessThanOrEqual
|
||||
case greaterThanOrEqual
|
||||
|
||||
internal var layoutRelation: NSLayoutRelation {
|
||||
get {
|
||||
switch(self) {
|
||||
case .Equal:
|
||||
return .Equal
|
||||
case .LessThanOrEqual:
|
||||
return .LessThanOrEqual
|
||||
case .GreaterThanOrEqual:
|
||||
return .GreaterThanOrEqual
|
||||
case .equal:
|
||||
return .equal
|
||||
case .lessThanOrEqual:
|
||||
return .lessThanOrEqual
|
||||
case .greaterThanOrEqual:
|
||||
return .greaterThanOrEqual
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,102 +30,102 @@
|
|||
|
||||
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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@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 }
|
||||
|
||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
||||
public func snp_prepareConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
public func snp_prepareConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
return self.snp.prepareConstraints(closure: closure)
|
||||
}
|
||||
|
||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
||||
public func snp_makeConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
public func snp_makeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
self.snp.makeConstraints(closure: closure)
|
||||
}
|
||||
|
||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
||||
public func snp_remakeConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
public func snp_remakeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
self.snp.remakeConstraints(closure: closure)
|
||||
}
|
||||
|
||||
@available(iOS, deprecated=0.30.0, message="Please use newer snp.* syntax.")
|
||||
public func snp_updateConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
public func snp_updateConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
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() {
|
||||
self.snp.removeConstraints()
|
||||
}
|
||||
|
|
|
@ -27,22 +27,22 @@
|
|||
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
return self.snp.bottomLayoutGuideBottom
|
||||
}
|
||||
|
|
|
@ -141,19 +141,19 @@ public struct ConstraintViewDSL {
|
|||
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)
|
||||
}
|
||||
|
||||
public func makeConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
||||
public func makeConstraints(closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||
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)
|
||||
}
|
||||
|
||||
public func updateConstraints(@noescape closure closure: (make: ConstraintMaker) -> Void) {
|
||||
public func updateConstraints(closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||
ConstraintMaker.updateConstraints(view: self.view, closure: closure)
|
||||
}
|
||||
|
||||
|
@ -180,13 +180,13 @@ public struct ConstraintViewDSL {
|
|||
return objc_getAssociatedObject(self.view, &installedLayoutConstraintsKey) as? [LayoutConstraint] ?? []
|
||||
}
|
||||
|
||||
internal func appendInstalledLayoutConstraints(layoutConstraints: [LayoutConstraint]) {
|
||||
internal func appendInstalledLayoutConstraints(_ layoutConstraints: [LayoutConstraint]) {
|
||||
var newValue = self.installedLayoutConstraints
|
||||
newValue += layoutConstraints
|
||||
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) }
|
||||
objc_setAssociatedObject(self.view, &installedLayoutConstraintsKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public extension LayoutConstraint {
|
|||
description += descriptionForObject(self)
|
||||
|
||||
description += " \(descriptionForObject(self.firstItem))"
|
||||
if self.firstAttribute != .NotAnAttribute {
|
||||
if self.firstAttribute != .notAnAttribute {
|
||||
description += ".\(descriptionForAttribute(self.firstAttribute))"
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public extension LayoutConstraint {
|
|||
description += " \(descriptionForObject(secondItem))"
|
||||
}
|
||||
|
||||
if self.secondAttribute != .NotAnAttribute {
|
||||
if self.secondAttribute != .notAnAttribute {
|
||||
description += ".\(descriptionForAttribute(self.secondAttribute))"
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public extension LayoutConstraint {
|
|||
description += " * \(self.multiplier)"
|
||||
}
|
||||
|
||||
if self.secondAttribute == .NotAnAttribute {
|
||||
if self.secondAttribute == .notAnAttribute {
|
||||
description += " \(self.constant)"
|
||||
} else {
|
||||
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 {
|
||||
case .Equal: return "=="
|
||||
case .GreaterThanOrEqual: return ">="
|
||||
case .LessThanOrEqual: return "<="
|
||||
case .equal: return "=="
|
||||
case .greaterThanOrEqual: return ">="
|
||||
case .lessThanOrEqual: return "<="
|
||||
}
|
||||
}
|
||||
|
||||
private func descriptionForAttribute(attribute: NSLayoutAttribute) -> String {
|
||||
private func descriptionForAttribute(_ attribute: NSLayoutAttribute) -> String {
|
||||
#if os(iOS) || os(tvOS)
|
||||
switch attribute {
|
||||
case .NotAnAttribute: return "notAnAttribute"
|
||||
case .Top: return "top"
|
||||
case .Left: return "left"
|
||||
case .Bottom: return "bottom"
|
||||
case .Right: return "right"
|
||||
case .Leading: return "leading"
|
||||
case .Trailing: return "trailing"
|
||||
case .Width: return "width"
|
||||
case .Height: return "height"
|
||||
case .CenterX: return "centerX"
|
||||
case .CenterY: return "centerY"
|
||||
case .Baseline: return "baseline"
|
||||
case .FirstBaseline: return "firstBaseline"
|
||||
case .TopMargin: return "topMargin"
|
||||
case .LeftMargin: return "leftMargin"
|
||||
case .BottomMargin: return "bottomMargin"
|
||||
case .RightMargin: return "rightMargin"
|
||||
case .LeadingMargin: return "leadingMargin"
|
||||
case .TrailingMargin: return "trailingMargin"
|
||||
case .CenterXWithinMargins: return "centerXWithinMargins"
|
||||
case .CenterYWithinMargins: return "centerYWithinMargins"
|
||||
case .notAnAttribute: return "notAnAttribute"
|
||||
case .top: return "top"
|
||||
case .left: return "left"
|
||||
case .bottom: return "bottom"
|
||||
case .right: return "right"
|
||||
case .leading: return "leading"
|
||||
case .trailing: return "trailing"
|
||||
case .width: return "width"
|
||||
case .height: return "height"
|
||||
case .centerX: return "centerX"
|
||||
case .centerY: return "centerY"
|
||||
case .lastBaseline: return "baseline"
|
||||
case .firstBaseline: return "firstBaseline"
|
||||
case .topMargin: return "topMargin"
|
||||
case .leftMargin: return "leftMargin"
|
||||
case .bottomMargin: return "bottomMargin"
|
||||
case .rightMargin: return "rightMargin"
|
||||
case .leadingMargin: return "leadingMargin"
|
||||
case .trailingMargin: return "trailingMargin"
|
||||
case .centerXWithinMargins: return "centerXWithinMargins"
|
||||
case .centerYWithinMargins: return "centerYWithinMargins"
|
||||
}
|
||||
#else
|
||||
switch attribute {
|
||||
|
@ -126,8 +126,8 @@ private func descriptionForAttribute(attribute: NSLayoutAttribute) -> String {
|
|||
#endif
|
||||
}
|
||||
|
||||
private func descriptionForObject(object: AnyObject) -> String {
|
||||
let pointerDescription = NSString(format: "%p", ObjectIdentifier(object).uintValue)
|
||||
private func descriptionForObject(_ object: AnyObject) -> String {
|
||||
let pointerDescription = NSString(format: "%p", UInt(ObjectIdentifier(object)))
|
||||
var desc = ""
|
||||
|
||||
desc += object.dynamicType.description()
|
||||
|
@ -146,4 +146,4 @@ private func descriptionForObject(object: AnyObject) -> String {
|
|||
|
||||
desc += ""
|
||||
return desc
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue