mirror of https://github.com/SnapKit/SnapKit
Removed 'final' declaration in attempt to fix odd crashes
This commit is contained in:
parent
02602258d6
commit
57baa96dc7
|
@ -63,7 +63,7 @@ public class Constraint {
|
||||||
/**
|
/**
|
||||||
Used internally to implement a ConcreteConstraint
|
Used internally to implement a ConcreteConstraint
|
||||||
*/
|
*/
|
||||||
final internal class ConcreteConstraint: Constraint {
|
internal class ConcreteConstraint: Constraint {
|
||||||
|
|
||||||
internal override func updateOffset(amount: Float) -> Void {
|
internal override func updateOffset(amount: Float) -> Void {
|
||||||
self.constant = amount
|
self.constant = amount
|
||||||
|
|
|
@ -163,7 +163,7 @@ public protocol ConstraintDescriptionExtendable: ConstraintDescriptionRelatable
|
||||||
/**
|
/**
|
||||||
Used to internally manage building constraint
|
Used to internally manage building constraint
|
||||||
*/
|
*/
|
||||||
final internal class ConstraintDescription: ConstraintDescriptionExtendable, ConstraintDescriptionEditable, ConstraintDescriptionFinalizable {
|
internal class ConstraintDescription: ConstraintDescriptionExtendable, ConstraintDescriptionEditable, ConstraintDescriptionFinalizable {
|
||||||
|
|
||||||
internal var left: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Left) }
|
internal var left: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Left) }
|
||||||
internal var top: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Top) }
|
internal var top: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Top) }
|
||||||
|
|
|
@ -30,7 +30,7 @@ import AppKit
|
||||||
/**
|
/**
|
||||||
Used to assist in building a constraint
|
Used to assist in building a constraint
|
||||||
*/
|
*/
|
||||||
final public class ConstraintItem {
|
public class ConstraintItem {
|
||||||
|
|
||||||
internal init(object: AnyObject?, attributes: ConstraintAttributes) {
|
internal init(object: AnyObject?, attributes: ConstraintAttributes) {
|
||||||
self.object = object
|
self.object = object
|
||||||
|
|
|
@ -30,7 +30,7 @@ import AppKit
|
||||||
/**
|
/**
|
||||||
Used to make constraints
|
Used to make constraints
|
||||||
*/
|
*/
|
||||||
final public class ConstraintMaker {
|
public class ConstraintMaker {
|
||||||
|
|
||||||
/// left edge
|
/// left edge
|
||||||
public var left: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Left) }
|
public var left: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Left) }
|
||||||
|
|
|
@ -30,7 +30,7 @@ import AppKit
|
||||||
/**
|
/**
|
||||||
Used to add extra information to the actual `NSLayoutConstraint`'s that will UIKit/AppKit will utilize
|
Used to add extra information to the actual `NSLayoutConstraint`'s that will UIKit/AppKit will utilize
|
||||||
*/
|
*/
|
||||||
final public class LayoutConstraint: NSLayoutConstraint {
|
public class LayoutConstraint: NSLayoutConstraint {
|
||||||
|
|
||||||
internal var snp_constraint: Constraint? = nil
|
internal var snp_constraint: Constraint? = nil
|
||||||
|
|
||||||
|
|
|
@ -35,85 +35,85 @@ public typealias View = NSView
|
||||||
public extension View {
|
public extension View {
|
||||||
|
|
||||||
/// left edge
|
/// left edge
|
||||||
final public var snp_left: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Left) }
|
public var snp_left: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Left) }
|
||||||
|
|
||||||
/// top edge
|
/// top edge
|
||||||
final public var snp_top: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Top) }
|
public var snp_top: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Top) }
|
||||||
|
|
||||||
/// right edge
|
/// right edge
|
||||||
final public var snp_right: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Right) }
|
public var snp_right: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Right) }
|
||||||
|
|
||||||
/// bottom edge
|
/// bottom edge
|
||||||
final public var snp_bottom: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Bottom) }
|
public var snp_bottom: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Bottom) }
|
||||||
|
|
||||||
/// leading edge
|
/// leading edge
|
||||||
final public var snp_leading: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Leading) }
|
public var snp_leading: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Leading) }
|
||||||
|
|
||||||
/// trailing edge
|
/// trailing edge
|
||||||
final public var snp_trailing: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Trailing) }
|
public var snp_trailing: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Trailing) }
|
||||||
|
|
||||||
/// width dimension
|
/// width dimension
|
||||||
final public var snp_width: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Width) }
|
public var snp_width: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Width) }
|
||||||
|
|
||||||
/// height dimension
|
/// height dimension
|
||||||
final public var snp_height: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Height) }
|
public var snp_height: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Height) }
|
||||||
|
|
||||||
/// centerX position
|
/// centerX position
|
||||||
final public var snp_centerX: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterX) }
|
public var snp_centerX: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterX) }
|
||||||
|
|
||||||
/// centerY position
|
/// centerY position
|
||||||
final public var snp_centerY: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterY) }
|
public var snp_centerY: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterY) }
|
||||||
|
|
||||||
/// baseline position
|
/// baseline position
|
||||||
final public var snp_baseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Baseline) }
|
public var snp_baseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Baseline) }
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
|
|
||||||
/// first baseline position
|
/// first baseline position
|
||||||
final public var snp_firstBaseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.FirstBaseline) }
|
public var snp_firstBaseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.FirstBaseline) }
|
||||||
|
|
||||||
/// left margin
|
/// left margin
|
||||||
final public var snp_leftMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeftMargin) }
|
public var snp_leftMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeftMargin) }
|
||||||
|
|
||||||
/// right margin
|
/// right margin
|
||||||
final public var snp_rightMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.RightMargin) }
|
public var snp_rightMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.RightMargin) }
|
||||||
|
|
||||||
/// top margin
|
/// top margin
|
||||||
final public var snp_topMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TopMargin) }
|
public var snp_topMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TopMargin) }
|
||||||
|
|
||||||
/// bottom margin
|
/// bottom margin
|
||||||
final public var snp_bottomMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.BottomMargin) }
|
public var snp_bottomMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.BottomMargin) }
|
||||||
|
|
||||||
/// leading margin
|
/// leading margin
|
||||||
final public var snp_leadingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeadingMargin) }
|
public var snp_leadingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeadingMargin) }
|
||||||
|
|
||||||
/// trailing margin
|
/// trailing margin
|
||||||
final public var snp_trailingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TrailingMargin) }
|
public var snp_trailingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TrailingMargin) }
|
||||||
|
|
||||||
/// centerX within margins
|
/// centerX within margins
|
||||||
final public var snp_centerXWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterXWithinMargins) }
|
public var snp_centerXWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterXWithinMargins) }
|
||||||
|
|
||||||
/// centerY within margins
|
/// centerY within margins
|
||||||
final public var snp_centerYWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterYWithinMargins) }
|
public var snp_centerYWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterYWithinMargins) }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// top + left + bottom + right edges
|
// top + left + bottom + right edges
|
||||||
final public var snp_edges: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Edges) }
|
public var snp_edges: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Edges) }
|
||||||
|
|
||||||
// width + height dimensions
|
// width + height dimensions
|
||||||
final public var snp_size: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Size) }
|
public var snp_size: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Size) }
|
||||||
|
|
||||||
// centerX + centerY positions
|
// centerX + centerY positions
|
||||||
final public var snp_center: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Center) }
|
public var snp_center: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Center) }
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
|
|
||||||
// top + left + bottom + right margins
|
// top + left + bottom + right margins
|
||||||
final public var snp_margins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Margins) }
|
public var snp_margins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Margins) }
|
||||||
|
|
||||||
// centerX + centerY within margins
|
// centerX + centerY within margins
|
||||||
final public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) }
|
public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public extension View {
|
||||||
|
|
||||||
:returns: the constraints made
|
:returns: the constraints made
|
||||||
*/
|
*/
|
||||||
final public func snp_prepareConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
public func snp_prepareConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
return ConstraintMaker.prepareConstraints(self, closure: closure)
|
return ConstraintMaker.prepareConstraints(self, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public extension View {
|
||||||
|
|
||||||
:param: closure that will be passed the `ConstraintMaker` to make the constraints with
|
:param: closure that will be passed the `ConstraintMaker` to make the constraints with
|
||||||
*/
|
*/
|
||||||
final public func snp_makeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
|
public func snp_makeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
|
||||||
ConstraintMaker.makeConstraints(self, closure: closure)
|
ConstraintMaker.makeConstraints(self, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public extension View {
|
||||||
|
|
||||||
:param: closure that will be passed the `ConstraintMaker` to update the constraints with
|
:param: closure that will be passed the `ConstraintMaker` to update the constraints with
|
||||||
*/
|
*/
|
||||||
final public func snp_updateConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
|
public func snp_updateConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
|
||||||
ConstraintMaker.updateConstraints(self, closure: closure)
|
ConstraintMaker.updateConstraints(self, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,18 +153,18 @@ public extension View {
|
||||||
|
|
||||||
:param: closure that will be passed the `ConstraintMaker` to remake the constraints with
|
:param: closure that will be passed the `ConstraintMaker` to remake the constraints with
|
||||||
*/
|
*/
|
||||||
final public func snp_remakeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
|
public func snp_remakeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
|
||||||
ConstraintMaker.remakeConstraints(self, closure: closure)
|
ConstraintMaker.remakeConstraints(self, closure: closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes all previously made constraints.
|
Removes all previously made constraints.
|
||||||
*/
|
*/
|
||||||
final public func snp_removeConstraints() {
|
public func snp_removeConstraints() {
|
||||||
ConstraintMaker.removeConstraints(self)
|
ConstraintMaker.removeConstraints(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
final internal var snp_installedLayoutConstraints: [LayoutConstraint] {
|
internal var snp_installedLayoutConstraints: [LayoutConstraint] {
|
||||||
get {
|
get {
|
||||||
if let constraints = objc_getAssociatedObject(self, &installedLayoutConstraintsKey) as? [LayoutConstraint] {
|
if let constraints = objc_getAssociatedObject(self, &installedLayoutConstraintsKey) as? [LayoutConstraint] {
|
||||||
return constraints
|
return constraints
|
||||||
|
|
Loading…
Reference in New Issue