mirror of https://github.com/SnapKit/SnapKit
Finalise classes
This commit is contained in:
parent
0126a0efc2
commit
b014ab638a
|
@ -30,7 +30,7 @@ import AppKit
|
|||
/**
|
||||
* Constraint is a single item that defines all the properties for a single ConstraintMaker chain
|
||||
*/
|
||||
public class Constraint {
|
||||
final public class Constraint {
|
||||
public var left: Constraint { return self.addConstraint(ConstraintAttributes.Left) }
|
||||
public var top: Constraint { return self.addConstraint(ConstraintAttributes.Top) }
|
||||
public var right: Constraint { return self.addConstraint(ConstraintAttributes.Right) }
|
||||
|
|
|
@ -30,7 +30,7 @@ import AppKit
|
|||
/**
|
||||
* ConstraintItem is a class that is used while building constraints.
|
||||
*/
|
||||
public class ConstraintItem {
|
||||
final public class ConstraintItem {
|
||||
|
||||
internal init(object: AnyObject?, attributes: ConstraintAttributes) {
|
||||
self.object = object
|
||||
|
|
|
@ -30,7 +30,7 @@ import AppKit
|
|||
/**
|
||||
* ConstraintMaker is the maker in snap that gets all constraints kickstarted
|
||||
*/
|
||||
public class ConstraintMaker {
|
||||
final public class ConstraintMaker {
|
||||
public var left: Constraint { return self.addConstraint(ConstraintAttributes.Left) }
|
||||
public var top: Constraint { return self.addConstraint(ConstraintAttributes.Top) }
|
||||
public var right: Constraint { return self.addConstraint(ConstraintAttributes.Right) }
|
||||
|
|
|
@ -30,8 +30,8 @@ import AppKit
|
|||
/**
|
||||
* LayoutConstraint is a subclass of NSLayoutConstraint to assist Snap and also provide better debugging
|
||||
*/
|
||||
public class LayoutConstraint: NSLayoutConstraint {
|
||||
internal var constraint: Constraint?
|
||||
final public class LayoutConstraint: NSLayoutConstraint {
|
||||
internal var snp_constraint: Constraint? = nil
|
||||
}
|
||||
|
||||
public func ==(left: LayoutConstraint, right: LayoutConstraint) -> Bool {
|
||||
|
|
|
@ -33,69 +33,69 @@ public extension View {
|
|||
|
||||
// normal
|
||||
|
||||
public var snp_left: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Left) }
|
||||
public var snp_top: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Top) }
|
||||
public var snp_right: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Right) }
|
||||
public var snp_bottom: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Bottom) }
|
||||
public var snp_leading: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Leading) }
|
||||
public var snp_trailing: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Trailing) }
|
||||
public var snp_width: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Width) }
|
||||
public var snp_height: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Height) }
|
||||
public var snp_centerX: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterX) }
|
||||
public var snp_centerY: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterY) }
|
||||
public var snp_baseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Baseline) }
|
||||
final public var snp_left: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Left) }
|
||||
final public var snp_top: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Top) }
|
||||
final public var snp_right: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Right) }
|
||||
final public var snp_bottom: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Bottom) }
|
||||
final public var snp_leading: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Leading) }
|
||||
final public var snp_trailing: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Trailing) }
|
||||
final public var snp_width: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Width) }
|
||||
final public var snp_height: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Height) }
|
||||
final public var snp_centerX: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterX) }
|
||||
final public var snp_centerY: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterY) }
|
||||
final public var snp_baseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Baseline) }
|
||||
|
||||
#if os(iOS)
|
||||
public var snp_firstBaseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.FirstBaseline) }
|
||||
public var snp_leftMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeftMargin) }
|
||||
public var snp_rightMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.RightMargin) }
|
||||
public var snp_topMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TopMargin) }
|
||||
public var snp_bottomMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.BottomMargin) }
|
||||
public var snp_leadingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeadingMargin) }
|
||||
public var snp_trailingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TrailingMargin) }
|
||||
public var snp_centerXWithinMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterXWithinMargins) }
|
||||
public var snp_centerYWithinMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterYWithinMargins) }
|
||||
final public var snp_firstBaseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.FirstBaseline) }
|
||||
final public var snp_leftMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeftMargin) }
|
||||
final public var snp_rightMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.RightMargin) }
|
||||
final public var snp_topMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TopMargin) }
|
||||
final public var snp_bottomMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.BottomMargin) }
|
||||
final public var snp_leadingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeadingMargin) }
|
||||
final public var snp_trailingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TrailingMargin) }
|
||||
final public var snp_centerXWithinMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterXWithinMargins) }
|
||||
final public var snp_centerYWithinMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterYWithinMargins) }
|
||||
#endif
|
||||
|
||||
// aggregates
|
||||
|
||||
public var snp_edges: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Edges) }
|
||||
public var snp_size: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Size) }
|
||||
public var snp_center: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Center) }
|
||||
final public var snp_edges: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Edges) }
|
||||
final public var snp_size: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Size) }
|
||||
final public var snp_center: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Center) }
|
||||
|
||||
#if os(iOS)
|
||||
public var snp_margins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Margins) }
|
||||
public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) }
|
||||
final public var snp_margins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Margins) }
|
||||
final public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) }
|
||||
#endif
|
||||
|
||||
public func snp_prepareConstraints(block: (make: ConstraintMaker) -> Void) -> Array<Constraint> {
|
||||
final public func snp_prepareConstraints(block: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
return ConstraintMaker.prepareConstraints(self, block: block)
|
||||
}
|
||||
|
||||
public func snp_makeConstraints(block: (make: ConstraintMaker) -> Void) {
|
||||
final public func snp_makeConstraints(block: (make: ConstraintMaker) -> Void) {
|
||||
ConstraintMaker.makeConstraints(self, block: block)
|
||||
}
|
||||
|
||||
public func snp_updateConstraints(block: (make: ConstraintMaker) -> Void) {
|
||||
final public func snp_updateConstraints(block: (make: ConstraintMaker) -> Void) {
|
||||
ConstraintMaker.updateConstraints(self, block: block)
|
||||
}
|
||||
|
||||
public func snp_remakeConstraints(block: (make: ConstraintMaker) -> Void) {
|
||||
final public func snp_remakeConstraints(block: (make: ConstraintMaker) -> Void) {
|
||||
ConstraintMaker.remakeConstraints(self, block: block)
|
||||
}
|
||||
|
||||
public func snp_removeConstraints() {
|
||||
final public func snp_removeConstraints() {
|
||||
ConstraintMaker.removeConstraints(self)
|
||||
}
|
||||
|
||||
// internal
|
||||
|
||||
internal var snp_installedLayoutConstraints: Array<LayoutConstraint> {
|
||||
final internal var snp_installedLayoutConstraints: [LayoutConstraint] {
|
||||
get {
|
||||
if let constraints = objc_getAssociatedObject(self, &installedLayoutConstraintsKey) as? Array<LayoutConstraint> {
|
||||
if let constraints = objc_getAssociatedObject(self, &installedLayoutConstraintsKey) as? [LayoutConstraint] {
|
||||
return constraints
|
||||
}
|
||||
return Array<LayoutConstraint>()
|
||||
return []
|
||||
}
|
||||
set {
|
||||
objc_setAssociatedObject(self, &installedLayoutConstraintsKey, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
|
||||
|
|
Loading…
Reference in New Issue