Commit ef382688 by Daniel Dahan

added button logic

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