Commit 5fdb65df by Daniel Dahan

development: updated ImageCard and added defaults

parent 448b0318
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
963832891B89097D0015F710 /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963832871B8908180015F710 /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 963832891B89097D0015F710 /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963832871B8908180015F710 /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; }; 96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; };
96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96C910EE1B95804B00E7CE5C /* ImageRevealCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9A3A3B701B8EB582005F16BC /* ImageRevealCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */; };
9A94D0F91B895C8C00F586A5 /* Roboto.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9AAC38531B89559900FE6B2D /* Roboto.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9A94D0F91B895C8C00F586A5 /* Roboto.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9AAC38531B89559900FE6B2D /* Roboto.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9A94D0FA1B895EA500F586A5 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 963832631B88E5BF0015F710 /* LICENSE */; }; 9A94D0FA1B895EA500F586A5 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 963832631B88E5BF0015F710 /* LICENSE */; };
9A94D0FB1B895EA500F586A5 /* Roboto-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */; }; 9A94D0FB1B895EA500F586A5 /* Roboto-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */; };
...@@ -78,7 +76,6 @@ ...@@ -78,7 +76,6 @@
963832681B88E5BF0015F710 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; }; 963832681B88E5BF0015F710 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; };
963832871B8908180015F710 /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; }; 963832871B8908180015F710 /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; };
96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialTheme.swift; sourceTree = "<group>"; }; 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialTheme.swift; sourceTree = "<group>"; };
9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageRevealCard.swift; sourceTree = "<group>"; };
9A94D1081B8A3F5100F586A5 /* MaterialCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCard.swift; sourceTree = "<group>"; }; 9A94D1081B8A3F5100F586A5 /* MaterialCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCard.swift; sourceTree = "<group>"; };
9A94D10A1B8A485C00F586A5 /* ImageCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCard.swift; sourceTree = "<group>"; }; 9A94D10A1B8A485C00F586A5 /* ImageCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCard.swift; sourceTree = "<group>"; };
9AAC384C1B89528900FE6B2D /* BasicCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCard.swift; sourceTree = "<group>"; }; 9AAC384C1B89528900FE6B2D /* BasicCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCard.swift; sourceTree = "<group>"; };
...@@ -235,7 +232,6 @@ ...@@ -235,7 +232,6 @@
9A94D1081B8A3F5100F586A5 /* MaterialCard.swift */, 9A94D1081B8A3F5100F586A5 /* MaterialCard.swift */,
9AAC384C1B89528900FE6B2D /* BasicCard.swift */, 9AAC384C1B89528900FE6B2D /* BasicCard.swift */,
9A94D10A1B8A485C00F586A5 /* ImageCard.swift */, 9A94D10A1B8A485C00F586A5 /* ImageCard.swift */,
9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */,
); );
name = Card; name = Card;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -273,7 +269,6 @@ ...@@ -273,7 +269,6 @@
657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */, 657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */,
657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */, 657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */,
96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */, 96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */,
96C910EE1B95804B00E7CE5C /* ImageRevealCard.swift in Headers */,
657CD02F1B8EE0D3008C0029 /* ImageCard.swift in Headers */, 657CD02F1B8EE0D3008C0029 /* ImageCard.swift in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -383,7 +378,6 @@ ...@@ -383,7 +378,6 @@
96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */, 96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */,
9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */, 9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */,
9A94D1091B8A3F5100F586A5 /* MaterialCard.swift in Sources */, 9A94D1091B8A3F5100F586A5 /* MaterialCard.swift in Sources */,
9A3A3B701B8EB582005F16BC /* ImageRevealCard.swift in Sources */,
65B965871B8BEEC60055B139 /* SideNavController.swift in Sources */, 65B965871B8BEEC60055B139 /* SideNavController.swift in Sources */,
9638326C1B88E5BF0015F710 /* FlatButton.swift in Sources */, 9638326C1B88E5BF0015F710 /* FlatButton.swift in Sources */,
963832711B88E5BF0015F710 /* Text.swift in Sources */, 963832711B88E5BF0015F710 /* Text.swift in Sources */,
......
...@@ -35,9 +35,9 @@ public class BasicCard : MaterialCard, Comparable, Equatable { ...@@ -35,9 +35,9 @@ public class BasicCard : MaterialCard, Comparable, Equatable {
public var verticalSpace: CGFloat = 8 public var verticalSpace: CGFloat = 8
/** /**
:name: maximumDetailHeight :name: horizontalSpace
*/ */
public var maximumDetailHeight: CGFloat = 144 public var horizontalSpace: CGFloat = 8
/** /**
:name: titleLabelContainer :name: titleLabelContainer
...@@ -74,6 +74,7 @@ public class BasicCard : MaterialCard, Comparable, Equatable { ...@@ -74,6 +74,7 @@ public class BasicCard : MaterialCard, Comparable, Equatable {
t.backgroundColor = MaterialTheme.clear.color t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.mediumWithSize(18) t.font = Roboto.mediumWithSize(18)
t.numberOfLines = 1 t.numberOfLines = 1
prepareCard()
} else { } else {
titleLabelContainer?.removeFromSuperview() titleLabelContainer?.removeFromSuperview()
} }
...@@ -81,6 +82,11 @@ public class BasicCard : MaterialCard, Comparable, Equatable { ...@@ -81,6 +82,11 @@ public class BasicCard : MaterialCard, Comparable, Equatable {
} }
/** /**
:name: maximumDetailLabelHeight
*/
public var maximumDetailLabelHeight: CGFloat = 144
/**
:name: detailLabelContainer :name: detailLabelContainer
*/ */
public private(set) var detailLabelContainer: UIView? public private(set) var detailLabelContainer: UIView?
...@@ -203,7 +209,7 @@ public class BasicCard : MaterialCard, Comparable, Equatable { ...@@ -203,7 +209,7 @@ public class BasicCard : MaterialCard, Comparable, Equatable {
views["titleLabelContainer"] = titleLabelContainer! views["titleLabelContainer"] = titleLabelContainer!
// text // text
titleLabelContainer!.addConstraints(Layout.constraint("H:|-(verticalSpace)-[titleLabel]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace], views: ["titleLabel": titleLabel!])) titleLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[titleLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["titleLabel": titleLabel!]))
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize + verticalSpace], views: ["titleLabel": titleLabel!])) titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize + verticalSpace], views: ["titleLabel": titleLabel!]))
} }
...@@ -215,8 +221,8 @@ public class BasicCard : MaterialCard, Comparable, Equatable { ...@@ -215,8 +221,8 @@ public class BasicCard : MaterialCard, Comparable, Equatable {
views["detailLabelContainer"] = detailLabelContainer! views["detailLabelContainer"] = detailLabelContainer!
// text // text
detailLabelContainer!.addConstraints(Layout.constraint("H:|-(verticalSpace)-[detailLabel]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace], views: ["detailLabel": detailLabel!])) detailLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[detailLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["detailLabel": detailLabel!]))
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailHeight": maximumDetailHeight], views: ["detailLabel": detailLabel!])) detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
} }
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) { if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
...@@ -240,10 +246,10 @@ public class BasicCard : MaterialCard, Comparable, Equatable { ...@@ -240,10 +246,10 @@ public class BasicCard : MaterialCard, Comparable, Equatable {
let button: MaterialButton = leftButtons![i] let button: MaterialButton = leftButtons![i]
buttonsContainer!.addSubview(button) buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button buttonViews["button\(i)"] = button
horizontalFormat += "-(verticalSpace)-[button\(i)]" horizontalFormat += "-(horizontalSpace)-[button\(i)]"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace) Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: horizontalSpace, bottom: verticalSpace)
} }
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["verticalSpace": verticalSpace], views: buttonViews)) buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
} }
// rightButtons // rightButtons
...@@ -254,10 +260,10 @@ public class BasicCard : MaterialCard, Comparable, Equatable { ...@@ -254,10 +260,10 @@ public class BasicCard : MaterialCard, Comparable, Equatable {
let button: MaterialButton = rightButtons![i] let button: MaterialButton = rightButtons![i]
buttonsContainer!.addSubview(button) buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button buttonViews["button\(i)"] = button
horizontalFormat += "[button\(i)]-(verticalSpace)-" horizontalFormat += "[button\(i)]-(horizontalSpace)-"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace) Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: horizontalSpace, bottom: verticalSpace)
} }
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["verticalSpace": verticalSpace], views: buttonViews)) buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
} }
} }
......
...@@ -27,7 +27,7 @@ public class FlatButton : MaterialButton { ...@@ -27,7 +27,7 @@ public class FlatButton : MaterialButton {
setTitleColor(MaterialTheme.indigo.darken1, forState: .Normal) setTitleColor(MaterialTheme.indigo.darken1, forState: .Normal)
pulseColor = MaterialTheme.indigo.darken1 pulseColor = MaterialTheme.indigo.darken1
backgroundColor = MaterialTheme.clear.color backgroundColor = MaterialTheme.clear.color
contentEdgeInsets = UIEdgeInsetsMake(4, 4, 4, 4) contentEdgeInsets = UIEdgeInsetsMake(4, 16, 4, 16)
} }
// //
......
...@@ -30,31 +30,72 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -30,31 +30,72 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
internal lazy var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() internal lazy var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
/** /**
:name: verticalSpace :name: verticalSpace
*/ */
public var verticalSpace: CGFloat = 8 public var verticalSpace: CGFloat = 8
/** /**
:name: maximumDetailHeight :name: horizontalSpace
*/ */
public var maximumDetailHeight: CGFloat = 144 public var horizontalSpace: CGFloat = 8
/** /**
:name: titleLabelContainer :name: shadow
*/ */
public private(set) var titleLabelContainer: UIView? public var shadow: Bool = true {
didSet {
false == shadow ? removeShadow() : prepareShadow()
}
}
/** /**
:name: shadow :name: maximumImageViewHeight
*/ */
public var shadow: Bool = true { public var maximumImageViewHeight: CGFloat = 200
/**
:name: imageViewContainer
*/
public private(set) var imageViewContainer: UIView?
/**
:name: imageView
*/
public var imageView: UIImageView? {
didSet { didSet {
false == shadow ? removeShadow() : prepareShadow() if let t = imageView {
// container
if nil == imageViewContainer {
imageViewContainer = UIView()
imageViewContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
imageViewContainer!.backgroundColor = MaterialTheme.clear.color
insertSubview(imageViewContainer!, belowSubview: backgroundColorView)
}
// text
imageViewContainer!.addSubview(t)
t.setTranslatesAutoresizingMaskIntoConstraints(false)
t.contentMode = .ScaleAspectFill
t.userInteractionEnabled = false
t.clipsToBounds = true
if nil != titleLabel {
titleLabelContainer!.removeFromSuperview()
imageViewContainer!.addSubview(titleLabelContainer!)
}
prepareCard()
} else {
imageViewContainer?.removeFromSuperview()
}
} }
} }
/** /**
:name: titleLabel :name: titleLabelContainer
*/
public private(set) var titleLabelContainer: UIView?
/**
:name: titleLabel
*/ */
public var titleLabel: UILabel? { public var titleLabel: UILabel? {
didSet { didSet {
...@@ -74,6 +115,13 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -74,6 +115,13 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
t.backgroundColor = MaterialTheme.clear.color t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.mediumWithSize(18) t.font = Roboto.mediumWithSize(18)
t.numberOfLines = 1 t.numberOfLines = 1
if nil == imageView {
titleLabelContainer!.addSubview(t)
} else {
titleLabelContainer!.removeFromSuperview()
imageViewContainer!.addSubview(titleLabelContainer!)
}
prepareCard()
} else { } else {
titleLabelContainer?.removeFromSuperview() titleLabelContainer?.removeFromSuperview()
} }
...@@ -81,12 +129,17 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -81,12 +129,17 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
} }
/** /**
:name: detailLabelContainer :name: maximumDetailLabelHeight
*/
public var maximumDetailLabelHeight: CGFloat = 144
/**
:name: detailLabelContainer
*/ */
public private(set) var detailLabelContainer: UIView? public private(set) var detailLabelContainer: UIView?
/** /**
:name: detailLabel :name: detailLabel
*/ */
public var detailLabel: UILabel? { public var detailLabel: UILabel? {
didSet { didSet {
...@@ -95,16 +148,16 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -95,16 +148,16 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
if nil == detailLabelContainer { if nil == detailLabelContainer {
detailLabelContainer = UIView() detailLabelContainer = UIView()
detailLabelContainer!.setTranslatesAutoresizingMaskIntoConstraints(false) detailLabelContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
detailLabelContainer!.backgroundColor = MaterialTheme.clear.color detailLabelContainer!.backgroundColor = MaterialTheme.white.color
addSubview(detailLabelContainer!) addSubview(detailLabelContainer!)
} }
// text // text
detailLabelContainer!.addSubview(l) detailLabelContainer!.addSubview(l)
l.setTranslatesAutoresizingMaskIntoConstraints(false) l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.textColor = MaterialTheme.white.color l.textColor = MaterialTheme.black.color
l.backgroundColor = MaterialTheme.clear.color l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.lightWithSize(12) l.font = Roboto.lightWithSize(16)
l.numberOfLines = 0 l.numberOfLines = 0
l.lineBreakMode = .ByWordWrapping l.lineBreakMode = .ByWordWrapping
prepareCard() prepareCard()
...@@ -115,13 +168,13 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -115,13 +168,13 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
} }
/** /**
:name: divider :name: divider
*/ */
public var divider: UIView? { public var divider: UIView? {
didSet { didSet {
if let d = divider { if let d = divider {
d.setTranslatesAutoresizingMaskIntoConstraints(false) d.setTranslatesAutoresizingMaskIntoConstraints(false)
d.backgroundColor = MaterialTheme.blueGrey.color d.backgroundColor = MaterialTheme.blueGrey.lighten5
addSubview(d) addSubview(d)
prepareCard() prepareCard()
} else { } else {
...@@ -131,7 +184,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -131,7 +184,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
} }
/** /**
:name: buttonsContainer :name: buttonsContainer
*/ */
public private(set) var buttonsContainer: UIView? public private(set) var buttonsContainer: UIView?
...@@ -144,7 +197,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -144,7 +197,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
if nil == buttonsContainer { if nil == buttonsContainer {
buttonsContainer = UIView() buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false) buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
buttonsContainer!.backgroundColor = MaterialTheme.clear.color buttonsContainer!.backgroundColor = MaterialTheme.white.color
addSubview(buttonsContainer!) addSubview(buttonsContainer!)
} }
prepareCard() prepareCard()
...@@ -155,7 +208,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -155,7 +208,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
} }
/** /**
:name: rightButtons :name: rightButtons
*/ */
public var rightButtons: Array<MaterialButton>? { public var rightButtons: Array<MaterialButton>? {
didSet { didSet {
...@@ -163,7 +216,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -163,7 +216,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
if nil == buttonsContainer { if nil == buttonsContainer {
buttonsContainer = UIView() buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false) buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
buttonsContainer!.backgroundColor = MaterialTheme.clear.color buttonsContainer!.backgroundColor = MaterialTheme.white.color
addSubview(buttonsContainer!) addSubview(buttonsContainer!)
} }
prepareCard() prepareCard()
...@@ -179,7 +232,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -179,7 +232,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
internal override func prepareView() { internal override func prepareView() {
super.prepareView() super.prepareView()
prepareShadow() prepareShadow()
backgroundColor = MaterialTheme.blueGrey.darken1 backgroundColor = MaterialTheme.clear.color
} }
// //
...@@ -195,16 +248,37 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -195,16 +248,37 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
// detect all components and create constraints // detect all components and create constraints
var verticalFormat: String = "V:|" var verticalFormat: String = "V:|"
// title // image
if nil != titleLabelContainer && nil != titleLabel { if nil != imageViewContainer && nil != imageView {
// container // container
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!]) layoutConstraints += Layout.constraint("H:|[imageViewContainer]|", options: nil, metrics: nil, views: ["imageViewContainer": imageViewContainer!])
verticalFormat += "[titleLabelContainer]" verticalFormat += "[imageViewContainer]"
views["titleLabelContainer"] = titleLabelContainer! views["imageViewContainer"] = imageViewContainer!
// text // text
titleLabelContainer!.addConstraints(Layout.constraint("H:|-(verticalSpace)-[titleLabel]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace], views: ["titleLabel": titleLabel!])) imageViewContainer!.addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: ["imageView": imageView!]))
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize], views: ["titleLabel": titleLabel!])) imageViewContainer!.addConstraints(Layout.constraint("V:|[imageView(maximumImageViewHeight)]|", options: nil, metrics: ["maximumImageViewHeight": maximumImageViewHeight], views: ["imageView": imageView!]))
}
// title
if nil != titleLabelContainer && nil != titleLabel {
if nil == imageView {
// container
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!])
verticalFormat += "[titleLabelContainer]"
views["titleLabelContainer"] = titleLabelContainer!
// text
titleLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[titleLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["titleLabel": titleLabel!]))
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize + verticalSpace], views: ["titleLabel": titleLabel!]))
} else {
//container
Layout.expandToParent(imageViewContainer!, child: titleLabelContainer!)
// text
titleLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[titleLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["titleLabel": titleLabel!]))
titleLabelContainer!.addConstraints(Layout.constraint("V:[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize + verticalSpace], views: ["titleLabel": titleLabel!]))
}
} }
// detail // detail
...@@ -215,8 +289,8 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -215,8 +289,8 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
views["detailLabelContainer"] = detailLabelContainer! views["detailLabelContainer"] = detailLabelContainer!
// text // text
detailLabelContainer!.addConstraints(Layout.constraint("H:|-(verticalSpace)-[detailLabel]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace], views: ["detailLabel": detailLabel!])) detailLabelContainer!.addConstraints(Layout.constraint("H:|-(horizontalSpace)-[detailLabel]-(horizontalSpace)-|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: ["detailLabel": detailLabel!]))
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailHeight": maximumDetailHeight], views: ["detailLabel": detailLabel!])) detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
} }
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) { if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
...@@ -240,10 +314,10 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -240,10 +314,10 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
let button: MaterialButton = leftButtons![i] let button: MaterialButton = leftButtons![i]
buttonsContainer!.addSubview(button) buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button buttonViews["button\(i)"] = button
horizontalFormat += "-(verticalSpace)-[button\(i)]" horizontalFormat += "-(horizontalSpace)-[button\(i)]"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace) Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
} }
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["verticalSpace": verticalSpace], views: buttonViews)) buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
} }
// rightButtons // rightButtons
...@@ -254,10 +328,10 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -254,10 +328,10 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
let button: MaterialButton = rightButtons![i] let button: MaterialButton = rightButtons![i]
buttonsContainer!.addSubview(button) buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button buttonViews["button\(i)"] = button
horizontalFormat += "[button\(i)]-(verticalSpace)-" horizontalFormat += "[button\(i)]-(horizontalSpace)-"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace) Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
} }
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["verticalSpace": verticalSpace], views: buttonViews)) buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
} }
} }
......
////
//// RevealCard.swift
//// MaterialKit
////
//// Created by Adam Dahan on 2015-08-26.
//// Copyright (c) 2015 GraphKit Inc. All rights reserved.
////
//
//import UIKit
//
//public class ImageRevealCard : ImageCard {
//
// private lazy var revealView: UIView = UIView()
// private lazy var tapGesture: UITapGestureRecognizer = UITapGestureRecognizer()
// private lazy var metrics: Dictionary <String, AnyObject> = Dictionary <String, AnyObject>()
// private var topLayoutConstraint: NSLayoutConstraint!
// private lazy var hideRevealViewButton: UIButton = UIButton()
//
// public required init(coder aDecoder: NSCoder) {
// super.init(coder: aDecoder)
// }
//
// public required init(frame: CGRect) {
// super.init(frame: frame)
// }
//
// internal override func initialize() {
// prepareTapGestures()
// prepareRevealView()
// prepareHideRevealViewButton()
// super.initialize()
// }
//
// public override func layoutSubviews() {
// super.layoutSubviews()
// revealView.frame = CGRectMake(0, 0, bounds.width, bounds.height)
// hideRevealViewButton.frame = CGRectMake(CGRectGetMaxX(revealView.frame) - 50, 10, 40, 40)
// }
//
// private func prepareTapGestures() {
// tapGesture.addTarget(self, action: "showRevealView")
// imageView.userInteractionEnabled = true
// addGestureRecognizer(tapGesture)
// }
//
// private func prepareRevealView() {
// revealView.backgroundColor = .whiteColor()
// revealView.hidden = true
// imageView.addSubview(revealView)
// }
//
// private func prepareHideRevealViewButton() {
// hideRevealViewButton.setImage(UIImage(named: "ic_clear"), forState: .Normal)
// hideRevealViewButton.tintColor = .whiteColor()
// hideRevealViewButton.addTarget(self, action: "hideRevealView", forControlEvents: UIControlEvents.TouchUpInside)
// revealView.addSubview(hideRevealViewButton)
// }
//
// internal func showRevealView() {
// removeTapGestures()
// revealView.hidden = false
// revealView.frame = CGRectMake(0, bounds.height, bounds.width, bounds.height)
// UIView.animateWithDuration(0.3, animations: { () -> Void in
// var frame = self.revealView.frame
// frame.origin.y -= self.bounds.height
// self.revealView.frame = frame
// })
// }
//
// internal func hideRevealView() {
// UIView.animateWithDuration(0.3, animations: { () -> Void in
// var frame = self.revealView.frame
// frame.origin.y = self.bounds.height
// self.revealView.frame = frame
// }) { (finished) -> Void in
// self.revealView.hidden = true
// self.prepareTapGestures()
// }
// }
//
// private func removeTapGestures() {
// removeGestureRecognizer(tapGesture)
// }
//}
//
//
//
...@@ -44,7 +44,7 @@ public class MaterialButton : UIButton { ...@@ -44,7 +44,7 @@ public class MaterialButton : UIButton {
/** /**
:name: pulseColor :name: pulseColor
*/ */
public var pulseColor: UIColor? = MaterialTheme.white.color public var pulseColor: UIColor? = MaterialTheme.blueGrey.lighten3
/** /**
:name: init :name: init
......
...@@ -44,7 +44,7 @@ public class MaterialCard : UIView { ...@@ -44,7 +44,7 @@ public class MaterialCard : UIView {
/** /**
:name: pulseColor :name: pulseColor
*/ */
public var pulseColor: UIColor = MaterialTheme.white.color public var pulseColor: UIColor = MaterialTheme.blueGrey.lighten3
/** /**
:name: init :name: init
......
...@@ -26,7 +26,7 @@ public class RaisedButton : MaterialButton { ...@@ -26,7 +26,7 @@ public class RaisedButton : MaterialButton {
super.prepareView() super.prepareView()
setTitleColor(MaterialTheme.white.color, forState: .Normal) setTitleColor(MaterialTheme.white.color, forState: .Normal)
backgroundColor = MaterialTheme.indigo.darken1 backgroundColor = MaterialTheme.indigo.darken1
contentEdgeInsets = UIEdgeInsetsMake(4, 4, 4, 4) contentEdgeInsets = UIEdgeInsetsMake(4, 16, 4, 16)
} }
// //
......
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