Commit cbae939a by M. Porooshani

Reworked the Layout class for chainables and did some cleanup

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