Commit c7d124bd by Daniel Dahan

added delegation for MaterialAnimation

parent f0421ecc
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
65DBE4211B9A9244000C804F /* Roboto-Thin.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */; }; 65DBE4211B9A9244000C804F /* Roboto-Thin.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */; };
962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; }; 962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; };
962F3E541BACA7FB0004B8AD /* NavigationBarView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 962F3E541BACA7FB0004B8AD /* NavigationBarView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96312E761BC46540007C0E9D /* MaterialTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96312E751BC46540007C0E9D /* MaterialTableViewCell.swift */; settings = {ASSET_TAGS = (); }; };
963832421B88DFD80015F710 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* MaterialKit.framework */; }; 963832421B88DFD80015F710 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* MaterialKit.framework */; };
9638325A1B88E31A0015F710 /* MaterialKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832581B88E31A0015F710 /* MaterialKitTests.swift */; }; 9638325A1B88E31A0015F710 /* MaterialKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832581B88E31A0015F710 /* MaterialKitTests.swift */; };
964B17B41BBA447F002A9CA0 /* MaterialLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964B17B31BBA447F002A9CA0 /* MaterialLayout.swift */; settings = {ASSET_TAGS = (); }; }; 964B17B41BBA447F002A9CA0 /* MaterialLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964B17B31BBA447F002A9CA0 /* MaterialLayout.swift */; settings = {ASSET_TAGS = (); }; };
...@@ -101,6 +102,7 @@ ...@@ -101,6 +102,7 @@
65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Bold.ttf"; sourceTree = "<group>"; }; 65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Bold.ttf"; sourceTree = "<group>"; };
65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; }; 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; };
962F3E521BACA68C0004B8AD /* NavigationBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBarView.swift; sourceTree = "<group>"; }; 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBarView.swift; sourceTree = "<group>"; };
96312E751BC46540007C0E9D /* MaterialTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialTableViewCell.swift; sourceTree = "<group>"; };
963832361B88DFD80015F710 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 963832361B88DFD80015F710 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
963832411B88DFD80015F710 /* MaterialKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 963832411B88DFD80015F710 /* MaterialKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
963832541B88E30F0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 963832541B88E30F0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
...@@ -149,6 +151,8 @@ ...@@ -149,6 +151,8 @@
children = ( children = (
65BDD1461BB5B916006F7F2B /* MaterialView.swift */, 65BDD1461BB5B916006F7F2B /* MaterialView.swift */,
65BDD16D1BB899F2006F7F2B /* MaterialPulseView.swift */, 65BDD16D1BB899F2006F7F2B /* MaterialPulseView.swift */,
962F3E521BACA68C0004B8AD /* NavigationBarView.swift */,
96312E751BC46540007C0E9D /* MaterialTableViewCell.swift */,
); );
name = View; name = View;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -177,14 +181,6 @@ ...@@ -177,14 +181,6 @@
name = Button; name = Button;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
65BDD16F1BB89A01006F7F2B /* Navigation */ = {
isa = PBXGroup;
children = (
962F3E521BACA68C0004B8AD /* NavigationBarView.swift */,
);
name = Navigation;
sourceTree = "<group>";
};
65BDD1701BB8CD56006F7F2B /* Label */ = { 65BDD1701BB8CD56006F7F2B /* Label */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -231,7 +227,6 @@ ...@@ -231,7 +227,6 @@
9AAC38521B89553800FE6B2D /* Font */, 9AAC38521B89553800FE6B2D /* Font */,
65AD15E81BC05B0E0068AF9C /* Layer */, 65AD15E81BC05B0E0068AF9C /* Layer */,
65B965851B8BEEB00055B139 /* View */, 65B965851B8BEEB00055B139 /* View */,
65BDD16F1BB89A01006F7F2B /* Navigation */,
964B17D71BBB38E2002A9CA0 /* Card */, 964B17D71BBB38E2002A9CA0 /* Card */,
65BDD1701BB8CD56006F7F2B /* Label */, 65BDD1701BB8CD56006F7F2B /* Label */,
65BDD1551BB6FC60006F7F2B /* Button */, 65BDD1551BB6FC60006F7F2B /* Button */,
...@@ -464,6 +459,7 @@ ...@@ -464,6 +459,7 @@
65BDD1741BB8D443006F7F2B /* MaterialAnimation.swift in Sources */, 65BDD1741BB8D443006F7F2B /* MaterialAnimation.swift in Sources */,
65BDD14B1BB5DD02006F7F2B /* MaterialFont.swift in Sources */, 65BDD14B1BB5DD02006F7F2B /* MaterialFont.swift in Sources */,
65BDD16A1BB7146B006F7F2B /* MaterialBorder.swift in Sources */, 65BDD16A1BB7146B006F7F2B /* MaterialBorder.swift in Sources */,
96312E761BC46540007C0E9D /* MaterialTableViewCell.swift in Sources */,
65BDD15B1BB7095E006F7F2B /* MaterialRadius.swift in Sources */, 65BDD15B1BB7095E006F7F2B /* MaterialRadius.swift in Sources */,
65BDD1721BB8CD77006F7F2B /* MaterialLabel.swift in Sources */, 65BDD1721BB8CD77006F7F2B /* MaterialLabel.swift in Sources */,
65BDD1491BB5DC98006F7F2B /* MaterialColor.swift in Sources */, 65BDD1491BB5DC98006F7F2B /* MaterialColor.swift in Sources */,
......
...@@ -18,6 +18,20 @@ ...@@ -18,6 +18,20 @@
import UIKit import UIKit
@objc(MaterialButtonDelegate)
public protocol MaterialButtonDelegate {
/**
:name: animationDidStart
*/
optional func animationDidStart(materialButton: MaterialButton, animation: CAAnimation)
/**
:name: animationDidStop
*/
optional func animationDidStop(materialButton: MaterialButton, animation: CAAnimation, finished flag: Bool)
}
@objc(MaterialButton)
public class MaterialButton : UIButton { public class MaterialButton : UIButton {
/** /**
:name: visualLayer :name: visualLayer
...@@ -30,6 +44,11 @@ public class MaterialButton : UIButton { ...@@ -30,6 +44,11 @@ public class MaterialButton : UIButton {
public private(set) lazy var pulseLayer: CAShapeLayer = CAShapeLayer() public private(set) lazy var pulseLayer: CAShapeLayer = CAShapeLayer()
/** /**
:name: delegate
*/
public weak var delegate: MaterialButtonDelegate?
/**
:name: pulseScale :name: pulseScale
*/ */
public lazy var pulseScale: Bool = true public lazy var pulseScale: Bool = true
...@@ -349,8 +368,10 @@ public class MaterialButton : UIButton { ...@@ -349,8 +368,10 @@ public class MaterialButton : UIButton {
/** /**
:name: animationDidStart :name: animationDidStart
public override func animationDidStart(anim: CAAnimation) {}
*/ */
public override func animationDidStart(anim: CAAnimation) {
delegate?.animationDidStart?(self, animation: anim)
}
/** /**
:name: animationDidStop :name: animationDidStop
...@@ -369,6 +390,8 @@ public class MaterialButton : UIButton { ...@@ -369,6 +390,8 @@ public class MaterialButton : UIButton {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
} }
} }
delegate?.animationDidStop?(self, animation: anim, finished: flag)
} }
// //
......
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
public class MaterialTableViewCell: UITableViewCell {
//
// :name: panRecognizer
//
private var panRecognizer: UIPanGestureRecognizer!
//
// :name: originalCenter
//
private var originalCenter: CGPoint!
//
// :name: leftView
//
public var leftView: UIView? {
didSet {
if let v: UIView = leftView {
contentView.addSubview(v)
}
}
}
//
// :name: rightView
//
public var rightView: UIView? {
didSet {
if let v: UIView = rightView {
contentView.addSubview(v)
}
}
}
//
// :name: init
//
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
//
// :name: init
//
public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
prepareView()
}
//
// :name: layoutSubviews
//
public override func layoutSubviews() {
super.layoutSubviews()
leftView?.frame = CGRectMake(-bounds.size.width, 0, bounds.size.width, bounds.size.height)
rightView?.frame = CGRectMake(bounds.size.width, 0, bounds.size.width, bounds.size.height)
}
//
// :name: gestureRecognizerShouldBegin
//
public override func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
if let panGestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer {
let translation = panGestureRecognizer.translationInView(superview!)
if fabs(translation.x) > fabs(translation.y) {
return true
}
return false
}
return false
}
//
// :name: handlePanGesture
//
internal func handlePanGesture(recognizer: UIPanGestureRecognizer) {
switch recognizer.state {
case .Began:
break
case .Changed:
break
case .Ended:
break
default:
break
}
}
//
// :name: prepareView
//
private func prepareView() {
clipsToBounds = true
selectionStyle = .None
panRecognizer = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
panRecognizer.delegate = self
addGestureRecognizer(panRecognizer)
}
}
...@@ -18,6 +18,20 @@ ...@@ -18,6 +18,20 @@
import UIKit import UIKit
@objc(MaterialViewDelegate)
public protocol MaterialViewDelegate {
/**
:name: animationDidStart
*/
optional func animationDidStart(materialView: MaterialView, animation: CAAnimation)
/**
:name: animationDidStop
*/
optional func animationDidStop(materialView: MaterialView, animation: CAAnimation, finished flag: Bool)
}
@objc(MaterialView)
public class MaterialView : UIView { public class MaterialView : UIView {
// //
// :name: visualLayer // :name: visualLayer
...@@ -25,6 +39,11 @@ public class MaterialView : UIView { ...@@ -25,6 +39,11 @@ public class MaterialView : UIView {
public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer() public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer()
/** /**
:name: visualLayer
*/
public weak var delegate: MaterialViewDelegate?
/**
:name: image :name: image
*/ */
public var image: UIImage? { public var image: UIImage? {
...@@ -343,8 +362,10 @@ public class MaterialView : UIView { ...@@ -343,8 +362,10 @@ public class MaterialView : UIView {
/** /**
:name: animationDidStart :name: animationDidStart
public override func animationDidStart(anim: CAAnimation) {}
*/ */
public override func animationDidStart(anim: CAAnimation) {
delegate?.animationDidStart?(self, animation: anim)
}
/** /**
:name: animationDidStop :name: animationDidStop
...@@ -363,6 +384,8 @@ public class MaterialView : UIView { ...@@ -363,6 +384,8 @@ public class MaterialView : UIView {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
} }
} }
delegate?.animationDidStop?(self, animation: anim, finished: flag)
} }
// //
......
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