Commit 503d3ba7 by Daniel Dahan

fixed shadow rotation issue

parent e4a4f114
......@@ -156,14 +156,14 @@ extension FeedViewController: MaterialCollectionViewDataSource {
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 {
// CardView template example.
cardView = CardView()
c.backgroundColor = nil
c.pulseColor = nil
c.contentView.addSubview(cardView!)
cardView!.pulseColor = nil
cardView!.pulseScale = false
cardView!.divider = false
cardView!.depth = .None
......@@ -197,7 +197,6 @@ extension FeedViewController: MaterialCollectionViewDataSource {
}
cardView!.frame = c.bounds
}
return c
......
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '1.34.8'
s.version = '1.34.9'
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.homepage = 'http://cosmicmind.io'
......
......@@ -405,9 +405,10 @@ public class CardView : MaterialPulseView {
*/
public override func prepareView() {
super.prepareView()
pulseColor = MaterialColor.blueGrey.lighten4
pulseColor = MaterialColor.grey.lighten1
depth = .Depth1
dividerColor = MaterialColor.blueGrey.lighten5
dividerColor = MaterialColor.grey.lighten3
cornerRadiusPreset = .Radius1
}
/**
......
......@@ -125,7 +125,6 @@ public class ControlView : MaterialView {
/// Reloads the view.
public func reloadView() {
// clear constraints so new ones do not conflict
removeConstraints(constraints)
for v in subviews {
......@@ -133,48 +132,49 @@ public class ControlView : MaterialView {
v.removeFromSuperview()
}
}
// Size of single grid column.
if let g: CGFloat = width / CGFloat(0 < grid.axis.columns ? grid.axis.columns : 1) {
grid.views = []
contentView.grid.columns = grid.axis.columns
// leftControls
if let v: Array<UIControl> = leftControls {
for c in v {
let w: CGFloat = c.intrinsicContentSize().width
if let b: UIButton = c as? UIButton {
b.contentEdgeInsets = UIEdgeInsetsZero
if 0 < width {
// Size of single grid column.
if let g: CGFloat = width / CGFloat(0 < grid.axis.columns ? grid.axis.columns : 1) {
grid.views = []
contentView.grid.columns = grid.axis.columns
// leftControls
if let v: Array<UIControl> = leftControls {
for c in v {
let w: CGFloat = c.intrinsicContentSize().width
if let b: UIButton = c as? UIButton {
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)
// rightControls
if let v: Array<UIControl> = rightControls {
for c in v {
let w: CGFloat = c.intrinsicContentSize().width
if let b: UIButton = c as? UIButton {
b.contentEdgeInsets = UIEdgeInsetsZero
grid.views?.append(contentView)
// rightControls
if let v: Array<UIControl> = rightControls {
for c in v {
let w: CGFloat = c.intrinsicContentSize().width
if let b: UIButton = c as? UIButton {
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 {
*/
public override func prepareView() {
super.prepareView()
pulseColor = MaterialColor.blueGrey.lighten4
pulseColor = MaterialColor.grey.lighten1
depth = .Depth1
dividerColor = MaterialColor.blueGrey.lighten5
dividerColor = MaterialColor.grey.lighten3
cornerRadiusPreset = .Radius1
}
/**
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.34.8</string>
<string>1.34.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -453,7 +453,13 @@ public class MaterialButton : UIButton {
/// Sets the shadow path.
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 {
/// Sets the shadow path.
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 {
/**
: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()
animation.keyPath = "position"
animation.path = bezierPath.CGPath
animation.rotationMode = MaterialAnimationRotationModeToValue(mode)
if let d = duration {
animation.duration = d
}
animation.duration = duration
return animation
}
}
\ No newline at end of file
......@@ -331,6 +331,12 @@ public class MaterialLayer : CAShapeLayer {
/// Sets the shadow path.
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 {
/// Sets the shadow path.
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 {
/**
: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()
animation.type = MaterialAnimationTransitionToValue(type)
if let d = direction {
animation.subtype = MaterialAnimationTransitionSubTypeToValue(d)
}
if let d = duration {
animation.duration = d
}
animation.duration = duration
return animation
}
}
\ No newline at end of file
......@@ -446,6 +446,12 @@ public class MaterialView : UIView {
/// Sets the shadow path.
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 {
public override func layoutSubviews() {
super.layoutSubviews()
// TitleView alignment.
if let v: UILabel = titleLabel {
if let d: UILabel = detailLabel {
......
......@@ -58,8 +58,8 @@ public class StatusBarView : ControlView {
public override func layoutSubviews() {
super.layoutSubviews()
width = UIScreen.mainScreen().bounds.width
grid.axis.columns = Int(width / 48)
// General alignment.
......@@ -74,10 +74,10 @@ public class StatusBarView : ControlView {
reloadView()
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 {
statusBarViewDidChangeLayout()
}
oldFrame = frame
}
}
......
......@@ -555,7 +555,13 @@ public class TextField : UITextField {
/// Sets the shadow path.
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.
......
......@@ -470,7 +470,13 @@ public class TextView: UITextView {
/// Sets the shadow path.
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