Commit ef382688 by Daniel Dahan

added button logic

parent f77ba634
...@@ -248,38 +248,44 @@ public class BasicCardView: MaterialPulseView { ...@@ -248,38 +248,44 @@ public class BasicCardView: MaterialPulseView {
// leftButtons // leftButtons
if let v = leftButtons { if let v = leftButtons {
var h: String = "H:|" if 0 < v.count {
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var h: String = "H:|"
var i: Int = 0 var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
for b in v {
let k: String = "b\(i++)" for b in v {
d[k] = b let k: String = "b\(i++)"
h += "-(left)-[\(k)]" d[k] = b
h += "-(left)-[\(k)]"
addSubview(b)
b.layer.zPosition = 2000
MaterialLayout.alignFromBottom(self, child: b, bottom: leftButtonsInsetsRef!.bottom)
}
insertSubview(b, atIndex: 1) addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : leftButtonsInsetsRef!.left], views: d))
MaterialLayout.alignFromBottom(self, child: b, bottom: leftButtonsInsetsRef!.bottom)
} }
addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : leftButtonsInsetsRef!.left], views: d))
} }
// rightButtons // rightButtons
if let v = rightButtons { if let v = rightButtons {
var h: String = "H:" if 0 < v.count {
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var h: String = "H:"
var i: Int = 0 var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
for b in v {
let k: String = "b\(i++)" for b in v {
d[k] = b let k: String = "b\(i++)"
h += "[\(k)]-(right)-" d[k] = b
h += "[\(k)]-(right)-"
addSubview(b)
b.layer.zPosition = 2000
MaterialLayout.alignFromBottom(self, child: b, bottom: rightButtonsInsetsRef!.bottom)
}
insertSubview(b, atIndex: 1) addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : rightButtonsInsetsRef!.right], views: d))
MaterialLayout.alignFromBottom(self, child: b, bottom: rightButtonsInsetsRef!.bottom)
} }
addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : rightButtonsInsetsRef!.right], views: d))
} }
if nil != titleLabel { if nil != titleLabel {
...@@ -294,8 +300,17 @@ public class BasicCardView: MaterialPulseView { ...@@ -294,8 +300,17 @@ public class BasicCardView: MaterialPulseView {
metrics["insetBottom"] = (metrics["insetBottom"] as! CGFloat) + titleLabelInsetsRef!.bottom 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)-|" verticalFormat += "-(insetBottom)-|"
}
if 0 < views.count {
addConstraints(MaterialLayout.constraint(verticalFormat, options: [], metrics: metrics, views: views)) addConstraints(MaterialLayout.constraint(verticalFormat, options: [], metrics: metrics, views: views))
} }
......
...@@ -165,45 +165,52 @@ public class NavigationBarView: MaterialView { ...@@ -165,45 +165,52 @@ public class NavigationBarView: MaterialView {
// leftButtons // leftButtons
if let v = leftButtons { if let v = leftButtons {
var h: String = "H:|" if 0 < v.count {
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var h: String = "H:|"
var i: Int = 0 var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
for b in v {
let k: String = "b\(i++)"
d[k] = b
h += "-(left)-[\(k)]"
insertSubview(b, atIndex: 1) for b in v {
MaterialLayout.alignFromBottom(self, child: b, bottom: leftButtonsInsetsRef!.bottom) let k: String = "b\(i++)"
d[k] = b
h += "-(left)-[\(k)]"
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))
} }
addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : leftButtonsInsetsRef!.left], views: d))
} }
// title // title
if let v = titleLabel { 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.alignToParentHorizontallyWithInsets(self, child: v, left: titleLabelInsetsRef!.left, right: titleLabelInsetsRef!.right)
MaterialLayout.alignFromBottom(self, child: v, bottom: titleLabelInsetsRef!.bottom) MaterialLayout.alignFromBottom(self, child: v, bottom: titleLabelInsetsRef!.bottom)
} }
// rightButtons // rightButtons
if let v = rightButtons { if let v = rightButtons {
var h: String = "H:" if 0 < v.count {
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var h: String = "H:"
var i: Int = 0 var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
for b in v {
let k: String = "b\(i++)" for b in v {
d[k] = b let k: String = "b\(i++)"
h += "[\(k)]-(right)-" d[k] = b
h += "[\(k)]-(right)-"
addSubview(b)
b.layer.zPosition = 2000
MaterialLayout.alignFromBottom(self, child: b, bottom: rightButtonsInsetsRef!.bottom)
}
insertSubview(b, atIndex: 1) addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : rightButtonsInsetsRef!.right], views: d))
MaterialLayout.alignFromBottom(self, child: b, bottom: rightButtonsInsetsRef!.bottom)
} }
addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : rightButtonsInsetsRef!.right], views: d))
} }
} }
......
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