Commit 414d067e by Daniel Dahan

updating Card views

parent c20e6381
......@@ -243,6 +243,8 @@ public class BasicCardView : MaterialPulseView {
super.prepareView()
userInteractionEnabled = MaterialTheme.basicCardView.userInteractionEnabled
backgroundColor = MaterialTheme.basicCardView.backgroundColor
pulseColor = MaterialTheme.basicCardView.pulseColor
contentInsetsRef = MaterialTheme.basicCardView.contentInsetsRef
titleLabelInsetsRef = MaterialTheme.basicCardView.titleLabelInsetsRef
detailLabelInsetsRef = MaterialTheme.basicCardView.detailLabelInsetsRef
......@@ -287,15 +289,18 @@ public class BasicCardView : MaterialPulseView {
// title
if let v = titleLabel {
addSubview(v)
verticalFormat += "-[titleLabel]"
views["titleLabel"] = v
addSubview(v)
MaterialLayout.alignToParentHorizontallyWithInsets(self, child: v, left: contentInsetsRef!.left + titleLabelInsetsRef!.left, right: contentInsetsRef!.right + titleLabelInsetsRef!.right)
}
// detail
if let v = detailLabel {
addSubview(v)
if nil != titleLabel {
verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInsetsRef!.bottom + detailLabelInsetsRef!.top
......@@ -303,8 +308,7 @@ public class BasicCardView : MaterialPulseView {
verticalFormat += "-[detailLabel]"
views["detailLabel"] = v
addSubview(v)
MaterialLayout.alignToParentHorizontallyWithInsets(self, child: v, left: contentInsetsRef!.left + detailLabelInsetsRef!.left, right: contentInsetsRef!.right + detailLabelInsetsRef!.right)
}
......@@ -387,10 +391,13 @@ public class BasicCardView : MaterialPulseView {
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + titleLabelInsetsRef!.bottom
}
} else if nil != metrics["insetC"] {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInsetsRef!.top
}
if 0 < views.count {
verticalFormat += "-(insetBottom)-|"
print(verticalFormat)
addConstraints(MaterialLayout.constraint(verticalFormat, options: [], metrics: metrics, views: views))
}
}
......
......@@ -34,8 +34,12 @@ public class ImageCardView : MaterialPulseView {
set(value) {
if let v = value {
imageLayer.contents = v.CGImage
if 0 == imageLayer.frame.size.height {
imageLayer.frame.size.height = v.size.height
if 0 == maxImageSize {
if 0 == imageLayer.frame.size.height {
imageLayer.frame.size.height = v.size.height
}
} else {
imageLayer.frame.size.height = maxImageSize
}
imageLayer.hidden = false
}
......@@ -49,6 +53,19 @@ public class ImageCardView : MaterialPulseView {
}
/**
:name: maxImageSize
*/
public var maxImageSize: CGFloat = 0 {
didSet {
if 0 < maxImageSize {
imageLayer.frame.size.height = maxImageSize
// imageLayer.contentsGravity = MaterialGravityToString(contentsGravity)
}
reloadView()
}
}
/**
:name: contentsRect
*/
public override var contentsRect: CGRect {
......@@ -299,11 +316,7 @@ public class ImageCardView : MaterialPulseView {
public override func layoutSubviews() {
super.layoutSubviews()
// image
let h: CGFloat = imageLayer.frame.size.height
imageLayer.frame = bounds
if 0 < h && nil != imageLayer.contents {
imageLayer.frame.size.height = h
}
imageLayer.frame.size.width = bounds.size.width
// divider
if true == divider {
......@@ -329,6 +342,8 @@ public class ImageCardView : MaterialPulseView {
super.prepareView()
userInteractionEnabled = MaterialTheme.imageCardView.userInteractionEnabled
backgroundColor = MaterialTheme.imageCardView.backgroundColor
pulseColor = MaterialTheme.imageCardView.pulseColor
contentInsetsRef = MaterialTheme.imageCardView.contentInsetsRef
titleLabelInsetsRef = MaterialTheme.imageCardView.titleLabelInsetsRef
detailLabelInsetsRef = MaterialTheme.imageCardView.detailLabelInsetsRef
......@@ -367,7 +382,7 @@ public class ImageCardView : MaterialPulseView {
if nil != imageLayer.contents {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef!.top + imageLayer.frame.size.height
metrics["insetTop"] = imageLayer.frame.size.height
} else if nil != titleLabel {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef!.top + titleLabelInsetsRef!.top
......@@ -379,6 +394,7 @@ public class ImageCardView : MaterialPulseView {
// title
if let v = titleLabel {
addSubview(v)
if nil == imageLayer.contents {
verticalFormat += "-[titleLabel]"
views["titleLabel"] = v
......@@ -390,15 +406,18 @@ public class ImageCardView : MaterialPulseView {
// detail
if let v = detailLabel {
addSubview(v)
if nil == imageLayer.contents && nil != titleLabel {
verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInsetsRef!.bottom + detailLabelInsetsRef!.top
} else {
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailLabelInsetsRef!.top
}
verticalFormat += "-[detailLabel]"
views["detailLabel"] = v
addSubview(v)
MaterialLayout.alignToParentHorizontallyWithInsets(self, child: v, left: contentInsetsRef!.left + detailLabelInsetsRef!.left, right: contentInsetsRef!.right + detailLabelInsetsRef!.right)
}
......@@ -481,10 +500,13 @@ public class ImageCardView : MaterialPulseView {
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + titleLabelInsetsRef!.bottom
}
} else if nil != metrics["insetC"] {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInsetsRef!.top
}
if 0 < views.count {
verticalFormat += "-(insetBottom)-|"
print(verticalFormat)
addConstraints(MaterialLayout.constraint(verticalFormat, options: [], metrics: metrics, views: views))
}
}
......@@ -493,7 +515,7 @@ public class ImageCardView : MaterialPulseView {
// :name: prepareImageLayer
//
internal func prepareImageLayer() {
imageLayer = CAShapeLayer()
imageLayer.masksToBounds = true
imageLayer.zPosition = 0
visualLayer.addSublayer(imageLayer)
}
......
......@@ -62,10 +62,10 @@ public enum MaterialInsets {
*/
public func MaterialInsetsToValue(inset: MaterialInsets) -> MaterialInsetsType {
switch inset {
// square
case .None:
return (top: 0, left: 0, bottom: 0, right: 0)
// square
case .Square1:
return (top: 4, left: 4, bottom: 4, right: 4)
case .Square2:
......
......@@ -102,11 +102,11 @@ public extension MaterialTheme.basicCardView {
// shape
public static var masksToBounds: Bool = true
public static var cornerRadius: MaterialRadius = .None
public static var contentInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square3)
public static var contentInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var titleLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var detailLabelInsetsRef: MaterialInsetsType = (top: 0, left: 8, bottom: 16, right: 8)
public static var leftButtonsInsetsRef: MaterialInsetsType = (top: 8, left: 8, bottom: -8, right: 0)
public static var rightButtonsInsetsRef: MaterialInsetsType = (top: 8, left: 0, bottom: -8, right: 8)
public static var detailLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var leftButtonsInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
public static var rightButtonsInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
// border
public static var borderWidth: MaterialBorder = .None
......@@ -114,7 +114,7 @@ public extension MaterialTheme.basicCardView {
// color
public static var backgroundColor: UIColor = MaterialColor.white
public static var pulseColor: UIColor = MaterialColor.white
public static var pulseColor: UIColor = MaterialColor.blueGrey.lighten4
public static var pulseColorOpacity: CGFloat = 0.25
// interaction
......@@ -144,10 +144,10 @@ public extension MaterialTheme.imageCardView {
public static var masksToBounds: Bool = true
public static var cornerRadius: MaterialRadius = .None
public static var contentInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var titleLabelInsetsRef: MaterialInsetsType = (top: 8, left: 16, bottom: 0, right: 16)
public static var detailLabelInsetsRef: MaterialInsetsType = (top: 8, left: 16, bottom: 16, right: 16)
public static var leftButtonsInsetsRef: MaterialInsetsType = (top: 8, left: 0, bottom: 0, right: 0)
public static var rightButtonsInsetsRef: MaterialInsetsType = (top: 8, left: 0, bottom: 0, right: 0)
public static var titleLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var detailLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var leftButtonsInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
public static var rightButtonsInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
// border
public static var borderWidth: MaterialBorder = .None
......@@ -155,7 +155,7 @@ public extension MaterialTheme.imageCardView {
// color
public static var backgroundColor: UIColor = MaterialColor.white
public static var pulseColor: UIColor = MaterialColor.white
public static var pulseColor: UIColor = MaterialColor.blueGrey.lighten4
public static var pulseColorOpacity: CGFloat = 0.25
// interaction
......
......@@ -282,13 +282,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
internal func prepareLeftView() {
prepareContainer(&leftViewContainer, originX: leftOriginX, originY: 0, width: options.leftViewContainerWidth, height: view.bounds.size.height)
prepareLeftGestures()
// leftViewContainer!.layer.speed = 0
let w: CGFloat = leftViewContainer!.width
let h: CGFloat = leftViewContainer!.height
// leftAnimation = MaterialAnimation.position(CGPointMake(w / 2, h / 2), duration: 1)
// leftViewContainer!.position = CGPointMake(-(w / 2), h / 2)
// leftViewContainer!.animation(leftAnimation!)
}
//
......
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