Commit 503d3ba7 by Daniel Dahan

fixed shadow rotation issue

parent e4a4f114
...@@ -156,14 +156,14 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -156,14 +156,14 @@ extension FeedViewController: MaterialCollectionViewDataSource {
var cardView: CardView? = c.contentView.subviews.first as? CardView var cardView: CardView? = c.contentView.subviews.first as? CardView
// Only build the template if the cardView doesn't exist. // Only build the template if the CardView doesn't exist.
if nil == cardView { if nil == cardView {
// CardView template example.
cardView = CardView() cardView = CardView()
c.backgroundColor = nil
c.pulseColor = nil
c.contentView.addSubview(cardView!) c.contentView.addSubview(cardView!)
cardView!.pulseColor = nil
cardView!.pulseScale = false cardView!.pulseScale = false
cardView!.divider = false cardView!.divider = false
cardView!.depth = .None cardView!.depth = .None
...@@ -197,7 +197,6 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -197,7 +197,6 @@ extension FeedViewController: MaterialCollectionViewDataSource {
} }
cardView!.frame = c.bounds cardView!.frame = c.bounds
} }
return c return c
......
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Material' s.name = 'Material'
s.version = '1.34.8' s.version = '1.34.9'
s.license = 'BSD' s.license = 'BSD'
s.summary = 'Express your creativity with Material, an animation and graphics framework for Google\'s Material Design and Apple\'s Flat UI in Swift.' s.summary = 'Express your creativity with Material, an animation and graphics framework for Google\'s Material Design and Apple\'s Flat UI in Swift.'
s.homepage = 'http://cosmicmind.io' s.homepage = 'http://cosmicmind.io'
......
...@@ -405,9 +405,10 @@ public class CardView : MaterialPulseView { ...@@ -405,9 +405,10 @@ public class CardView : MaterialPulseView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
pulseColor = MaterialColor.blueGrey.lighten4 pulseColor = MaterialColor.grey.lighten1
depth = .Depth1 depth = .Depth1
dividerColor = MaterialColor.blueGrey.lighten5 dividerColor = MaterialColor.grey.lighten3
cornerRadiusPreset = .Radius1
} }
/** /**
......
...@@ -125,7 +125,6 @@ public class ControlView : MaterialView { ...@@ -125,7 +125,6 @@ public class ControlView : MaterialView {
/// Reloads the view. /// Reloads the view.
public func reloadView() { public func reloadView() {
// clear constraints so new ones do not conflict // clear constraints so new ones do not conflict
removeConstraints(constraints) removeConstraints(constraints)
for v in subviews { for v in subviews {
...@@ -133,48 +132,49 @@ public class ControlView : MaterialView { ...@@ -133,48 +132,49 @@ public class ControlView : MaterialView {
v.removeFromSuperview() v.removeFromSuperview()
} }
} }
if 0 < width {
// Size of single grid column. // Size of single grid column.
if let g: CGFloat = width / CGFloat(0 < grid.axis.columns ? grid.axis.columns : 1) { if let g: CGFloat = width / CGFloat(0 < grid.axis.columns ? grid.axis.columns : 1) {
grid.views = [] grid.views = []
contentView.grid.columns = grid.axis.columns contentView.grid.columns = grid.axis.columns
// leftControls // leftControls
if let v: Array<UIControl> = leftControls { if let v: Array<UIControl> = leftControls {
for c in v { for c in v {
let w: CGFloat = c.intrinsicContentSize().width let w: CGFloat = c.intrinsicContentSize().width
if let b: UIButton = c as? UIButton { if let b: UIButton = c as? UIButton {
b.contentEdgeInsets = UIEdgeInsetsZero b.contentEdgeInsets = UIEdgeInsetsZero
}
c.grid.columns = 0 == g ? 1 : Int(ceil(w / g))
contentView.grid.columns -= c.grid.columns
addSubview(c)
grid.views?.append(c)
} }
c.grid.columns = 0 == g ? 1 : Int(ceil(w / g))
contentView.grid.columns -= c.grid.columns
addSubview(c)
grid.views?.append(c)
} }
}
grid.views?.append(contentView)
grid.views?.append(contentView)
// rightControls
// rightControls if let v: Array<UIControl> = rightControls {
if let v: Array<UIControl> = rightControls { for c in v {
for c in v { let w: CGFloat = c.intrinsicContentSize().width
let w: CGFloat = c.intrinsicContentSize().width if let b: UIButton = c as? UIButton {
if let b: UIButton = c as? UIButton { b.contentEdgeInsets = UIEdgeInsetsZero
b.contentEdgeInsets = UIEdgeInsetsZero }
c.grid.columns = 0 == g ? 1 : Int(ceil(w / g))
contentView.grid.columns -= c.grid.columns
addSubview(c)
grid.views?.append(c)
} }
c.grid.columns = 0 == g ? 1 : Int(ceil(w / g))
contentView.grid.columns -= c.grid.columns
addSubview(c)
grid.views?.append(c)
} }
grid.reloadLayout()
contentView.grid.reloadLayout()
} }
grid.reloadLayout()
contentView.grid.reloadLayout()
} }
} }
......
...@@ -543,9 +543,10 @@ public class ImageCardView : MaterialPulseView { ...@@ -543,9 +543,10 @@ public class ImageCardView : MaterialPulseView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
pulseColor = MaterialColor.blueGrey.lighten4 pulseColor = MaterialColor.grey.lighten1
depth = .Depth1 depth = .Depth1
dividerColor = MaterialColor.blueGrey.lighten5 dividerColor = MaterialColor.grey.lighten3
cornerRadiusPreset = .Radius1
} }
/** /**
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.34.8</string> <string>1.34.9</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -453,7 +453,13 @@ public class MaterialButton : UIButton { ...@@ -453,7 +453,13 @@ public class MaterialButton : UIButton {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath if .None == self.depth {
layer.shadowPath = nil
} else if nil == layer.shadowPath {
layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
}
} }
/** /**
......
...@@ -507,7 +507,13 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -507,7 +507,13 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath if .None == self.depth {
layer.shadowPath = nil
} else if nil == layer.shadowPath {
layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
}
} }
/** /**
......
...@@ -56,14 +56,12 @@ public extension MaterialAnimation { ...@@ -56,14 +56,12 @@ public extension MaterialAnimation {
/** /**
:name: path :name: path
*/ */
public static func path(bezierPath: UIBezierPath, mode: MaterialAnimationRotationMode = .Auto, duration: CFTimeInterval? = nil) -> CAKeyframeAnimation { public static func path(bezierPath: UIBezierPath, mode: MaterialAnimationRotationMode = .Auto, duration: CFTimeInterval = 0.25) -> CAKeyframeAnimation {
let animation: CAKeyframeAnimation = CAKeyframeAnimation() let animation: CAKeyframeAnimation = CAKeyframeAnimation()
animation.keyPath = "position" animation.keyPath = "position"
animation.path = bezierPath.CGPath animation.path = bezierPath.CGPath
animation.rotationMode = MaterialAnimationRotationModeToValue(mode) animation.rotationMode = MaterialAnimationRotationModeToValue(mode)
if let d = duration { animation.duration = duration
animation.duration = d
}
return animation return animation
} }
} }
\ No newline at end of file
...@@ -331,6 +331,12 @@ public class MaterialLayer : CAShapeLayer { ...@@ -331,6 +331,12 @@ public class MaterialLayer : CAShapeLayer {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath if .None == self.depth {
shadowPath = nil
} else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
}
} }
} }
...@@ -406,7 +406,13 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -406,7 +406,13 @@ public class MaterialTableViewCell: UITableViewCell {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath if .None == self.depth {
layer.shadowPath = nil
} else if nil == layer.shadowPath {
layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
}
} }
/** /**
......
...@@ -83,15 +83,13 @@ public extension MaterialAnimation { ...@@ -83,15 +83,13 @@ public extension MaterialAnimation {
/** /**
:name: transition :name: transition
*/ */
public static func transition(type: MaterialAnimationTransition, direction: MaterialAnimationTransitionSubType? = nil, duration: CFTimeInterval? = nil) -> CATransition { public static func transition(type: MaterialAnimationTransition, direction: MaterialAnimationTransitionSubType? = nil, duration: CFTimeInterval = 0.25) -> CATransition {
let animation: CATransition = CATransition() let animation: CATransition = CATransition()
animation.type = MaterialAnimationTransitionToValue(type) animation.type = MaterialAnimationTransitionToValue(type)
if let d = direction { if let d = direction {
animation.subtype = MaterialAnimationTransitionSubTypeToValue(d) animation.subtype = MaterialAnimationTransitionSubTypeToValue(d)
} }
if let d = duration { animation.duration = duration
animation.duration = d
}
return animation return animation
} }
} }
\ No newline at end of file
...@@ -446,6 +446,12 @@ public class MaterialView : UIView { ...@@ -446,6 +446,12 @@ public class MaterialView : UIView {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath if .None == self.depth {
layer.shadowPath = nil
} else if nil == layer.shadowPath {
layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
}
} }
} }
...@@ -70,7 +70,7 @@ public class NavigationBarView : StatusBarView { ...@@ -70,7 +70,7 @@ public class NavigationBarView : StatusBarView {
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
// TitleView alignment. // TitleView alignment.
if let v: UILabel = titleLabel { if let v: UILabel = titleLabel {
if let d: UILabel = detailLabel { if let d: UILabel = detailLabel {
......
...@@ -58,8 +58,8 @@ public class StatusBarView : ControlView { ...@@ -58,8 +58,8 @@ public class StatusBarView : ControlView {
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
width = UIScreen.mainScreen().bounds.width width = UIScreen.mainScreen().bounds.width
grid.axis.columns = Int(width / 48) grid.axis.columns = Int(width / 48)
// General alignment. // General alignment.
...@@ -74,10 +74,10 @@ public class StatusBarView : ControlView { ...@@ -74,10 +74,10 @@ public class StatusBarView : ControlView {
reloadView() reloadView()
if frame.origin.x != oldFrame!.origin.x || frame.origin.y != oldFrame!.origin.y || frame.width != oldFrame!.width || frame.height != oldFrame!.height { if frame.origin.x != oldFrame!.origin.x || frame.origin.y != oldFrame!.origin.y || frame.width != oldFrame!.width || frame.height != oldFrame!.height {
oldFrame = frame
if nil != delegate { if nil != delegate {
statusBarViewDidChangeLayout() statusBarViewDidChangeLayout()
} }
oldFrame = frame
} }
} }
......
...@@ -555,7 +555,13 @@ public class TextField : UITextField { ...@@ -555,7 +555,13 @@ public class TextField : UITextField {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath if .None == self.depth {
layer.shadowPath = nil
} else if nil == layer.shadowPath {
layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
}
} }
/// Prepares the titleLabel property. /// Prepares the titleLabel property.
......
...@@ -470,7 +470,13 @@ public class TextView: UITextView { ...@@ -470,7 +470,13 @@ public class TextView: UITextView {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath if .None == self.depth {
layer.shadowPath = nil
} else if nil == layer.shadowPath {
layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
}
} }
/** /**
......
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