Commit 2373b2b6 by Daniel Dahan

development: update NavigationViewController to NavigationView

parent 73bd9492
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
65B965871B8BEEC60055B139 /* SideNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */; }; 65B965871B8BEEC60055B139 /* SideNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */; };
65DBE4201B9A9244000C804F /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */; }; 65DBE4201B9A9244000C804F /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */; };
65DBE4211B9A9244000C804F /* Roboto-Thin.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */; }; 65DBE4211B9A9244000C804F /* Roboto-Thin.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */; };
962F3E531BACA68C0004B8AD /* NavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationViewController.swift */; }; 962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; };
962F3E541BACA7FB0004B8AD /* NavigationViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 962F3E541BACA7FB0004B8AD /* NavigationBarView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
963832421B88DFD80015F710 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* MaterialKit.framework */; }; 963832421B88DFD80015F710 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* MaterialKit.framework */; };
9638325A1B88E31A0015F710 /* MaterialKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832581B88E31A0015F710 /* MaterialKitTests.swift */; }; 9638325A1B88E31A0015F710 /* MaterialKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832581B88E31A0015F710 /* MaterialKitTests.swift */; };
963832691B88E5BF0015F710 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9638325E1B88E5BF0015F710 /* Capture.swift */; }; 963832691B88E5BF0015F710 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9638325E1B88E5BF0015F710 /* Capture.swift */; };
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideNavigationViewController.swift; sourceTree = "<group>"; }; 65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideNavigationViewController.swift; sourceTree = "<group>"; };
65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Bold.ttf"; sourceTree = "<group>"; }; 65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Bold.ttf"; sourceTree = "<group>"; };
65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; }; 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; };
962F3E521BACA68C0004B8AD /* NavigationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationViewController.swift; sourceTree = "<group>"; }; 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBarView.swift; sourceTree = "<group>"; };
963832361B88DFD80015F710 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 963832361B88DFD80015F710 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
963832411B88DFD80015F710 /* MaterialKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 963832411B88DFD80015F710 /* MaterialKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
963832541B88E30F0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 963832541B88E30F0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */, 65B965861B8BEEC60055B139 /* SideNavigationViewController.swift */,
962F3E521BACA68C0004B8AD /* NavigationViewController.swift */, 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */,
); );
name = Navigation; name = Navigation;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -272,7 +272,7 @@ ...@@ -272,7 +272,7 @@
657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */, 657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */,
96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */, 96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */,
657CD02F1B8EE0D3008C0029 /* ImageCardView.swift in Headers */, 657CD02F1B8EE0D3008C0029 /* ImageCardView.swift in Headers */,
962F3E541BACA7FB0004B8AD /* NavigationViewController.swift in Headers */, 962F3E541BACA7FB0004B8AD /* NavigationBarView.swift in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -383,7 +383,7 @@ ...@@ -383,7 +383,7 @@
963832691B88E5BF0015F710 /* Capture.swift in Sources */, 963832691B88E5BF0015F710 /* Capture.swift in Sources */,
9A94D10B1B8A485C00F586A5 /* ImageCardView.swift in Sources */, 9A94D10B1B8A485C00F586A5 /* ImageCardView.swift in Sources */,
96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */, 96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */,
962F3E531BACA68C0004B8AD /* NavigationViewController.swift in Sources */, 962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */,
9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */, 9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */,
9A94D1091B8A3F5100F586A5 /* MaterialCardView.swift in Sources */, 9A94D1091B8A3F5100F586A5 /* MaterialCardView.swift in Sources */,
65B965871B8BEEC60055B139 /* SideNavigationViewController.swift in Sources */, 65B965871B8BEEC60055B139 /* SideNavigationViewController.swift in Sources */,
......
...@@ -403,7 +403,7 @@ public class BasicCardView : MaterialCardView, Comparable { ...@@ -403,7 +403,7 @@ public class BasicCardView : MaterialCardView, Comparable {
var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
// title // title
if nil != titleLabelContainer && nil != titleLabel { if nil != titleLabel {
// clear for updated constraints // clear for updated constraints
titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints) titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints)
...@@ -422,7 +422,7 @@ public class BasicCardView : MaterialCardView, Comparable { ...@@ -422,7 +422,7 @@ public class BasicCardView : MaterialCardView, Comparable {
} }
// detail // detail
if nil != detailLabelContainer && nil != detailLabel { if nil != detailLabel {
// clear for updated constraints // clear for updated constraints
detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints) detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints)
...@@ -440,7 +440,7 @@ public class BasicCardView : MaterialCardView, Comparable { ...@@ -440,7 +440,7 @@ public class BasicCardView : MaterialCardView, Comparable {
} }
// buttons // buttons
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) { if nil != leftButtons || nil != rightButtons {
// clear for updated constraints // clear for updated constraints
buttonsContainer!.removeConstraints(buttonsContainer!.constraints) buttonsContainer!.removeConstraints(buttonsContainer!.constraints)
......
...@@ -515,7 +515,7 @@ public class ImageCardView : MaterialCardView, Comparable { ...@@ -515,7 +515,7 @@ public class ImageCardView : MaterialCardView, Comparable {
var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
// image // image
if nil != imageViewContainer && nil != imageView { if nil != imageView {
// clear for updated constraints // clear for updated constraints
imageViewContainer!.removeConstraints(imageViewContainer!.constraints) imageViewContainer!.removeConstraints(imageViewContainer!.constraints)
...@@ -530,7 +530,7 @@ public class ImageCardView : MaterialCardView, Comparable { ...@@ -530,7 +530,7 @@ public class ImageCardView : MaterialCardView, Comparable {
} }
// title // title
if nil != titleLabelContainer && nil != titleLabel { if nil != titleLabel {
// clear for updated constraints // clear for updated constraints
titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints) titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints)
...@@ -555,7 +555,7 @@ public class ImageCardView : MaterialCardView, Comparable { ...@@ -555,7 +555,7 @@ public class ImageCardView : MaterialCardView, Comparable {
} }
// detail // detail
if nil != detailLabelContainer && nil != detailLabel { if nil != detailLabel {
// clear for updated constraints // clear for updated constraints
detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints) detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints)
...@@ -574,7 +574,7 @@ public class ImageCardView : MaterialCardView, Comparable { ...@@ -574,7 +574,7 @@ public class ImageCardView : MaterialCardView, Comparable {
} }
// buttons // buttons
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) { if nil != leftButtons || nil != rightButtons {
// clear for updated constraints // clear for updated constraints
buttonsContainer!.removeConstraints(buttonsContainer!.constraints) buttonsContainer!.removeConstraints(buttonsContainer!.constraints)
......
...@@ -18,16 +18,16 @@ ...@@ -18,16 +18,16 @@
import UIKit import UIKit
public class NavigationViewController: UIViewController { public class NavigationBarView: UIView {
// //
// :name: layoutConstraints // :name: layoutConstraints
// //
internal lazy var layoutConstraints: Array<NSLayoutConstraint> = Array<NSLayoutConstraint>() internal lazy var layoutConstraints: Array<NSLayoutConstraint> = Array<NSLayoutConstraint>()
/** //
:name: maximumTitleLabelHeight // :name: horizontalInset
*/ //
public var maximumTitleLabelHeight: CGFloat = 0 { public var horizontalInset: CGFloat = MaterialTheme.cardHorizontalInset / 2 {
didSet { didSet {
prepareNavigation() prepareNavigation()
} }
...@@ -49,7 +49,7 @@ public class NavigationViewController: UIViewController { ...@@ -49,7 +49,7 @@ public class NavigationViewController: UIViewController {
titleLabelContainer = UIView() titleLabelContainer = UIView()
titleLabelContainer!.translatesAutoresizingMaskIntoConstraints = false titleLabelContainer!.translatesAutoresizingMaskIntoConstraints = false
titleLabelContainer!.backgroundColor = MaterialTheme.clear.color titleLabelContainer!.backgroundColor = MaterialTheme.clear.color
view.addSubview(titleLabelContainer!) addSubview(titleLabelContainer!)
} }
// text // text
...@@ -57,7 +57,7 @@ public class NavigationViewController: UIViewController { ...@@ -57,7 +57,7 @@ public class NavigationViewController: UIViewController {
t.translatesAutoresizingMaskIntoConstraints = false t.translatesAutoresizingMaskIntoConstraints = false
t.backgroundColor = MaterialTheme.clear.color t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.regular t.font = Roboto.regular
t.numberOfLines = 0 t.numberOfLines = 1
t.lineBreakMode = .ByTruncatingTail t.lineBreakMode = .ByTruncatingTail
t.textColor = MaterialTheme.white.color t.textColor = MaterialTheme.white.color
} else { } else {
...@@ -85,7 +85,7 @@ public class NavigationViewController: UIViewController { ...@@ -85,7 +85,7 @@ public class NavigationViewController: UIViewController {
leftButtonsContainer = UIView() leftButtonsContainer = UIView()
leftButtonsContainer!.translatesAutoresizingMaskIntoConstraints = false leftButtonsContainer!.translatesAutoresizingMaskIntoConstraints = false
leftButtonsContainer!.backgroundColor = MaterialTheme.clear.color leftButtonsContainer!.backgroundColor = MaterialTheme.clear.color
view.addSubview(leftButtonsContainer!) addSubview(leftButtonsContainer!)
} }
prepareNavigation() prepareNavigation()
} }
...@@ -108,7 +108,7 @@ public class NavigationViewController: UIViewController { ...@@ -108,7 +108,7 @@ public class NavigationViewController: UIViewController {
rightButtonsContainer = UIView() rightButtonsContainer = UIView()
rightButtonsContainer!.translatesAutoresizingMaskIntoConstraints = false rightButtonsContainer!.translatesAutoresizingMaskIntoConstraints = false
rightButtonsContainer!.backgroundColor = MaterialTheme.clear.color rightButtonsContainer!.backgroundColor = MaterialTheme.clear.color
view.addSubview(rightButtonsContainer!) addSubview(rightButtonsContainer!)
} }
prepareNavigation() prepareNavigation()
} }
...@@ -124,15 +124,23 @@ public class NavigationViewController: UIViewController { ...@@ -124,15 +124,23 @@ public class NavigationViewController: UIViewController {
/** /**
:name: init :name: init
*/ */
public init() { public override init(frame: CGRect) {
super.init(nibName: nil, bundle: nil) super.init(frame: frame)
prepareView()
}
/**
:name: init
*/
public convenience init() {
self.init(frame: CGRect.null)
} }
/** /**
:name: init :name: init
*/ */
public init?(titleLabel: UILabel? = nil, leftButtons: Array<MaterialButton>? = nil, rightButtons: Array<MaterialButton>? = nil) { public convenience init?(titleLabel: UILabel? = nil, leftButtons: Array<MaterialButton>? = nil, rightButtons: Array<MaterialButton>? = nil) {
super.init(nibName: nil, bundle: nil) self.init(frame: CGRect.null)
prepareProperties(titleLabel, leftButtons: leftButtons, rightButtons: rightButtons) prepareProperties(titleLabel, leftButtons: leftButtons, rightButtons: rightButtons)
} }
...@@ -146,38 +154,15 @@ public class NavigationViewController: UIViewController { ...@@ -146,38 +154,15 @@ public class NavigationViewController: UIViewController {
} }
// //
// :name: viewDidLoad
//
public override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareNavigation()
}
/**
:name: viewWillAppear
*/
public override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
/**
:name: viewDidDisappear
*/
public override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
}
//
// :name: prepareView // :name: prepareView
// //
private func prepareView() { private func prepareView() {
view.translatesAutoresizingMaskIntoConstraints = false translatesAutoresizingMaskIntoConstraints = false
view.layer.shadowColor = MaterialTheme.blueGrey.darken4.CGColor layer.shadowColor = MaterialTheme.blueGrey.darken4.CGColor
view.layer.shadowOffset = CGSizeMake(0.2, 0.2) layer.shadowOffset = CGSizeMake(0.2, 0.2)
view.layer.shadowOpacity = 0.5 layer.shadowOpacity = 0.5
view.layer.shadowRadius = 1 layer.shadowRadius = 1
view.clipsToBounds = false clipsToBounds = false
} }
// //
...@@ -189,18 +174,14 @@ public class NavigationViewController: UIViewController { ...@@ -189,18 +174,14 @@ public class NavigationViewController: UIViewController {
layoutConstraints.removeAll(keepCapacity: false) layoutConstraints.removeAll(keepCapacity: false)
// detect all components and create constraints // detect all components and create constraints
var verticalFormat: String = "V:|"
var horizontalFormat: String = "H:|"
var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
// left buttons // left buttons
if nil != leftButtonsContainer && (nil != leftButtons) { if nil != leftButtons {
// clear for updated constraints // clear for updated constraints
leftButtonsContainer!.removeConstraints(leftButtonsContainer!.constraints) leftButtonsContainer!.removeConstraints(leftButtonsContainer!.constraints)
//container //container
verticalFormat += "[leftButtonsContainer]"
horizontalFormat += "|[leftButtonsContainer]"
views["leftButtonsContainer"] = leftButtonsContainer! views["leftButtonsContainer"] = leftButtonsContainer!
// leftButtons // leftButtons
...@@ -210,61 +191,64 @@ public class NavigationViewController: UIViewController { ...@@ -210,61 +191,64 @@ public class NavigationViewController: UIViewController {
let button: MaterialButton = leftButtons![i] let button: MaterialButton = leftButtons![i]
leftButtonsContainer!.addSubview(button) leftButtonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button buttonViews["button\(i)"] = button
hFormat += "-(buttonLeftInset)-[button\(i)]" hFormat += "-(horizontalInset)-[button\(i)]"
Layout.expandToParentVerticallyWithPad(leftButtonsContainer!, child: button, top: 8, bottom: 8) Layout.expandToParentVerticallyWithPad(leftButtonsContainer!, child: button)
} }
leftButtonsContainer!.addConstraints(Layout.constraint(hFormat, options: [], metrics: ["buttonLeftInset": 8], views: buttonViews)) leftButtonsContainer!.addConstraints(Layout.constraint(hFormat + "|", options: [], metrics: ["horizontalInset": horizontalInset], views: buttonViews))
} }
// title // title
if nil != titleLabelContainer && nil != titleLabel { if nil != titleLabel {
// clear for updated constraints // clear for updated constraints
titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints) titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints)
// container // container
verticalFormat += "[titleLabelContainer]"
horizontalFormat += "[titleLabelContainer]"
views["titleLabelContainer"] = titleLabelContainer! views["titleLabelContainer"] = titleLabelContainer!
// common text // common text
if 0 == maximumTitleLabelHeight { Layout.expandToParentVerticallyWithPad(titleLabelContainer!, child: titleLabel!)
Layout.expandToParentWithPad(titleLabelContainer!, child: titleLabel!, top: 8, left: 8, bottom: 8, right: 8) Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!)
} else {
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: 8, right: 8)
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(titleLabelTopInset)-[titleLabel(<=maximumTitleLabelHeight)]-(titleLabelBottomInset)-|", options: [], metrics: ["titleLabelTopInset": 8, "titleLabelBottomInset": 8, "maximumTitleLabelHeight": maximumTitleLabelHeight], views: ["titleLabel": titleLabel!]))
}
} }
// left buttons // right buttons
if nil != rightButtonsContainer && (nil != leftButtons) { if nil != rightButtons {
// clear for updated constraints // clear for updated constraints
rightButtonsContainer!.removeConstraints(rightButtonsContainer!.constraints) rightButtonsContainer!.removeConstraints(rightButtonsContainer!.constraints)
//container //container
verticalFormat += "[rightButtonsContainer]"
horizontalFormat += "[rightButtonsContainer]|"
views["rightButtonsContainer"] = rightButtonsContainer! views["rightButtonsContainer"] = rightButtonsContainer!
// leftButtons // leftButtons
var hFormat: String = "H:" var hFormat: String = "H:|"
var buttonViews: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var buttonViews: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
for var i: Int = 0, l: Int = leftButtons!.count; i < l; ++i { for var i: Int = 0, l: Int = rightButtons!.count; i < l; ++i {
let button: MaterialButton = leftButtons![i] let button: MaterialButton = rightButtons![i]
rightButtonsContainer!.addSubview(button) rightButtonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button buttonViews["button\(i)"] = button
hFormat += "[button\(i)]-(buttonLeftInset)-" hFormat += "[button\(i)]-(horizontalInset)-"
Layout.expandToParentVerticallyWithPad(rightButtonsContainer!, child: button, top: 8, bottom: 8) Layout.expandToParentVerticallyWithPad(rightButtonsContainer!, child: button)
} }
rightButtonsContainer!.addConstraints(Layout.constraint(hFormat + "|", options: [], metrics: ["buttonLeftInset": 8], views: buttonViews)) rightButtonsContainer!.addConstraints(Layout.constraint(hFormat + "|", options: [], metrics: ["horizontalInset": horizontalInset], views: buttonViews))
} }
verticalFormat += "|" if nil != leftButtons && nil != titleLabel {
layoutConstraints += Layout.constraint("H:|[leftButtonsContainer]-(inset)-[titleLabelContainer]", options: [], metrics: ["inset": horizontalInset], views: ["leftButtonsContainer": leftButtonsContainer!, "titleLabelContainer": titleLabelContainer!])
Layout.alignFromBottom(self, child: leftButtonsContainer!, bottom: horizontalInset)
Layout.alignFromBottom(self, child: titleLabelContainer!, bottom: horizontalInset + leftButtons!.first!.contentEdgeInsets.bottom - 1)
} else if nil != leftButtons {
layoutConstraints += Layout.constraint("H:|[leftButtonsContainer]", options: [], metrics: ["inset": horizontalInset], views: ["leftButtonsContainer": leftButtonsContainer!])
Layout.alignFromBottom(self, child: leftButtonsContainer!, bottom: horizontalInset)
} else if nil != titleLabel {
layoutConstraints += Layout.constraint("H:|-(inset)-[titleLabelContainer]", options: [], metrics: ["inset": horizontalInset], views: ["titleLabelContainer": titleLabelContainer!])
Layout.alignFromBottom(self, child: titleLabelContainer!, bottom: horizontalInset)
}
// combine constraints if nil != rightButtons {
if 0 < layoutConstraints.count { layoutConstraints += Layout.constraint("H:[rightButtonsContainer]|", options: [], metrics: ["inset": horizontalInset], views: ["rightButtonsContainer": rightButtonsContainer!])
layoutConstraints += Layout.constraint(verticalFormat, options: [], metrics: nil, views: views) Layout.alignFromBottom(self, child: rightButtonsContainer!, bottom: horizontalInset)
layoutConstraints += Layout.constraint(horizontalFormat, options: [], metrics: nil, views: views)
NSLayoutConstraint.activateConstraints(layoutConstraints)
} }
// constraints
NSLayoutConstraint.activateConstraints(layoutConstraints)
} }
} }
\ No newline at end of file
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