Finalise classes

This commit is contained in:
Robert Payne 2015-04-11 17:13:02 +12:00
parent 0126a0efc2
commit b014ab638a
5 changed files with 38 additions and 38 deletions

View File

@ -30,7 +30,7 @@ import AppKit
/** /**
* Constraint is a single item that defines all the properties for a single ConstraintMaker chain * 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 left: Constraint { return self.addConstraint(ConstraintAttributes.Left) }
public var top: Constraint { return self.addConstraint(ConstraintAttributes.Top) } public var top: Constraint { return self.addConstraint(ConstraintAttributes.Top) }
public var right: Constraint { return self.addConstraint(ConstraintAttributes.Right) } public var right: Constraint { return self.addConstraint(ConstraintAttributes.Right) }

View File

@ -30,7 +30,7 @@ import AppKit
/** /**
* ConstraintItem is a class that is used while building constraints. * ConstraintItem is a class that is used while building constraints.
*/ */
public class ConstraintItem { final public class ConstraintItem {
internal init(object: AnyObject?, attributes: ConstraintAttributes) { internal init(object: AnyObject?, attributes: ConstraintAttributes) {
self.object = object self.object = object

View File

@ -30,7 +30,7 @@ import AppKit
/** /**
* ConstraintMaker is the maker in snap that gets all constraints kickstarted * 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 left: Constraint { return self.addConstraint(ConstraintAttributes.Left) }
public var top: Constraint { return self.addConstraint(ConstraintAttributes.Top) } public var top: Constraint { return self.addConstraint(ConstraintAttributes.Top) }
public var right: Constraint { return self.addConstraint(ConstraintAttributes.Right) } public var right: Constraint { return self.addConstraint(ConstraintAttributes.Right) }

View File

@ -30,8 +30,8 @@ import AppKit
/** /**
* LayoutConstraint is a subclass of NSLayoutConstraint to assist Snap and also provide better debugging * LayoutConstraint is a subclass of NSLayoutConstraint to assist Snap and also provide better debugging
*/ */
public class LayoutConstraint: NSLayoutConstraint { final public class LayoutConstraint: NSLayoutConstraint {
internal var constraint: Constraint? internal var snp_constraint: Constraint? = nil
} }
public func ==(left: LayoutConstraint, right: LayoutConstraint) -> Bool { public func ==(left: LayoutConstraint, right: LayoutConstraint) -> Bool {

View File

@ -33,69 +33,69 @@ public extension View {
// normal // normal
public var snp_left: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Left) } final public var snp_left: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Left) }
public var snp_top: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Top) } final public var snp_top: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Top) }
public var snp_right: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Right) } final public var snp_right: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Right) }
public var snp_bottom: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Bottom) } final public var snp_bottom: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Bottom) }
public var snp_leading: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Leading) } final public var snp_leading: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Leading) }
public var snp_trailing: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Trailing) } final public var snp_trailing: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Trailing) }
public var snp_width: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Width) } final public var snp_width: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Width) }
public var snp_height: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Height) } final public var snp_height: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Height) }
public var snp_centerX: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterX) } final public var snp_centerX: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterX) }
public var snp_centerY: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterY) } final 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_baseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Baseline) }
#if os(iOS) #if os(iOS)
public var snp_firstBaseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.FirstBaseline) } final public var snp_firstBaseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.FirstBaseline) }
public var snp_leftMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeftMargin) } final public var snp_leftMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeftMargin) }
public var snp_rightMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.RightMargin) } final public var snp_rightMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.RightMargin) }
public var snp_topMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TopMargin) } final public var snp_topMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TopMargin) }
public var snp_bottomMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.BottomMargin) } final public var snp_bottomMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.BottomMargin) }
public var snp_leadingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeadingMargin) } final public var snp_leadingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeadingMargin) }
public var snp_trailingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TrailingMargin) } final public var snp_trailingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TrailingMargin) }
public var snp_centerXWithinMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterXWithinMargins) } final 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_centerYWithinMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterYWithinMargins) }
#endif #endif
// aggregates // aggregates
public var snp_edges: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Edges) } final public var snp_edges: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Edges) }
public var snp_size: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Size) } final 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_center: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Center) }
#if os(iOS) #if os(iOS)
public var snp_margins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Margins) } final 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_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) }
#endif #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) 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) 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) 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) ConstraintMaker.remakeConstraints(self, block: block)
} }
public func snp_removeConstraints() { final public func snp_removeConstraints() {
ConstraintMaker.removeConstraints(self) ConstraintMaker.removeConstraints(self)
} }
// internal // internal
internal var snp_installedLayoutConstraints: Array<LayoutConstraint> { final internal var snp_installedLayoutConstraints: [LayoutConstraint] {
get { get {
if let constraints = objc_getAssociatedObject(self, &installedLayoutConstraintsKey) as? Array<LayoutConstraint> { if let constraints = objc_getAssociatedObject(self, &installedLayoutConstraintsKey) as? [LayoutConstraint] {
return constraints return constraints
} }
return Array<LayoutConstraint>() return []
} }
set { set {
objc_setAssociatedObject(self, &installedLayoutConstraintsKey, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) objc_setAssociatedObject(self, &installedLayoutConstraintsKey, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))