Commit 468b271b by M. Porooshani

Cleaned up unwanted selfs and added more inline documentations

parent cbae939a
...@@ -42,13 +42,14 @@ public class Layout { ...@@ -42,13 +42,14 @@ public class Layout {
init(context: UIView?) { init(context: UIView?) {
self.context = context self.context = context
} }
init(context: UIView?, childContext: UIView?) { init(context: UIView?, childContext: UIView?) {
self.context = context self.context = context
self.childContext = childContext self.childContext = childContext
} }
/// Width /// Width
/// - returns: layout instance
public func width(child: UIView, width: CGFloat) -> Layout { public func width(child: UIView, width: CGFloat) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.width(v, child: child, width: width) Layout.width(v, child: child, width: width)
...@@ -57,6 +58,7 @@ public class Layout { ...@@ -57,6 +58,7 @@ public class Layout {
} }
/// Width (Assuming a child context) /// Width (Assuming a child context)
/// - returns: current layout instance
public func width(width: CGFloat) -> Layout { public func width(width: CGFloat) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.width(c, width: width) self.width(c, width: width)
...@@ -65,6 +67,7 @@ public class Layout { ...@@ -65,6 +67,7 @@ public class Layout {
} }
/// Height /// Height
/// - returns: current layout instance
public func height(child: UIView, height: CGFloat) -> Layout { public func height(child: UIView, height: CGFloat) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.height(v, child: child, height: height) Layout.height(v, child: child, height: height)
...@@ -73,6 +76,7 @@ public class Layout { ...@@ -73,6 +76,7 @@ public class Layout {
} }
/// Height (Assuming a child context) /// Height (Assuming a child context)
/// - returns: current layout instance
public func height(height: CGFloat) -> Layout { public func height(height: CGFloat) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.height(c, height: height) self.height(c, height: height)
...@@ -81,6 +85,7 @@ public class Layout { ...@@ -81,6 +85,7 @@ public class Layout {
} }
/// Size /// Size
/// - returns: current layout instance
public func size(child: UIView, width: CGFloat, height: CGFloat) -> Layout { public func size(child: UIView, width: CGFloat, height: CGFloat) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.size(v, child: child, width: width, height: height) Layout.size(v, child: child, width: width, height: height)
...@@ -89,14 +94,16 @@ public class Layout { ...@@ -89,14 +94,16 @@ public class Layout {
} }
/// Size (Assuming a child context) /// Size (Assuming a child context)
/// - returns: current layout instance
public func size(width: CGFloat, height: CGFloat) -> Layout { public func size(width: CGFloat, height: CGFloat) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.size(c, width: width, height: height) size(c, width: width, height: height)
} }
return self return self
} }
/// Array of UIViews horizontally aligned. /// Array of UIViews horizontally aligned.
/// - returns: current layout instance
public func horizontally(children: Array<UIView>, left: CGFloat = 0, right: CGFloat = 0, spacing: CGFloat = 0) -> Layout { public func horizontally(children: Array<UIView>, left: CGFloat = 0, right: CGFloat = 0, spacing: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignToParentHorizontally(v, children: children, left: left, right: right, spacing: spacing) Layout.alignToParentHorizontally(v, children: children, left: left, right: right, spacing: spacing)
...@@ -105,6 +112,7 @@ public class Layout { ...@@ -105,6 +112,7 @@ public class Layout {
} }
/// Array of UIViews vertically aligned. /// Array of UIViews vertically aligned.
/// - returns: current layout instance
public func vertically(children: Array<UIView>, top: CGFloat = 0, bottom: CGFloat = 0, spacing: CGFloat = 0) -> Layout { public func vertically(children: Array<UIView>, top: CGFloat = 0, bottom: CGFloat = 0, spacing: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignToParentVertically(v, children: children, top: top, bottom: bottom, spacing: spacing) Layout.alignToParentVertically(v, children: children, top: top, bottom: bottom, spacing: spacing)
...@@ -113,6 +121,7 @@ public class Layout { ...@@ -113,6 +121,7 @@ public class Layout {
} }
/// Horizontally aligned. /// Horizontally aligned.
/// - returns: current layout instance
public func horizontally(child: UIView, left: CGFloat = 0, right: CGFloat = 0) -> Layout { public func horizontally(child: UIView, left: CGFloat = 0, right: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignToParentHorizontally(v, child: child, left: left, right: right) Layout.alignToParentHorizontally(v, child: child, left: left, right: right)
...@@ -121,14 +130,16 @@ public class Layout { ...@@ -121,14 +130,16 @@ public class Layout {
} }
/// Horizontally aligned (Assuming a child context) /// Horizontally aligned (Assuming a child context)
/// - returns: current layout instance
public func horizontally(left: CGFloat = 0, right: CGFloat = 0) -> Layout { public func horizontally(left: CGFloat = 0, right: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.horizontally(c, left: left, right: right) horizontally(c, left: left, right: right)
} }
return self return self
} }
/// Vertically aligned. /// Vertically aligned.
/// - returns: current layout instance
public func vertically(child: UIView, top: CGFloat = 0, bottom: CGFloat = 0) -> Layout { public func vertically(child: UIView, top: CGFloat = 0, bottom: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignToParentVertically(v, child: child, top: top, bottom: bottom) Layout.alignToParentVertically(v, child: child, top: top, bottom: bottom)
...@@ -137,14 +148,16 @@ public class Layout { ...@@ -137,14 +148,16 @@ public class Layout {
} }
/// Vertically aligned (Assuming a child context) /// Vertically aligned (Assuming a child context)
/// - returns: current layout instance
public func vertically(top: CGFloat = 0, bottom: CGFloat = 0) -> Layout { public func vertically(top: CGFloat = 0, bottom: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.vertically(c, top: top, bottom: bottom) vertically(c, top: top, bottom: bottom)
} }
return self return self
} }
/// Center /// Center
/// - returns: current layout instance
public func center(child: UIView, constantX: CGFloat = 0, constantY: CGFloat = 0) -> Layout { public func center(child: UIView, constantX: CGFloat = 0, constantY: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.center(v, child: child, constantX: constantX, constantY: constantY) Layout.center(v, child: child, constantX: constantX, constantY: constantY)
...@@ -153,14 +166,16 @@ public class Layout { ...@@ -153,14 +166,16 @@ public class Layout {
} }
/// Center (Assuming a child context) /// Center (Assuming a child context)
/// - returns: current layout instance
public func center(constantX: CGFloat = 0, constantY: CGFloat = 0) -> Layout { public func center(constantX: CGFloat = 0, constantY: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.center(c, constantX: constantX, constantY: constantY) center(c, constantX: constantX, constantY: constantY)
} }
return self return self
} }
/// Center Horizontally /// Center Horizontally
/// - returns: current layout instance
public func centerHorizontally(child: UIView, constant: CGFloat = 0) -> Layout { public func centerHorizontally(child: UIView, constant: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.centerHorizontally(v, child: child, constant: constant) Layout.centerHorizontally(v, child: child, constant: constant)
...@@ -169,14 +184,16 @@ public class Layout { ...@@ -169,14 +184,16 @@ public class Layout {
} }
/// Center Horizontally (Assuming a child context) /// Center Horizontally (Assuming a child context)
/// - returns: current layout instance
public func centerHorizontally(constant: CGFloat = 0) -> Layout { public func centerHorizontally(constant: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.centerHorizontally(c, constant: constant) centerHorizontally(c, constant: constant)
} }
return self return self
} }
/// Center Vertically /// Center Vertically
/// - returns: current layout instance
public func centerVertically(child: UIView, constant: CGFloat = 0) -> Layout { public func centerVertically(child: UIView, constant: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.centerVertically(v, child: child, constant: constant) Layout.centerVertically(v, child: child, constant: constant)
...@@ -185,14 +202,16 @@ public class Layout { ...@@ -185,14 +202,16 @@ public class Layout {
} }
/// Center Vertically (Assuming a child context) /// Center Vertically (Assuming a child context)
/// - returns: current layout instance
public func centerVertically(constant: CGFloat = 0) -> Layout { public func centerVertically(constant: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.centerVertically(c, constant: constant) centerVertically(c, constant: constant)
} }
return self return self
} }
/// Align Edges /// Align Edges
/// - returns: current layout instance
public func edges(child: UIView, top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> Layout { public func edges(child: UIView, top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignToParent(v, child: child, top: top, left: left, bottom: bottom, right: right) Layout.alignToParent(v, child: child, top: top, left: left, bottom: bottom, right: right)
...@@ -201,14 +220,16 @@ public class Layout { ...@@ -201,14 +220,16 @@ public class Layout {
} }
/// Align Edges (Assuming a child context) /// Align Edges (Assuming a child context)
/// - returns: current layout instance
public func edges(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> Layout { public func edges(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.edges(c, top: top, left: left, bottom: bottom, right: right) edges(c, top: top, left: left, bottom: bottom, right: right)
} }
return self return self
} }
/// Align to TopLeft /// Align to TopLeft
/// - returns: current layout instance
public func topLeft(child: UIView, top: CGFloat = 0, left: CGFloat = 0) -> Layout { public func topLeft(child: UIView, top: CGFloat = 0, left: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignFromTopLeft(v, child: child, top: top, left: left) Layout.alignFromTopLeft(v, child: child, top: top, left: left)
...@@ -217,14 +238,16 @@ public class Layout { ...@@ -217,14 +238,16 @@ public class Layout {
} }
/// Align to TopLeft (Assuming a child context) /// Align to TopLeft (Assuming a child context)
/// - returns: current layout instance
public func topLeft(top: CGFloat = 0, left: CGFloat = 0) -> Layout { public func topLeft(top: CGFloat = 0, left: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.topLeft(c, top: top, left: left) topLeft(c, top: top, left: left)
} }
return self return self
} }
/// Align to TopRight /// Align to TopRight
/// - returns: current layout instance
public func topRight(child: UIView, top: CGFloat = 0, right: CGFloat = 0) -> Layout { public func topRight(child: UIView, top: CGFloat = 0, right: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignFromTopRight(v, child: child, top: top, right: right) Layout.alignFromTopRight(v, child: child, top: top, right: right)
...@@ -233,14 +256,16 @@ public class Layout { ...@@ -233,14 +256,16 @@ public class Layout {
} }
/// Align to TopRight (Assuming a child context) /// Align to TopRight (Assuming a child context)
/// - returns: current layout instance
public func topRight(top: CGFloat = 0, right: CGFloat = 0) -> Layout { public func topRight(top: CGFloat = 0, right: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.topRight(c, top: top, right: right) topRight(c, top: top, right: right)
} }
return self return self
} }
/// Align to BottomLeft /// Align to BottomLeft
/// - returns: current layout instance
public func bottomLeft(child: UIView, bottom: CGFloat = 0, left: CGFloat = 0) -> Layout { public func bottomLeft(child: UIView, bottom: CGFloat = 0, left: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignFromBottomLeft(v, child: child, bottom: bottom, left: left) Layout.alignFromBottomLeft(v, child: child, bottom: bottom, left: left)
...@@ -249,14 +274,16 @@ public class Layout { ...@@ -249,14 +274,16 @@ public class Layout {
} }
/// Align to BottomLeft (Assuming a child context) /// Align to BottomLeft (Assuming a child context)
/// - returns: current layout instance
public func bottomLeft(bottom: CGFloat = 0, left: CGFloat = 0) -> Layout { public func bottomLeft(bottom: CGFloat = 0, left: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.bottomLeft(c, bottom: bottom, left: left) bottomLeft(c, bottom: bottom, left: left)
} }
return self return self
} }
/// Align to BottomRight /// Align to BottomRight
/// - returns: current layout instance
public func bottomRight(child: UIView, bottom: CGFloat = 0, right: CGFloat = 0) -> Layout { public func bottomRight(child: UIView, bottom: CGFloat = 0, right: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignFromBottomRight(v, child: child, bottom: bottom, right: right) Layout.alignFromBottomRight(v, child: child, bottom: bottom, right: right)
...@@ -266,14 +293,16 @@ public class Layout { ...@@ -266,14 +293,16 @@ public class Layout {
} }
/// Align to BottomRight (Assuming a child context) /// Align to BottomRight (Assuming a child context)
/// - returns: current layout instance
public func bottomRight(bottom: CGFloat = 0, right: CGFloat = 0) -> Layout { public func bottomRight(bottom: CGFloat = 0, right: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.bottomRight(c, bottom: bottom, right: right) bottomRight(c, bottom: bottom, right: right)
} }
return self return self
} }
/// Align to Top /// Align to Top
/// - returns: current layout instance
public func top(child: UIView, top: CGFloat = 0) -> Layout { public func top(child: UIView, top: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignFromTop(v, child: child, top: top) Layout.alignFromTop(v, child: child, top: top)
...@@ -282,6 +311,7 @@ public class Layout { ...@@ -282,6 +311,7 @@ public class Layout {
} }
/// Align to Top (Assuming a child context) /// Align to Top (Assuming a child context)
/// - returns: current layout instance
public func top(top: CGFloat = 0) -> Layout { public func top(top: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.top(c, top: top) self.top(c, top: top)
...@@ -290,6 +320,7 @@ public class Layout { ...@@ -290,6 +320,7 @@ public class Layout {
} }
/// Align to Left /// Align to Left
/// - returns: current layout instance
public func left(child: UIView, left: CGFloat = 0) -> Layout { public func left(child: UIView, left: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignFromLeft(v, child: child, left: left) Layout.alignFromLeft(v, child: child, left: left)
...@@ -298,6 +329,7 @@ public class Layout { ...@@ -298,6 +329,7 @@ public class Layout {
} }
/// Align to Left (Assuming a child context) /// Align to Left (Assuming a child context)
/// - returns: current layout instance
public func left(left: CGFloat = 0) -> Layout { public func left(left: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.left(c, left: left) self.left(c, left: left)
...@@ -306,6 +338,7 @@ public class Layout { ...@@ -306,6 +338,7 @@ public class Layout {
} }
/// Align to Bottom /// Align to Bottom
/// - returns: current layout instance
public func bottom(child: UIView, bottom: CGFloat = 0) -> Layout { public func bottom(child: UIView, bottom: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignFromBottom(v, child: child, bottom: bottom) Layout.alignFromBottom(v, child: child, bottom: bottom)
...@@ -314,6 +347,7 @@ public class Layout { ...@@ -314,6 +347,7 @@ public class Layout {
} }
/// Align to Bottom (Assuming a child context) /// Align to Bottom (Assuming a child context)
/// - returns: current layout instance
public func bottom(bottom: CGFloat = 0) -> Layout { public func bottom(bottom: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.bottom(c, bottom: bottom) self.bottom(c, bottom: bottom)
...@@ -323,6 +357,7 @@ public class Layout { ...@@ -323,6 +357,7 @@ public class Layout {
/// Align to Right /// Align to Right
/// - returns: current layout instance
public func right(child: UIView, right: CGFloat = 0) -> Layout { public func right(child: UIView, right: CGFloat = 0) -> Layout {
if let v: UIView = context { if let v: UIView = context {
Layout.alignFromRight(v, child: child, right: right) Layout.alignFromRight(v, child: child, right: right)
...@@ -332,6 +367,7 @@ public class Layout { ...@@ -332,6 +367,7 @@ public class Layout {
} }
/// Align to Right (Assuming a child context) /// Align to Right (Assuming a child context)
/// - returns: current layout instance
public func right(right: CGFloat = 0) -> Layout { public func right(right: CGFloat = 0) -> Layout {
if let c: UIView = childContext { if let c: UIView = childContext {
self.right(c, right: right) self.right(c, right: right)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment