Commit 21f6756b by Daniel Dahan

editor: progression commit on Pulse refactor

parent 062c21f8
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
965E80E21DD4C50600D61E4B /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB78C1CB40DC500C806FE /* View.swift */; }; 965E80E21DD4C50600D61E4B /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB78C1CB40DC500C806FE /* View.swift */; };
965E80E31DD4C53300D61E4B /* Pulse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C61D95E5D900CFB109 /* Pulse.swift */; }; 965E80E31DD4C53300D61E4B /* Pulse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C61D95E5D900CFB109 /* Pulse.swift */; };
965E80E41DD4C53300D61E4B /* PulseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7841CB40DC500C806FE /* PulseView.swift */; }; 965E80E41DD4C53300D61E4B /* PulseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7841CB40DC500C806FE /* PulseView.swift */; };
965E80E51DD4C53300D61E4B /* PulseAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7821CB40DC500C806FE /* PulseAnimation.swift */; }; 965E80E51DD4C53300D61E4B /* MotionPulse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7821CB40DC500C806FE /* MotionPulse.swift */; };
965E80E61DD4C55200D61E4B /* Material+Obj-C.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7631CB40DC500C806FE /* Material+Obj-C.swift */; }; 965E80E61DD4C55200D61E4B /* Material+Obj-C.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7631CB40DC500C806FE /* Material+Obj-C.swift */; };
965E80E71DD4C55200D61E4B /* Material+UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E3C3931D397AE90086A024 /* Material+UIView.swift */; }; 965E80E71DD4C55200D61E4B /* Material+UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E3C3931D397AE90086A024 /* Material+UIView.swift */; };
965E80E81DD4C55200D61E4B /* Material+CALayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F1DC871D654FDF0025F925 /* Material+CALayer.swift */; }; 965E80E81DD4C55200D61E4B /* Material+CALayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F1DC871D654FDF0025F925 /* Material+CALayer.swift */; };
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
96BCB8101CB4115200C806FE /* MotionTransition.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB78B1CB40DC500C806FE /* MotionTransition.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8101CB4115200C806FE /* MotionTransition.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB78B1CB40DC500C806FE /* MotionTransition.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8111CB4115200C806FE /* Motion.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB76D1CB40DC500C806FE /* Motion.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8111CB4115200C806FE /* Motion.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB76D1CB40DC500C806FE /* Motion.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8131CB4115200C806FE /* MotionKeyframe.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8131CB4115200C806FE /* MotionKeyframe.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8141CB4115200C806FE /* PulseAnimation.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7821CB40DC500C806FE /* PulseAnimation.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8141CB4115200C806FE /* MotionPulse.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7821CB40DC500C806FE /* MotionPulse.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8151CB4115200C806FE /* FabButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FabButton.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8151CB4115200C806FE /* FabButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FabButton.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8161CB4115200C806FE /* FlatButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7601CB40DC500C806FE /* FlatButton.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8161CB4115200C806FE /* FlatButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7601CB40DC500C806FE /* FlatButton.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8171CB4115200C806FE /* Button.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7701CB40DC500C806FE /* Button.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8171CB4115200C806FE /* Button.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7701CB40DC500C806FE /* Button.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionKeyframe.swift; sourceTree = "<group>"; }; 96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionKeyframe.swift; sourceTree = "<group>"; };
96BCB7801CB40DC500C806FE /* Layer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layer.swift; sourceTree = "<group>"; }; 96BCB7801CB40DC500C806FE /* Layer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layer.swift; sourceTree = "<group>"; };
96BCB7811CB40DC500C806FE /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; }; 96BCB7811CB40DC500C806FE /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; };
96BCB7821CB40DC500C806FE /* PulseAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PulseAnimation.swift; sourceTree = "<group>"; }; 96BCB7821CB40DC500C806FE /* MotionPulse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionPulse.swift; sourceTree = "<group>"; };
96BCB7841CB40DC500C806FE /* PulseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PulseView.swift; sourceTree = "<group>"; }; 96BCB7841CB40DC500C806FE /* PulseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PulseView.swift; sourceTree = "<group>"; };
96BCB7851CB40DC500C806FE /* CornerRadius.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CornerRadius.swift; sourceTree = "<group>"; }; 96BCB7851CB40DC500C806FE /* CornerRadius.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CornerRadius.swift; sourceTree = "<group>"; };
96BCB7861CB40DC500C806FE /* Shape.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Shape.swift; sourceTree = "<group>"; }; 96BCB7861CB40DC500C806FE /* Shape.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Shape.swift; sourceTree = "<group>"; };
...@@ -414,7 +414,6 @@ ...@@ -414,7 +414,6 @@
children = ( children = (
9631A7C61D95E5D900CFB109 /* Pulse.swift */, 9631A7C61D95E5D900CFB109 /* Pulse.swift */,
96BCB7841CB40DC500C806FE /* PulseView.swift */, 96BCB7841CB40DC500C806FE /* PulseView.swift */,
96BCB7821CB40DC500C806FE /* PulseAnimation.swift */,
); );
name = Pulse; name = Pulse;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -717,6 +716,7 @@ ...@@ -717,6 +716,7 @@
96BCB78B1CB40DC500C806FE /* MotionTransition.swift */, 96BCB78B1CB40DC500C806FE /* MotionTransition.swift */,
96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */, 96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */,
96E3C39D1D3A1D0C0086A024 /* MotionBasic.swift */, 96E3C39D1D3A1D0C0086A024 /* MotionBasic.swift */,
96BCB7821CB40DC500C806FE /* MotionPulse.swift */,
); );
name = Motion; name = Motion;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -795,7 +795,7 @@ ...@@ -795,7 +795,7 @@
96BCB8101CB4115200C806FE /* MotionTransition.swift in Headers */, 96BCB8101CB4115200C806FE /* MotionTransition.swift in Headers */,
96BCB8111CB4115200C806FE /* Motion.swift in Headers */, 96BCB8111CB4115200C806FE /* Motion.swift in Headers */,
96BCB8131CB4115200C806FE /* MotionKeyframe.swift in Headers */, 96BCB8131CB4115200C806FE /* MotionKeyframe.swift in Headers */,
96BCB8141CB4115200C806FE /* PulseAnimation.swift in Headers */, 96BCB8141CB4115200C806FE /* MotionPulse.swift in Headers */,
96BCB8151CB4115200C806FE /* FabButton.swift in Headers */, 96BCB8151CB4115200C806FE /* FabButton.swift in Headers */,
96BCB8161CB4115200C806FE /* FlatButton.swift in Headers */, 96BCB8161CB4115200C806FE /* FlatButton.swift in Headers */,
96BCB8171CB4115200C806FE /* Button.swift in Headers */, 96BCB8171CB4115200C806FE /* Button.swift in Headers */,
...@@ -1099,7 +1099,7 @@ ...@@ -1099,7 +1099,7 @@
965E80ED1DD4C55200D61E4B /* Material+UIWindow.swift in Sources */, 965E80ED1DD4C55200D61E4B /* Material+UIWindow.swift in Sources */,
965E80E31DD4C53300D61E4B /* Pulse.swift in Sources */, 965E80E31DD4C53300D61E4B /* Pulse.swift in Sources */,
965E80E41DD4C53300D61E4B /* PulseView.swift in Sources */, 965E80E41DD4C53300D61E4B /* PulseView.swift in Sources */,
965E80E51DD4C53300D61E4B /* PulseAnimation.swift in Sources */, 965E80E51DD4C53300D61E4B /* MotionPulse.swift in Sources */,
965E80FE1DD4D59500D61E4B /* ToolbarController.swift in Sources */, 965E80FE1DD4D59500D61E4B /* ToolbarController.swift in Sources */,
965E80C81DD4C50600D61E4B /* Motion.swift in Sources */, 965E80C81DD4C50600D61E4B /* Motion.swift in Sources */,
965E80C91DD4C50600D61E4B /* MotionTransition.swift in Sources */, 965E80C91DD4C50600D61E4B /* MotionTransition.swift in Sources */,
......
...@@ -37,10 +37,10 @@ open class Button: UIButton, Pulsable { ...@@ -37,10 +37,10 @@ open class Button: UIButton, Pulsable {
allows the dropshadow effect on the backing layer, while clipping allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer. the image to a desired shape within the visualLayer.
*/ */
open internal(set) lazy var visualLayer = CAShapeLayer() open internal(set) var visualLayer = CAShapeLayer()
/// A Pulse reference. /// A Pulse reference.
internal internal(set) lazy var pulse: Pulse = Pulse() internal var pulse = Pulse()
/// PulseAnimation value. /// PulseAnimation value.
open var pulseAnimation: PulseAnimation { open var pulseAnimation: PulseAnimation {
...@@ -183,12 +183,12 @@ open class Button: UIButton, Pulsable { ...@@ -183,12 +183,12 @@ open class Button: UIButton, Pulsable {
let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
var s = self var s = self
MotionPulseAnimation<Button>.pulseExpandAnimation(&s, point: p) MotionPulse<Button>.expandAnimation(view: &s, visualLayer: visualLayer, point: p)
Motion.delay(time: 0.35) { [weak self] in Motion.delay(time: 0.35) { [weak self] in
guard var s = self else { guard var s = self else {
return return
} }
MotionPulseAnimation<Button>.pulseContractAnimation(&s) MotionPulse<Button>.contractAnimation(view: &s)
} }
} }
...@@ -201,7 +201,7 @@ open class Button: UIButton, Pulsable { ...@@ -201,7 +201,7 @@ open class Button: UIButton, Pulsable {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event) super.touchesBegan(touches, with: event)
var s = self var s = self
MotionPulseAnimation<Button>.pulseExpandAnimation(&s, point: layer.convert(touches.first!.location(in: s), from: layer)) MotionPulse<Button>.expandAnimation(view: &s, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer))
} }
/** /**
...@@ -213,7 +213,7 @@ open class Button: UIButton, Pulsable { ...@@ -213,7 +213,7 @@ open class Button: UIButton, Pulsable {
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event) super.touchesEnded(touches, with: event)
var s = self var s = self
MotionPulseAnimation<Button>.pulseContractAnimation(&s) MotionPulse<Button>.contractAnimation(view: &s)
} }
/** /**
...@@ -225,7 +225,7 @@ open class Button: UIButton, Pulsable { ...@@ -225,7 +225,7 @@ open class Button: UIButton, Pulsable {
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event) super.touchesCancelled(touches, with: event)
var s = self var s = self
MotionPulseAnimation<Button>.pulseContractAnimation(&s) MotionPulse<Button>.contractAnimation(view: &s)
} }
open func bringImageViewToFront() { open func bringImageViewToFront() {
......
...@@ -38,10 +38,10 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable { ...@@ -38,10 +38,10 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable {
allows the dropshadow effect on the backing layer, while clipping allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer. the image to a desired shape within the visualLayer.
*/ */
open internal(set) lazy var visualLayer = CAShapeLayer() open internal(set) var visualLayer = CAShapeLayer()
/// A Pulse reference. /// A Pulse reference.
internal internal(set) lazy var pulse: Pulse = Pulse() internal var pulse = Pulse()
/// PulseAnimation value. /// PulseAnimation value.
open var pulseAnimation: PulseAnimation { open var pulseAnimation: PulseAnimation {
...@@ -237,12 +237,12 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable { ...@@ -237,12 +237,12 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable {
let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
var s = self var s = self
MotionPulseAnimation<CollectionReusableView>.pulseExpandAnimation(&s, point: p) MotionPulse<CollectionReusableView>.expandAnimation(view: &s, visualLayer: visualLayer, point: p)
Motion.delay(time: 0.35) { [weak self] in Motion.delay(time: 0.35) { [weak self] in
guard var s = self else { guard var s = self else {
return return
} }
MotionPulseAnimation<CollectionReusableView>.pulseContractAnimation(&s) MotionPulse<CollectionReusableView>.contractAnimation(view: &s)
} }
} }
...@@ -255,7 +255,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable { ...@@ -255,7 +255,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event) super.touchesBegan(touches, with: event)
var s = self var s = self
MotionPulseAnimation<CollectionReusableView>.pulseExpandAnimation(&s, point: layer.convert(touches.first!.location(in: s), from: layer)) MotionPulse<CollectionReusableView>.expandAnimation(view: &s, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer))
} }
/** /**
...@@ -267,7 +267,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable { ...@@ -267,7 +267,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable {
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event) super.touchesEnded(touches, with: event)
var s = self var s = self
MotionPulseAnimation<CollectionReusableView>.pulseContractAnimation(&s) MotionPulse<CollectionReusableView>.contractAnimation(view: &s)
} }
/** /**
...@@ -279,7 +279,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable { ...@@ -279,7 +279,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulsable {
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event) super.touchesCancelled(touches, with: event)
var s = self var s = self
MotionPulseAnimation<CollectionReusableView>.pulseContractAnimation(&s) MotionPulse<CollectionReusableView>.contractAnimation(view: &s)
} }
/** /**
......
...@@ -38,10 +38,10 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable { ...@@ -38,10 +38,10 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable {
allows the dropshadow effect on the backing layer, while clipping allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer. the image to a desired shape within the visualLayer.
*/ */
open internal(set) lazy var visualLayer = CAShapeLayer() open internal(set) var visualLayer = CAShapeLayer()
/// A Pulse reference. /// A Pulse reference.
internal internal(set) lazy var pulse: Pulse = Pulse() internal var pulse = Pulse()
/// PulseAnimation value. /// PulseAnimation value.
open var pulseAnimation: PulseAnimation { open var pulseAnimation: PulseAnimation {
...@@ -244,12 +244,12 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable { ...@@ -244,12 +244,12 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable {
let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
var s = self var s = self
MotionPulseAnimation<CollectionViewCell>.pulseExpandAnimation(&s, point: p) MotionPulse<CollectionViewCell>.expandAnimation(view: &s, visualLayer: visualLayer, point: p)
Motion.delay(time: 0.35) { [weak self] in Motion.delay(time: 0.35) { [weak self] in
guard var s = self else { guard var s = self else {
return return
} }
MotionPulseAnimation<CollectionViewCell>.pulseContractAnimation(&s) MotionPulse<CollectionViewCell>.contractAnimation(view: &s)
} }
} }
...@@ -262,7 +262,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable { ...@@ -262,7 +262,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event) super.touchesBegan(touches, with: event)
var s = self var s = self
MotionPulseAnimation<CollectionViewCell>.pulseExpandAnimation(&s, point: layer.convert(touches.first!.location(in: s), from: layer)) MotionPulse<CollectionViewCell>.expandAnimation(view: &s, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer))
} }
/** /**
...@@ -274,7 +274,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable { ...@@ -274,7 +274,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable {
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event) super.touchesEnded(touches, with: event)
var s = self var s = self
MotionPulseAnimation<CollectionViewCell>.pulseContractAnimation(&s) MotionPulse<CollectionViewCell>.contractAnimation(view: &s)
} }
/** /**
...@@ -286,7 +286,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable { ...@@ -286,7 +286,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulsable {
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event) super.touchesCancelled(touches, with: event)
var s = self var s = self
MotionPulseAnimation<CollectionViewCell>.pulseContractAnimation(&s) MotionPulse<CollectionViewCell>.contractAnimation(view: &s)
} }
/** /**
......
...@@ -38,7 +38,7 @@ open class Layer: CAShapeLayer { ...@@ -38,7 +38,7 @@ open class Layer: CAShapeLayer {
allows the dropshadow effect on the backing layer, while clipping allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer. the image to a desired shape within the visualLayer.
*/ */
open internal(set) lazy var visualLayer = CAShapeLayer() open internal(set) var visualLayer = CAShapeLayer()
/** /**
A property that manages an image for the visualLayer's contents A property that manages an image for the visualLayer's contents
......
...@@ -84,7 +84,7 @@ public func AnimationTimingFunctionToValue(function: AnimationTimingFunction) -> ...@@ -84,7 +84,7 @@ public func AnimationTimingFunctionToValue(function: AnimationTimingFunction) ->
} }
} }
public typealias AnimationDelayCancelBlock = (Bool) -> Void public typealias MotionDelayCancelBlock = (Bool) -> Void
public struct Motion { public struct Motion {
/** /**
...@@ -95,15 +95,15 @@ public struct Motion { ...@@ -95,15 +95,15 @@ public struct Motion {
the animations have completed. the animations have completed.
*/ */
@discardableResult @discardableResult
public static func delay(time: TimeInterval, execute block: @escaping () -> Void) -> AnimationDelayCancelBlock? { public static func delay(time: TimeInterval, execute block: @escaping () -> Void) -> MotionDelayCancelBlock? {
func asyncAfter(completion: @escaping () -> Void) { func asyncAfter(completion: @escaping () -> Void) {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + time, execute: completion) DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + time, execute: completion)
} }
var cancelable: AnimationDelayCancelBlock? var cancelable: MotionDelayCancelBlock?
let delayed: AnimationDelayCancelBlock = { let delayed: MotionDelayCancelBlock = {
if !$0 { if !$0 {
DispatchQueue.main.async(execute: block) DispatchQueue.main.async(execute: block)
} }
...@@ -121,10 +121,10 @@ public struct Motion { ...@@ -121,10 +121,10 @@ public struct Motion {
} }
/** /**
Cancels the delayed AnimationDelayCancelBlock. Cancels the delayed MotionDelayCancelBlock.
- Parameter delayed completion: An AnimationDelayCancelBlock. - Parameter delayed completion: An MotionDelayCancelBlock.
*/ */
public static func cancel(delayed completion: AnimationDelayCancelBlock) { public static func cancel(delayed completion: MotionDelayCancelBlock) {
completion(true) completion(true)
} }
......
...@@ -42,14 +42,14 @@ public enum PulseAnimation: Int { ...@@ -42,14 +42,14 @@ public enum PulseAnimation: Int {
case pointWithBacking case pointWithBacking
} }
internal struct MotionPulseAnimation<T: UIView> where T: Pulsable { internal struct MotionPulse<T: UIView> where T: Pulsable {
/** /**
Triggers the expanding animation. Triggers the expanding animation.
- Parameter _ view: A Reference to the view to add the - Parameter _ view: A Reference to the view to add the
animations too. animations too.
- Parameter point: A point to pulse from. - Parameter point: A point to pulse from.
*/ */
internal static func pulseExpandAnimation(_ view: inout T, point: CGPoint) { internal static func expandAnimation(view: inout T, visualLayer: CAShapeLayer, point: CGPoint) {
guard .none != view.pulse.animation else { guard .none != view.pulse.animation else {
return return
} }
...@@ -63,15 +63,15 @@ internal struct MotionPulseAnimation<T: UIView> where T: Pulsable { ...@@ -63,15 +63,15 @@ internal struct MotionPulseAnimation<T: UIView> where T: Pulsable {
let pLayer = CAShapeLayer() let pLayer = CAShapeLayer()
bLayer.addSublayer(pLayer) bLayer.addSublayer(pLayer)
view.pulse.layers.insert(bLayer, at: 0) view.pulse.layers.append(bLayer)
view.visualLayer.addSublayer(bLayer) visualLayer.addSublayer(bLayer)
bLayer.zPosition = 0 bLayer.zPosition = 0
pLayer.zPosition = 0 pLayer.zPosition = 0
view.visualLayer.masksToBounds = !(.centerRadialBeyondBounds == view.pulse.animation || .radialBeyondBounds == view.pulse.animation) visualLayer.masksToBounds = !(.centerRadialBeyondBounds == view.pulse.animation || .radialBeyondBounds == view.pulse.animation)
Motion.disable(animations: { [view = view] in Motion.disable(animations: {
bLayer.frame = view.visualLayer.bounds bLayer.frame = visualLayer.bounds
pLayer.bounds = CGRect(x: 0, y: 0, width: n, height: n) pLayer.bounds = CGRect(x: 0, y: 0, width: n, height: n)
switch view.pulse.animation { switch view.pulse.animation {
...@@ -113,8 +113,9 @@ internal struct MotionPulseAnimation<T: UIView> where T: Pulsable { ...@@ -113,8 +113,9 @@ internal struct MotionPulseAnimation<T: UIView> where T: Pulsable {
animations too. animations too.
- Parameter pulse: A Pulse instance. - Parameter pulse: A Pulse instance.
*/ */
internal static func pulseContractAnimation(_ view: inout T) { internal static func contractAnimation(view: inout T) {
guard let bLayer = view.pulse.layers.popLast() else { var view = view
guard let bLayer = view.pulse.layers.last else {
return return
} }
...@@ -122,7 +123,7 @@ internal struct MotionPulseAnimation<T: UIView> where T: Pulsable { ...@@ -122,7 +123,7 @@ internal struct MotionPulseAnimation<T: UIView> where T: Pulsable {
return return
} }
Motion.delay(time: animated ? 0 : 0.15) { [view = view] in Motion.delay(time: animated ? 0 : 0.15) {
guard let pLayer = bLayer.sublayers?.first as? CAShapeLayer else { guard let pLayer = bLayer.sublayers?.first as? CAShapeLayer else {
return return
} }
......
...@@ -32,12 +32,14 @@ import UIKit ...@@ -32,12 +32,14 @@ import UIKit
internal protocol Pulsable { internal protocol Pulsable {
var pulse: Pulse { get set } var pulse: Pulse { get set }
var visualLayer: CAShapeLayer { get set } var pulseAnimation: PulseAnimation { get set }
var pulseColor: UIColor { get set }
var pulseOpacity: CGFloat { get set }
} }
internal struct Pulse { internal struct Pulse {
/// An Array of layers. /// An Array of layers.
internal lazy var layers = [CAShapeLayer]() internal var layers = [CAShapeLayer]()
/// A UIColor. /// A UIColor.
internal var color = Color.grey.base internal var color = Color.grey.base
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
open class PulseView: View, Pulsable { open class PulseView: View, Pulsable {
/// A Pulse reference. /// A Pulse reference.
internal internal(set) lazy var pulse: Pulse = Pulse() internal var pulse = Pulse()
/// PulseAnimation value. /// PulseAnimation value.
open var pulseAnimation: PulseAnimation { open var pulseAnimation: PulseAnimation {
...@@ -75,12 +75,12 @@ open class PulseView: View, Pulsable { ...@@ -75,12 +75,12 @@ open class PulseView: View, Pulsable {
let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
var s = self var s = self
MotionPulseAnimation<PulseView>.pulseExpandAnimation(&s, point: p) MotionPulse<PulseView>.expandAnimation(view: &s, visualLayer: visualLayer, point: p)
Motion.delay(time: 0.35) { [weak self] in Motion.delay(time: 0.35) { [weak self] in
guard var s = self else { guard var s = self else {
return return
} }
MotionPulseAnimation<PulseView>.pulseContractAnimation(&s) MotionPulse<PulseView>.contractAnimation(view: &s)
} }
} }
...@@ -93,7 +93,7 @@ open class PulseView: View, Pulsable { ...@@ -93,7 +93,7 @@ open class PulseView: View, Pulsable {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event) super.touchesBegan(touches, with: event)
var s = self var s = self
MotionPulseAnimation<PulseView>.pulseExpandAnimation(&s, point: layer.convert(touches.first!.location(in: s), from: layer)) MotionPulse<PulseView>.expandAnimation(view: &s, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer))
} }
/** /**
...@@ -105,7 +105,7 @@ open class PulseView: View, Pulsable { ...@@ -105,7 +105,7 @@ open class PulseView: View, Pulsable {
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event) super.touchesEnded(touches, with: event)
var s = self var s = self
MotionPulseAnimation<PulseView>.pulseContractAnimation(&s) MotionPulse<PulseView>.contractAnimation(view: &s)
} }
/** /**
...@@ -117,6 +117,6 @@ open class PulseView: View, Pulsable { ...@@ -117,6 +117,6 @@ open class PulseView: View, Pulsable {
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event) super.touchesCancelled(touches, with: event)
var s = self var s = self
MotionPulseAnimation<PulseView>.pulseContractAnimation(&s) MotionPulse<PulseView>.contractAnimation(view: &s)
} }
} }
...@@ -107,7 +107,7 @@ open class SnackbarController: RootController { ...@@ -107,7 +107,7 @@ open class SnackbarController: RootController {
- Parameter status: A SnackbarStatus enum value. - Parameter status: A SnackbarStatus enum value.
*/ */
@discardableResult @discardableResult
open func animate(snackbar status: SnackbarStatus, delay: TimeInterval = 0, animations: ((Snackbar) -> Void)? = nil, completion: ((Snackbar) -> Void)? = nil) -> AnimationDelayCancelBlock? { open func animate(snackbar status: SnackbarStatus, delay: TimeInterval = 0, animations: ((Snackbar) -> Void)? = nil, completion: ((Snackbar) -> Void)? = nil) -> MotionDelayCancelBlock? {
return Motion.delay(time: delay) { [weak self, status = status, animations = animations, completion = completion] in return Motion.delay(time: delay) { [weak self, status = status, animations = animations, completion = completion] in
guard let s = self else { guard let s = self else {
return return
......
...@@ -37,10 +37,10 @@ open class TableViewCell: UITableViewCell, Pulsable { ...@@ -37,10 +37,10 @@ open class TableViewCell: UITableViewCell, Pulsable {
allows the dropshadow effect on the backing layer, while clipping allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer. the image to a desired shape within the visualLayer.
*/ */
open internal(set) lazy var visualLayer = CAShapeLayer() open internal(set) var visualLayer = CAShapeLayer()
/// A Pulse reference. /// A Pulse reference.
internal internal(set) lazy var pulse: Pulse = Pulse() internal var pulse = Pulse()
/// PulseAnimation value. /// PulseAnimation value.
open var pulseAnimation: PulseAnimation { open var pulseAnimation: PulseAnimation {
...@@ -121,12 +121,12 @@ open class TableViewCell: UITableViewCell, Pulsable { ...@@ -121,12 +121,12 @@ open class TableViewCell: UITableViewCell, Pulsable {
let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
var s = self var s = self
MotionPulseAnimation<TableViewCell>.pulseExpandAnimation(&s, point: p) MotionPulse<TableViewCell>.expandAnimation(view: &s, visualLayer: visualLayer, point: p)
Motion.delay(time: 0.35) { [weak self] in Motion.delay(time: 0.35) { [weak self] in
guard var s = self else { guard var s = self else {
return return
} }
MotionPulseAnimation<TableViewCell>.pulseContractAnimation(&s) MotionPulse<TableViewCell>.contractAnimation(view: &s)
} }
} }
...@@ -139,7 +139,7 @@ open class TableViewCell: UITableViewCell, Pulsable { ...@@ -139,7 +139,7 @@ open class TableViewCell: UITableViewCell, Pulsable {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event) super.touchesBegan(touches, with: event)
var s = self var s = self
MotionPulseAnimation<TableViewCell>.pulseExpandAnimation(&s, point: layer.convert(touches.first!.location(in: s), from: layer)) MotionPulse<TableViewCell>.expandAnimation(view: &s, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer))
} }
/** /**
...@@ -151,7 +151,7 @@ open class TableViewCell: UITableViewCell, Pulsable { ...@@ -151,7 +151,7 @@ open class TableViewCell: UITableViewCell, Pulsable {
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event) super.touchesEnded(touches, with: event)
var s = self var s = self
MotionPulseAnimation<TableViewCell>.pulseContractAnimation(&s) MotionPulse<TableViewCell>.contractAnimation(view: &s)
} }
/** /**
...@@ -163,7 +163,7 @@ open class TableViewCell: UITableViewCell, Pulsable { ...@@ -163,7 +163,7 @@ open class TableViewCell: UITableViewCell, Pulsable {
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event) super.touchesCancelled(touches, with: event)
var s = self var s = self
MotionPulseAnimation<TableViewCell>.pulseContractAnimation(&s) MotionPulse<TableViewCell>.contractAnimation(view: &s)
} }
/** /**
......
...@@ -37,7 +37,7 @@ open class View: UIView { ...@@ -37,7 +37,7 @@ open class View: UIView {
allows the dropshadow effect on the backing layer, while clipping allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer. the image to a desired shape within the visualLayer.
*/ */
open internal(set) lazy var visualLayer = CAShapeLayer() open internal(set) var visualLayer = CAShapeLayer()
/** /**
A property that manages an image for the visualLayer's contents A property that manages an image for the visualLayer's contents
......
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