Commit ef382688 by Daniel Dahan

added button logic

parent f77ba634
......@@ -248,6 +248,7 @@ public class BasicCardView: MaterialPulseView {
// leftButtons
if let v = leftButtons {
if 0 < v.count {
var h: String = "H:|"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
......@@ -257,15 +258,18 @@ public class BasicCardView: MaterialPulseView {
d[k] = b
h += "-(left)-[\(k)]"
insertSubview(b, atIndex: 1)
addSubview(b)
b.layer.zPosition = 2000
MaterialLayout.alignFromBottom(self, child: b, bottom: leftButtonsInsetsRef!.bottom)
}
addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : leftButtonsInsetsRef!.left], views: d))
}
}
// rightButtons
if let v = rightButtons {
if 0 < v.count {
var h: String = "H:"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
......@@ -275,12 +279,14 @@ public class BasicCardView: MaterialPulseView {
d[k] = b
h += "[\(k)]-(right)-"
insertSubview(b, atIndex: 1)
addSubview(b)
b.layer.zPosition = 2000
MaterialLayout.alignFromBottom(self, child: b, bottom: rightButtonsInsetsRef!.bottom)
}
addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : rightButtonsInsetsRef!.right], views: d))
}
}
if nil != titleLabel {
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + titleLabelInsetsRef!.top
......@@ -294,8 +300,17 @@ public class BasicCardView: MaterialPulseView {
metrics["insetBottom"] = (metrics["insetBottom"] as! CGFloat) + titleLabelInsetsRef!.bottom
}
if 0 < views.count {
if 0 < leftButtons?.count {
verticalFormat += "-[button]-|"
views["button"] = leftButtons![0]
} else if 0 < rightButtons?.count {
verticalFormat += "-[button]-|"
views["button"] = rightButtons![0]
} else {
verticalFormat += "-(insetBottom)-|"
}
if 0 < views.count {
addConstraints(MaterialLayout.constraint(verticalFormat, options: [], metrics: metrics, views: views))
}
......
......@@ -165,6 +165,7 @@ public class NavigationBarView: MaterialView {
// leftButtons
if let v = leftButtons {
if 0 < v.count {
var h: String = "H:|"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
......@@ -174,22 +175,26 @@ public class NavigationBarView: MaterialView {
d[k] = b
h += "-(left)-[\(k)]"
insertSubview(b, atIndex: 1)
addSubview(b)
b.layer.zPosition = 2000
MaterialLayout.alignFromBottom(self, child: b, bottom: leftButtonsInsetsRef!.bottom)
}
addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : leftButtonsInsetsRef!.left], views: d))
}
}
// title
if let v = titleLabel {
insertSubview(v, atIndex: 0)
addSubview(v)
v.layer.zPosition = 1500
MaterialLayout.alignToParentHorizontallyWithInsets(self, child: v, left: titleLabelInsetsRef!.left, right: titleLabelInsetsRef!.right)
MaterialLayout.alignFromBottom(self, child: v, bottom: titleLabelInsetsRef!.bottom)
}
// rightButtons
if let v = rightButtons {
if 0 < v.count {
var h: String = "H:"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
......@@ -199,13 +204,15 @@ public class NavigationBarView: MaterialView {
d[k] = b
h += "[\(k)]-(right)-"
insertSubview(b, atIndex: 1)
addSubview(b)
b.layer.zPosition = 2000
MaterialLayout.alignFromBottom(self, child: b, bottom: rightButtonsInsetsRef!.bottom)
}
addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : rightButtonsInsetsRef!.right], views: d))
}
}
}
//
// :name: prepareProperties
......
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