Commit a0a9c77a by Daniel Dahan

fixed issue-194 where animation was not updating the value path correctly

parent e097bb28
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
965626701C88B7F4004ADEF7 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9656266F1C88B7F4004ADEF7 /* Material.framework */; };
965626711C88B7F4004ADEF7 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9656266F1C88B7F4004ADEF7 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
967513CA1C136BB7009F455A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513C91C136BB7009F455A /* AppDelegate.swift */; };
967513CC1C136BB7009F455A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513CB1C136BB7009F455A /* ViewController.swift */; };
967513D11C136BB7009F455A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 967513D01C136BB7009F455A /* Assets.xcassets */; };
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
965626711C88B7F4004ADEF7 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
9656266F1C88B7F4004ADEF7 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
967513C61C136BB7009F455A /* CardView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CardView.app; sourceTree = BUILT_PRODUCTS_DIR; };
967513C91C136BB7009F455A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
967513CB1C136BB7009F455A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
965626701C88B7F4004ADEF7 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
967513BD1C136BB7009F455A = {
isa = PBXGroup;
children = (
9656266F1C88B7F4004ADEF7 /* Material.framework */,
967513C81C136BB7009F455A /* CardView */,
967513C71C136BB7009F455A /* Products */,
);
......
......@@ -58,6 +58,45 @@ class ViewController: UIViewController {
:description: General usage example.
*/
private func prepareGeneralCardViewExample() {
// let cardView: CardView = CardView()
//
// // Title label.
// let titleLabel: UILabel = UILabel()
// titleLabel.text = "Welcome Back!"
// titleLabel.textColor = MaterialColor.blue.darken1
// titleLabel.font = RobotoFont.mediumWithSize(20)
// cardView.titleLabel = titleLabel
//
// // Detail label.
// let detailLabel: UILabel = UILabel()
// detailLabel.text = "It’s been a while, have you read any new books lately?"
// detailLabel.numberOfLines = 0
// cardView.detailView = detailLabel
//
// // Yes button.
// let btn1: FlatButton = FlatButton()
// btn1.pulseColor = MaterialColor.blue.lighten1
// btn1.pulseScale = false
// btn1.setTitle("YES", forState: .Normal)
// btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
//
// // No button.
// let btn2: FlatButton = FlatButton()
// btn2.pulseColor = MaterialColor.blue.lighten1
// btn2.pulseScale = false
// btn2.setTitle("NO", forState: .Normal)
// btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
//
// // Add buttons to left side.
// cardView.leftButtons = [btn1, btn2]
//
// // To support orientation changes, use MaterialLayout.
// view.addSubview(cardView)
// cardView.translatesAutoresizingMaskIntoConstraints = false
// MaterialLayout.alignFromTop(view, child: cardView, top: 100)
// MaterialLayout.alignToParentHorizontally(view, child: cardView, left: 20, right: 20)
let cardView: CardView = CardView()
// Title label.
......@@ -96,6 +135,7 @@ class ViewController: UIViewController {
MaterialLayout.alignFromTop(view, child: cardView, top: 100)
MaterialLayout.alignToParentHorizontally(view, child: cardView, left: 20, right: 20)
cardView.animate(MaterialAnimation.translateY(200))
}
/**
......
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
9656266A1C88242F004ADEF7 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 965626691C88242F004ADEF7 /* Material.framework */; };
9656266B1C88242F004ADEF7 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 965626691C88242F004ADEF7 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96D88C831C132C1800B91418 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C821C132C1800B91418 /* AppDelegate.swift */; };
96D88C851C132C1800B91418 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C841C132C1800B91418 /* ViewController.swift */; };
96D88C8A1C132C1800B91418 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96D88C891C132C1800B91418 /* Assets.xcassets */; };
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
9656266B1C88242F004ADEF7 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
965626691C88242F004ADEF7 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96D88C7F1C132C1800B91418 /* NavigationBarView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationBarView.app; sourceTree = BUILT_PRODUCTS_DIR; };
96D88C821C132C1800B91418 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96D88C841C132C1800B91418 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9656266A1C88242F004ADEF7 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
96D88C761C132C1800B91418 = {
isa = PBXGroup;
children = (
965626691C88242F004ADEF7 /* Material.framework */,
96D88C811C132C1800B91418 /* NavigationBarView */,
96D88C801C132C1800B91418 /* Products */,
);
......
......@@ -379,7 +379,11 @@ public class MaterialButton : UIButton {
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if anim is CAPropertyAnimation {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKeyPath: b.keyPath!)
}
layer.removeAnimationForKey(a.keyPath!)
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
......
......@@ -432,7 +432,11 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if anim is CAPropertyAnimation {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKeyPath: b.keyPath!)
}
layer.removeAnimationForKey(a.keyPath!)
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
......
......@@ -308,7 +308,11 @@ public class MaterialLayer : CAShapeLayer {
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if anim is CAPropertyAnimation {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
setValue(nil == b.toValue ? b.byValue : b.toValue, forKeyPath: b.keyPath!)
}
removeAnimationForKey(a.keyPath!)
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
......
......@@ -334,7 +334,11 @@ public class MaterialTableViewCell: UITableViewCell {
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if anim is CAPropertyAnimation {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKeyPath: b.keyPath!)
}
layer.removeAnimationForKey(a.keyPath!)
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
......
......@@ -420,7 +420,11 @@ public class MaterialView : UIView {
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if anim is CAPropertyAnimation {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKeyPath: b.keyPath!)
}
layer.removeAnimationForKey(a.keyPath!)
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
......@@ -440,8 +444,6 @@ public class MaterialView : UIView {
public func prepareView() {
prepareVisualLayer()
backgroundColor = MaterialColor.white
shadowColor = MaterialColor.black
borderColor = MaterialColor.black
}
/// Prepares the visualLayer property.
......
......@@ -487,7 +487,11 @@ public class TextField : UITextField {
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if anim is CAPropertyAnimation {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKeyPath: b.keyPath!)
}
layer.removeAnimationForKey(a.keyPath!)
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
......@@ -505,8 +509,6 @@ public class TextField : UITextField {
*/
public func prepareView() {
backgroundColor = MaterialColor.white
shadowColor = MaterialColor.black
borderColor = MaterialColor.black
masksToBounds = false
clearButtonMode = .WhileEditing
prepareBottomBorderLayer()
......
......@@ -432,7 +432,11 @@ public class TextView: UITextView {
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if anim is CAPropertyAnimation {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKeyPath: b.keyPath!)
}
layer.removeAnimationForKey(a.keyPath!)
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
......
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