Commit cbae939a by M. Porooshani

Reworked the Layout class for chainables and did some cleanup

parent 2b3fa494
......@@ -97,10 +97,12 @@ class AppLeftViewController: UIViewController {
nameLabel.font = RobotoFont.mediumWithSize(18)
view.layout.size(profileView, width: 72, height: 72)
view.layout.align.topLeft(profileView, top: 30, left: (view.bounds.width - 72) / 2)
// view.layout.align.topLeft(profileView, top: 30, left: (view.bounds.width - 72) / 2)
view.layout(profileView).top(30).left((view.bounds.width - 72) / 2)
view.addSubview(nameLabel)
view.layout.align
Layout.alignFromTop(view, child: nameLabel, top: 130)
Layout.alignToParentHorizontally(view, child: nameLabel, left: 20, right: 20)
// view.layout.alignFromTop(nameLabel, top: 130)
......@@ -116,7 +118,7 @@ class AppLeftViewController: UIViewController {
tableView.separatorStyle = .None
// Use Layout to easily align the tableView.
view.layout.align.edges(tableView, top: 170)
view.layout.edges(tableView, top: 170)
}
}
......
......@@ -157,7 +157,7 @@ class AppMenuController: MenuController {
menuView.delegate = self
view.layout.size(menuView, width: baseSize.width, height: baseSize.height)
view.layout.align.bottomRight(menuView, bottom: menuViewInset, right: menuViewInset)
view.layout.bottomRight(menuView, bottom: menuViewInset, right: menuViewInset)
}
/// Prepare tabBarItem.
......
......@@ -169,7 +169,7 @@ class RecipesViewController: UIViewController {
tableView.delegate = self
// Use Layout to easily align the tableView.
view.layout.align.edges(tableView)
view.layout.edges(tableView)
}
}
......@@ -214,7 +214,7 @@ extension RecipesViewController: UITableViewDataSource {
label.textColor = MaterialColor.grey.darken1
label.text = "Favorites"
header.layout.align.edges(label, left: 24)
header.layout.edges(label, left: 24)
return header
}
......
......@@ -70,7 +70,7 @@ class RecommendationViewController: UIViewController {
tableView.delegate = self
// Use Layout to easily align the tableView.
view.layout.align.edges(tableView)
view.layout.edges(tableView)
}
}
......@@ -115,7 +115,7 @@ extension RecommendationViewController: UITableViewDataSource {
label.textColor = MaterialColor.grey.darken1
label.text = "Recommendations"
header.layout.align.edges(label, left: 24)
header.layout.edges(label, left: 24)
return header
}
......
......@@ -41,7 +41,7 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
// prepareAlignToParentHorizontallyAndVerticallyExample()
prepareAlignToParentHorizontallyAndVerticallyExample()
prepareCenterExample()
}
......@@ -75,10 +75,13 @@ class ViewController: UIViewController {
let children: Array<UIView> = [label1, label2, label3, label4]
// Align the labels vertically with an equal height.
view.layout.vertically(children, top: 100, bottom: 100)
// view.layout.vertically(children, top: 100, bottom: 100)
// Align the labels horizontally with an equal width.
view.layout.horizontally(children, left: 30, right: 30, spacing: 30)
// view.layout.horizontally(children, left: 30, right: 30, spacing: 30)
view.layout.horizontally(children, left: 30, right: 30, spacing: 30).vertically(children, top: 100, bottom: 100)
// Print out the dimensions of the labels.
for v in children {
......
......@@ -233,7 +233,7 @@ public class BottomTabBar : UITabBar {
super.didMoveToSuperview()
if autoLayoutToSuperview {
if let v: UIView = superview {
v.layout.align.bottom(self)
v.layout(self).bottom()
v.layout.horizontally(self)
}
}
......
......@@ -314,7 +314,7 @@ public class CardView : MaterialPulseView {
h += "[\(k)]"
layout.align.bottom(b, bottom: contentInset.bottom + leftButtonsInset.bottom)
layout.bottom(b, bottom: contentInset.bottom + leftButtonsInset.bottom)
i += 1
}
......@@ -343,7 +343,7 @@ public class CardView : MaterialPulseView {
h += "-(right_left)-"
}
layout.align.bottom(b, bottom: contentInset.bottom + rightButtonsInset.bottom)
layout.bottom(b, bottom: contentInset.bottom + rightButtonsInset.bottom)
i -= 1
}
......
......@@ -378,7 +378,7 @@ public class ImageCardView : MaterialPulseView {
verticalFormat += "-[titleLabel]"
views["titleLabel"] = v
} else {
layout.align.top(v, top: contentInset.top + titleLabelInset.top)
layout.top(v, top: contentInset.top + titleLabelInset.top)
}
layout.horizontally(v, left: contentInset.left + titleLabelInset.left, right: contentInset.right + titleLabelInset.right)
}
......@@ -417,7 +417,7 @@ public class ImageCardView : MaterialPulseView {
h += "[\(k)]"
layout.align.bottom(b, bottom: contentInset.bottom + leftButtonsInset.bottom)
layout.bottom(b, bottom: contentInset.bottom + leftButtonsInset.bottom)
i += 1
}
......@@ -446,7 +446,7 @@ public class ImageCardView : MaterialPulseView {
h += "-(right_left)-"
}
layout.align.bottom(b, bottom: contentInset.bottom + rightButtonsInset.bottom)
layout.bottom(b, bottom: contentInset.bottom + rightButtonsInset.bottom)
i -= 1
}
......
......@@ -401,7 +401,7 @@ public class TextView: UITextView {
internal func reloadView() {
if let p = placeholderLabel {
removeConstraints(constraints)
layout.align.edges(p,
layout.edges(p,
top: textContainerInset.top,
left: textContainerInset.left + textContainer.lineFragmentPadding,
bottom: textContainerInset.bottom,
......
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