Commit e697f176 by Daniel Dahan

development: handle nil values set to BasicCard

parent a86fc878
......@@ -58,6 +58,7 @@ public class BasicCard : MaterialCard {
*/
public var titleLabel: UILabel? {
didSet {
if let t = titleLabel {
// container
if nil == titleLabelContainer {
titleLabelContainer = UIView()
......@@ -67,12 +68,16 @@ public class BasicCard : MaterialCard {
}
// text
titleLabelContainer!.addSubview(titleLabel!)
titleLabel!.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabel!.textColor = MaterialTheme.white.color
titleLabel!.backgroundColor = MaterialTheme.clear.color
titleLabel!.font = Roboto.mediumWithSize(18)
titleLabel!.numberOfLines = 1
titleLabelContainer!.addSubview(t)
t.setTranslatesAutoresizingMaskIntoConstraints(false)
t.textColor = MaterialTheme.white.color
t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.mediumWithSize(18)
t.numberOfLines = 1
} else {
titleLabel?.removeFromSuperview()
titleLabelContainer?.removeFromSuperview()
}
}
}
......@@ -86,6 +91,7 @@ public class BasicCard : MaterialCard {
*/
public var detailLabel: UILabel? {
didSet {
if let l = detailLabel {
// container
if nil == detailLabelContainer {
detailLabelContainer = UIView()
......@@ -95,14 +101,18 @@ public class BasicCard : MaterialCard {
}
// text
detailLabelContainer!.addSubview(detailLabel!)
detailLabel!.setTranslatesAutoresizingMaskIntoConstraints(false)
detailLabel!.textColor = MaterialTheme.white.color
detailLabel!.backgroundColor = MaterialTheme.clear.color
detailLabel!.font = Roboto.lightWithSize(12)
detailLabel!.numberOfLines = 0
detailLabel!.lineBreakMode = .ByWordWrapping
detailLabelContainer!.addSubview(l)
l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.textColor = MaterialTheme.white.color
l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.lightWithSize(12)
l.numberOfLines = 0
l.lineBreakMode = .ByWordWrapping
prepareCard()
} else {
detailLabel?.removeFromSuperview()
detailLabelContainer?.removeFromSuperview()
}
}
}
......@@ -111,10 +121,14 @@ public class BasicCard : MaterialCard {
*/
public var divider: UIView? {
didSet {
divider!.setTranslatesAutoresizingMaskIntoConstraints(false)
divider!.backgroundColor = MaterialTheme.blueGrey.color
addSubview(divider!)
if let d = divider {
d.setTranslatesAutoresizingMaskIntoConstraints(false)
d.backgroundColor = MaterialTheme.blueGrey.color
addSubview(d)
prepareCard()
} else {
divider?.removeFromSuperview()
}
}
}
......@@ -128,6 +142,7 @@ public class BasicCard : MaterialCard {
*/
public var leftButtons: Array<MaterialButton>? {
didSet {
if let b = leftButtons {
if nil == buttonsContainer {
buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
......@@ -135,6 +150,9 @@ public class BasicCard : MaterialCard {
addSubview(buttonsContainer!)
}
prepareCard()
} else {
buttonsContainer?.removeFromSuperview()
}
}
}
......@@ -143,6 +161,7 @@ public class BasicCard : MaterialCard {
*/
public var rightButtons: Array<MaterialButton>? {
didSet {
if let b = rightButtons {
if nil == buttonsContainer {
buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
......@@ -150,6 +169,9 @@ public class BasicCard : MaterialCard {
addSubview(buttonsContainer!)
}
prepareCard()
} else {
buttonsContainer?.removeFromSuperview()
}
}
}
......
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