Commit 13ec5abd by Daniel Dahan

fixing Layout constraints on card with constructor paramaters

parent a60c8773
......@@ -72,7 +72,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
t.setTranslatesAutoresizingMaskIntoConstraints(false)
t.textColor = MaterialTheme.white.color
t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.mediumWithSize(18)
t.font = Roboto.medium
t.numberOfLines = 1
prepareCard()
} else {
......@@ -110,7 +110,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.textColor = MaterialTheme.white.color
l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.lightWithSize(16)
l.font = Roboto.light
l.numberOfLines = 0
l.lineBreakMode = .ByWordWrapping
prepareCard()
......@@ -161,7 +161,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
}
/**
:name: rightButtons
:name: rightButtons
*/
public var rightButtons: Array<MaterialButton>? {
didSet {
......@@ -189,29 +189,16 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
/**
:name: init
*/
public convenience init() {
self.init(frame: CGRectZero)
}
/**
:name: init
*/
public convenience init(titleLabel: UILabel? = nil, detailLabel: UILabel? = nil, divider: UIView? = nil, leftButtons: Array<MaterialButton>? = nil, rightButtons: Array<MaterialButton>? = nil) {
self.init(frame: CGRectZero)
self.titleLabel = titleLabel
self.detailLabel = detailLabel
self.leftButtons = leftButtons
self.rightButtons = rightButtons
prepareProperties(detailLabel)
}
/**
:name: init
*/
public required init(frame: CGRect) {
super.init(frame: frame)
if CGRectZero == frame {
setTranslatesAutoresizingMaskIntoConstraints(false)
}
super.init(frame: CGRectZero)
}
//
......@@ -224,6 +211,13 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
}
//
// :name: prepareProperties
//
internal func prepareProperties(detailLabel: UILabel?) {
self.detailLabel = detailLabel
}
//
// :name: prepareCard
//
internal override func prepareCard() {
......
......@@ -113,7 +113,7 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
titleLabelContainer!.addSubview(t)
t.setTranslatesAutoresizingMaskIntoConstraints(false)
t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.mediumWithSize(18)
t.font = Roboto.medium
t.numberOfLines = 1
if nil == imageView {
titleLabelContainer!.backgroundColor = MaterialTheme.white.color
......@@ -160,7 +160,7 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.textColor = MaterialTheme.black.color
l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.lightWithSize(16)
l.font = Roboto.light
l.numberOfLines = 0
l.lineBreakMode = .ByWordWrapping
prepareCard()
......@@ -192,7 +192,7 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
public private(set) var buttonsContainer: UIView?
/**
:name: leftButtons
:name: leftButtons
*/
public var leftButtons: Array<MaterialButton>? {
didSet {
......
......@@ -132,12 +132,10 @@ public struct Layout {
}
/**
:name: alignAllSides
:name: alignAllSides
*/
public static func alignAllSides(parent: UIView, child: UIView) {
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|[child]|", options: nil, metrics: nil, views: views))
parent.addConstraints(constraint("V:|[child]|", options: nil, metrics: nil, views: views))
expandToParent(parent, child: child)
}
/**
......
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