Commit 9756078e by Daniel Dahan

development: added Pulse object to replace pulse behavior

parent 10bbe53e
...@@ -58,12 +58,12 @@ class ViewController: UIViewController { ...@@ -58,12 +58,12 @@ class ViewController: UIViewController {
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.white) favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.white)
favoriteButton.pulseColor = Color.white favoriteButton.pulse.color = Color.white
} }
private func prepareShareButton() { private func prepareShareButton() {
shareButton = IconButton(image: Icon.cm.share, tintColor: Color.white) shareButton = IconButton(image: Icon.cm.share, tintColor: Color.white)
shareButton.pulseColor = Color.white shareButton.pulse.color = Color.white
} }
private func prepareTitleLabel() { private func prepareTitleLabel() {
......
...@@ -80,7 +80,7 @@ class ViewController: UIViewController { ...@@ -80,7 +80,7 @@ class ViewController: UIViewController {
private func prepareRaisedButton() { private func prepareRaisedButton() {
let button = RaisedButton(title: "Raised Button", titleColor: Color.white) let button = RaisedButton(title: "Raised Button", titleColor: Color.white)
button.pulseColor = Color.white button.pulse.color = Color.white
button.backgroundColor = Color.blue.base button.backgroundColor = Color.blue.base
view.layout(button) view.layout(button)
......
...@@ -64,7 +64,7 @@ class ViewController: UIViewController { ...@@ -64,7 +64,7 @@ class ViewController: UIViewController {
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.blue.base) favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.blue.base)
favoriteButton.pulseColor = Color.blue.base favoriteButton.pulse.color = Color.blue.base
} }
private func prepareBottomBar() { private func prepareBottomBar() {
......
...@@ -81,7 +81,7 @@ class ViewController: UIViewController { ...@@ -81,7 +81,7 @@ class ViewController: UIViewController {
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.grey.base) favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.grey.base)
favoriteButton.pulseColor = Color.grey.base favoriteButton.pulse.color = Color.grey.base
} }
private func prepareBottomBar() { private func prepareBottomBar() {
......
...@@ -77,7 +77,7 @@ class RootViewController: UIViewController { ...@@ -77,7 +77,7 @@ class RootViewController: UIViewController {
private func prepareNextButton() { private func prepareNextButton() {
nextButton = FlatButton() nextButton = FlatButton()
nextButton.pulseAnimation = .none nextButton.pulse.animation = .none
nextButton.addTarget(self, action: #selector(handleNextButton), for: .touchUpInside) nextButton.addTarget(self, action: #selector(handleNextButton), for: .touchUpInside)
view.layout(nextButton).edges() view.layout(nextButton).edges()
} }
......
...@@ -34,7 +34,7 @@ import Material ...@@ -34,7 +34,7 @@ import Material
class PhotoLibraryCollectionViewCell: CollectionViewCell { class PhotoLibraryCollectionViewCell: CollectionViewCell {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
pulseAnimation = .backing pulse.animation = .backing
contentsGravityPreset = .ResizeAspectFill contentsGravityPreset = .ResizeAspectFill
} }
} }
...@@ -51,7 +51,7 @@ class RootViewController: UIViewController { ...@@ -51,7 +51,7 @@ class RootViewController: UIViewController {
private func prepareUndoButton() { private func prepareUndoButton() {
undoButton = FlatButton(title: "Undo", titleColor: Color.yellow.base) undoButton = FlatButton(title: "Undo", titleColor: Color.yellow.base)
undoButton.pulseAnimation = .backing undoButton.pulse.animation = .backing
undoButton.titleLabel?.font = RobotoFont.regular(with: 14) undoButton.titleLabel?.font = RobotoFont.regular(with: 14)
} }
......
...@@ -48,15 +48,15 @@ class ViewController: UIViewController { ...@@ -48,15 +48,15 @@ class ViewController: UIViewController {
private func prepareButtons() { private func prepareButtons() {
let btn1 = FlatButton(title: "Library", titleColor: Color.blueGrey.base) let btn1 = FlatButton(title: "Library", titleColor: Color.blueGrey.base)
btn1.pulseAnimation = .none btn1.pulse.animation = .none
buttons.append(btn1) buttons.append(btn1)
let btn2 = FlatButton(title: "Photo", titleColor: Color.blueGrey.base) let btn2 = FlatButton(title: "Photo", titleColor: Color.blueGrey.base)
btn2.pulseAnimation = .none btn2.pulse.animation = .none
buttons.append(btn2) buttons.append(btn2)
let btn3 = FlatButton(title: "Video", titleColor: Color.blueGrey.base) let btn3 = FlatButton(title: "Video", titleColor: Color.blueGrey.base)
btn3.pulseAnimation = .none btn3.pulse.animation = .none
buttons.append(btn3) buttons.append(btn3)
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
962864621D54111D00690B69 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; }; 962864621D54111D00690B69 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; };
962864631D54111D00690B69 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; }; 962864631D54111D00690B69 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; };
9631A7C11D95E3AC00CFB109 /* PresenterCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */; }; 9631A7C11D95E3AC00CFB109 /* PresenterCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */; };
9631A7C71D95E5D900CFB109 /* Pulse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C61D95E5D900CFB109 /* Pulse.swift */; };
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; }; 96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; }; 963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; };
963FBEFD1D669510008F8512 /* Snackbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; }; 963FBEFD1D669510008F8512 /* Snackbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; };
...@@ -228,6 +229,7 @@ ...@@ -228,6 +229,7 @@
9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; }; 9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; };
962864611D54111D00690B69 /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; }; 962864611D54111D00690B69 /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; };
9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresenterCard.swift; sourceTree = "<group>"; }; 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresenterCard.swift; sourceTree = "<group>"; };
9631A7C61D95E5D900CFB109 /* Pulse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pulse.swift; sourceTree = "<group>"; };
96334EF51C8B84660083986B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96334EF51C8B84660083986B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
963832361B88DFD80015F710 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 963832361B88DFD80015F710 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; };
963832411B88DFD80015F710 /* Material.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Material.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 963832411B88DFD80015F710 /* Material.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Material.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
...@@ -414,6 +416,16 @@ ...@@ -414,6 +416,16 @@
name = BottomTabBar; name = BottomTabBar;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9631A7C51D95E5C400CFB109 /* Pulse */ = {
isa = PBXGroup;
children = (
9631A7C61D95E5D900CFB109 /* Pulse.swift */,
96BCB7841CB40DC500C806FE /* PulseView.swift */,
96BCB7821CB40DC500C806FE /* PulseAnimation.swift */,
);
name = Pulse;
sourceTree = "<group>";
};
9638322C1B88DFD80015F710 = { 9638322C1B88DFD80015F710 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -561,6 +573,7 @@ ...@@ -561,6 +573,7 @@
96BCB8011CB40F1700C806FE /* Navigation */, 96BCB8011CB40F1700C806FE /* Navigation */,
962DDD071D6FBBB7001C307C /* Page */, 962DDD071D6FBBB7001C307C /* Page */,
96EA9A411D4E68E60052C74D /* PhotoLibrary */, 96EA9A411D4E68E60052C74D /* PhotoLibrary */,
9631A7C51D95E5C400CFB109 /* Pulse */,
96264BE51D833CFF00576F37 /* Reminders */, 96264BE51D833CFF00576F37 /* Reminders */,
963FBF031D6696EF008F8512 /* SearchBar */, 963FBF031D6696EF008F8512 /* SearchBar */,
963FBEFB1D6694E8008F8512 /* Snackbar */, 963FBEFB1D6694E8008F8512 /* Snackbar */,
...@@ -710,7 +723,6 @@ ...@@ -710,7 +723,6 @@
96BCB76D1CB40DC500C806FE /* Animation.swift */, 96BCB76D1CB40DC500C806FE /* Animation.swift */,
96BCB78B1CB40DC500C806FE /* TransitionAnimation.swift */, 96BCB78B1CB40DC500C806FE /* TransitionAnimation.swift */,
96BCB77E1CB40DC500C806FE /* KeyframeAnimation.swift */, 96BCB77E1CB40DC500C806FE /* KeyframeAnimation.swift */,
96BCB7821CB40DC500C806FE /* PulseAnimation.swift */,
96E3C39D1D3A1D0C0086A024 /* BasicAnimation.swift */, 96E3C39D1D3A1D0C0086A024 /* BasicAnimation.swift */,
); );
name = Animation; name = Animation;
...@@ -743,7 +755,6 @@ ...@@ -743,7 +755,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96BCB78C1CB40DC500C806FE /* View.swift */, 96BCB78C1CB40DC500C806FE /* View.swift */,
96BCB7841CB40DC500C806FE /* PulseView.swift */,
); );
name = View; name = View;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1103,6 +1114,7 @@ ...@@ -1103,6 +1114,7 @@
96BCB7C81CB40DC500C806FE /* Label.swift in Sources */, 96BCB7C81CB40DC500C806FE /* Label.swift in Sources */,
96BCB7A21CB40DC500C806FE /* BottomTabBar.swift in Sources */, 96BCB7A21CB40DC500C806FE /* BottomTabBar.swift in Sources */,
96BCB7BD1CB40DC500C806FE /* CollectionViewDelegate.swift in Sources */, 96BCB7BD1CB40DC500C806FE /* CollectionViewDelegate.swift in Sources */,
9631A7C71D95E5D900CFB109 /* Pulse.swift in Sources */,
961F18E81CD93E3E008927C5 /* ErrorTextField.swift in Sources */, 961F18E81CD93E3E008927C5 /* ErrorTextField.swift in Sources */,
96BCB7D01CB40DC500C806FE /* InterimSpace.swift in Sources */, 96BCB7D01CB40DC500C806FE /* InterimSpace.swift in Sources */,
96BCB7E81CB40DC500C806FE /* Toolbar.swift in Sources */, 96BCB7E81CB40DC500C806FE /* Toolbar.swift in Sources */,
......
...@@ -40,19 +40,9 @@ open class Button: UIButton { ...@@ -40,19 +40,9 @@ open class Button: UIButton {
*/ */
open private(set) lazy var visualLayer = CAShapeLayer() open private(set) lazy var visualLayer = CAShapeLayer()
/// An Array of pulse layers. /// A Pulse reference.
open private(set) lazy var pulseLayers = [CAShapeLayer]() @IBInspectable
open internal(set) lazy var pulse: Pulse = Pulse()
/// The opacity value for the pulse animation.
@IBInspectable
open var pulseOpacity: CGFloat = 0.25
/// The color of the pulse effect.
@IBInspectable
open var pulseColor = Color.grey.base
/// The type of PulseAnimation.
public var pulseAnimation = PulseAnimation.pointWithBacking
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's backgroundColor.
@IBInspectable @IBInspectable
...@@ -178,13 +168,13 @@ open class Button: UIButton { ...@@ -178,13 +168,13 @@ open class Button: UIButton {
from the center. from the center.
*/ */
open func pulse(point: CGPoint? = nil) { open func pulse(point: CGPoint? = nil) {
let p = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: p, width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: p, width: width, height: height, pulse: &pulse)
Animation.delay(time: 0.35) { [weak self] in Animation.delay(time: 0.35) { [weak self] in
guard let s = self else { guard let s = self else {
return return
} }
Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulseColor: s.pulseColor, pulseLayers: &s.pulseLayers, pulseAnimation: s.pulseAnimation) Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulse: &s.pulse)
} }
} }
...@@ -196,7 +186,7 @@ open class Button: UIButton { ...@@ -196,7 +186,7 @@ open class Button: UIButton {
*/ */
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)
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulse: &pulse)
} }
/** /**
...@@ -207,7 +197,7 @@ open class Button: UIButton { ...@@ -207,7 +197,7 @@ open class Button: UIButton {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
...@@ -218,7 +208,7 @@ open class Button: UIButton { ...@@ -218,7 +208,7 @@ open class Button: UIButton {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
......
...@@ -40,19 +40,9 @@ open class CollectionReusableView: UICollectionReusableView { ...@@ -40,19 +40,9 @@ open class CollectionReusableView: UICollectionReusableView {
*/ */
open private(set) lazy var visualLayer = CAShapeLayer() open private(set) lazy var visualLayer = CAShapeLayer()
/// An Array of pulse layers. /// A Pulse reference.
open private(set) lazy var pulseLayers = [CAShapeLayer]() @IBInspectable
open internal(set) lazy var pulse: Pulse = Pulse()
/// The opcaity value for the pulse animation.
@IBInspectable
open var pulseOpacity: CGFloat = 0.25
/// The color of the pulse effect.
@IBInspectable
open var pulseColor = Color.grey.base
/// The type of PulseAnimation.
open var pulseAnimation = PulseAnimation.pointWithBacking
/** /**
A property that manages an image for the visualLayer's contents A property that manages an image for the visualLayer's contents
...@@ -216,12 +206,12 @@ open class CollectionReusableView: UICollectionReusableView { ...@@ -216,12 +206,12 @@ open class CollectionReusableView: UICollectionReusableView {
*/ */
open func pulse(point: CGPoint? = nil) { open func pulse(point: CGPoint? = nil) {
let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: p, width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: p, width: width, height: height, pulse: &pulse)
Animation.delay(time: 0.35) { [weak self] in Animation.delay(time: 0.35) { [weak self] in
guard let s = self else { guard let s = self else {
return return
} }
Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulseColor: s.pulseColor, pulseLayers: &s.pulseLayers, pulseAnimation: s.pulseAnimation) Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulse: &s.pulse)
} }
} }
...@@ -233,7 +223,7 @@ open class CollectionReusableView: UICollectionReusableView { ...@@ -233,7 +223,7 @@ open class CollectionReusableView: UICollectionReusableView {
*/ */
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)
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulse: &pulse)
} }
/** /**
...@@ -244,7 +234,7 @@ open class CollectionReusableView: UICollectionReusableView { ...@@ -244,7 +234,7 @@ open class CollectionReusableView: UICollectionReusableView {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
...@@ -255,7 +245,7 @@ open class CollectionReusableView: UICollectionReusableView { ...@@ -255,7 +245,7 @@ open class CollectionReusableView: UICollectionReusableView {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
...@@ -267,7 +257,7 @@ open class CollectionReusableView: UICollectionReusableView { ...@@ -267,7 +257,7 @@ open class CollectionReusableView: UICollectionReusableView {
*/ */
open func prepare() { open func prepare() {
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
pulseAnimation = .none pulse.animation = .none
prepareVisualLayer() prepareVisualLayer()
} }
......
...@@ -43,19 +43,9 @@ open class CollectionViewCell: UICollectionViewCell { ...@@ -43,19 +43,9 @@ open class CollectionViewCell: UICollectionViewCell {
*/ */
open private(set) lazy var visualLayer = CAShapeLayer() open private(set) lazy var visualLayer = CAShapeLayer()
/// An Array of pulse layers. /// A Pulse reference.
open private(set) lazy var pulseLayers = [CAShapeLayer]() @IBInspectable
open internal(set) lazy var pulse: Pulse = Pulse()
/// The opcaity value for the pulse animation.
@IBInspectable
open var pulseOpacity: CGFloat = 0.25
/// The color of the pulse effect.
@IBInspectable
open var pulseColor = Color.grey.base
/// The type of PulseAnimation.
open var pulseAnimation = PulseAnimation.pointWithBacking
/** /**
A property that manages an image for the visualLayer's contents A property that manages an image for the visualLayer's contents
...@@ -226,12 +216,12 @@ open class CollectionViewCell: UICollectionViewCell { ...@@ -226,12 +216,12 @@ open class CollectionViewCell: UICollectionViewCell {
*/ */
open func pulse(point: CGPoint? = nil) { open func pulse(point: CGPoint? = nil) {
let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: p, width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: p, width: width, height: height, pulse: &pulse)
Animation.delay(time: 0.35) { [weak self] in Animation.delay(time: 0.35) { [weak self] in
guard let s = self else { guard let s = self else {
return return
} }
Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulseColor: s.pulseColor, pulseLayers: &s.pulseLayers, pulseAnimation: s.pulseAnimation) Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulse: &s.pulse)
} }
} }
...@@ -243,7 +233,7 @@ open class CollectionViewCell: UICollectionViewCell { ...@@ -243,7 +233,7 @@ open class CollectionViewCell: UICollectionViewCell {
*/ */
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)
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulse: &pulse)
} }
/** /**
...@@ -254,7 +244,7 @@ open class CollectionViewCell: UICollectionViewCell { ...@@ -254,7 +244,7 @@ open class CollectionViewCell: UICollectionViewCell {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
...@@ -265,7 +255,7 @@ open class CollectionViewCell: UICollectionViewCell { ...@@ -265,7 +255,7 @@ open class CollectionViewCell: UICollectionViewCell {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
......
...@@ -48,7 +48,7 @@ open class Divider { ...@@ -48,7 +48,7 @@ open class Divider {
/// A reference to the height. /// A reference to the height.
public var height: CGFloat public var height: CGFloat
/// Divider color. /// A UIColor.
open var color: UIColor? { open var color: UIColor? {
get { get {
return line?.backgroundColor return line?.backgroundColor
......
...@@ -42,8 +42,8 @@ open class FabButton: Button { ...@@ -42,8 +42,8 @@ open class FabButton: Button {
super.prepare() super.prepare()
depthPreset = .depth1 depthPreset = .depth1
shapePreset = .circle shapePreset = .circle
pulseAnimation = .centerWithBacking pulse.animation = .centerWithBacking
pulseColor = Color.white pulse.color = Color.white
tintColor = Color.white tintColor = Color.white
backgroundColor = Color.red.base backgroundColor = Color.red.base
} }
......
...@@ -40,6 +40,6 @@ open class IconButton: Button { ...@@ -40,6 +40,6 @@ open class IconButton: Button {
*/ */
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
pulseAnimation = .center pulse.animation = .center
} }
} }
...@@ -36,7 +36,7 @@ private var PageTabBarItemKey: UInt8 = 0 ...@@ -36,7 +36,7 @@ private var PageTabBarItemKey: UInt8 = 0
open class PageTabBarItem: FlatButton { open class PageTabBarItem: FlatButton {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
pulseAnimation = .none pulse.animation = .none
} }
} }
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
open class Pulse {
/// An Array of layers.
internal lazy var layers = [CAShapeLayer]()
/// A UIColor.
@IBInspectable
open var color = Color.grey.base
/// A reference to the PulseAnimation.
open var animation = PulseAnimation.pointWithBacking
/// The opcaity value for the pulse animation.
@IBInspectable
open var opacity: CGFloat = 0.18
}
...@@ -46,35 +46,34 @@ internal extension Animation { ...@@ -46,35 +46,34 @@ internal extension Animation {
/** /**
Triggers the expanding animation. Triggers the expanding animation.
- Parameter layer: Container CALayer. - Parameter layer: Container CALayer.
- Parameter visualLayer: A CAShapeLayer for the pulseLayer. - Parameter visualLayer: A CAShapeLayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter point: A point to pulse from. - Parameter point: A point to pulse from.
- Parameter width: Container width. - Parameter width: Container width.
- Parameter height: Container height. - Parameter height: Container height.
- Parameter duration: Animation duration. - Parameter duration: Animation duration.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation. - Parameter pulse: A Pulse instance.
*/ */
internal static func pulseExpandAnimation(layer: CALayer, visualLayer: CALayer, pulseColor: UIColor, pulseOpacity: CGFloat, point: CGPoint, width: CGFloat, height: CGFloat, pulseLayers: inout Array<CAShapeLayer>, pulseAnimation: PulseAnimation) { internal static func pulseExpandAnimation(layer: CALayer, visualLayer: CALayer, point: CGPoint, width: CGFloat, height: CGFloat, pulse: inout Pulse) {
guard .none != pulseAnimation else { guard .none != pulse.animation else {
return return
} }
let n = .center == pulseAnimation ? width < height ? width : height : width < height ? height : width let n = .center == pulse.animation ? width < height ? width : height : width < height ? height : width
let bLayer = CAShapeLayer() let bLayer = CAShapeLayer()
let pLayer = CAShapeLayer() let pLayer = CAShapeLayer()
bLayer.addSublayer(pLayer) bLayer.addSublayer(pLayer)
pulseLayers.insert(bLayer, at: 0) pulse.layers.insert(bLayer, at: 0)
visualLayer.addSublayer(bLayer) visualLayer.addSublayer(bLayer)
visualLayer.masksToBounds = !(.centerRadialBeyondBounds == pulseAnimation || .radialBeyondBounds == pulseAnimation) visualLayer.masksToBounds = !(.centerRadialBeyondBounds == pulse.animation || .radialBeyondBounds == pulse.animation)
Animation.animationDisabled(animations: { Animation.animationDisabled(animations: { [visualLayer = visualLayer, pulse = pulse] in
bLayer.frame = 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 pulseAnimation { switch pulse.animation {
case .center, .centerWithBacking, .centerRadialBeyondBounds: case .center, .centerWithBacking, .centerRadialBeyondBounds:
pLayer.position = CGPoint(x: width / 2, y: height / 2) pLayer.position = CGPoint(x: width / 2, y: height / 2)
default: default:
...@@ -82,21 +81,21 @@ internal extension Animation { ...@@ -82,21 +81,21 @@ internal extension Animation {
} }
pLayer.cornerRadius = n / 2 pLayer.cornerRadius = n / 2
pLayer.backgroundColor = pulseColor.withAlphaComponent(pulseOpacity).cgColor pLayer.backgroundColor = pulse.color.withAlphaComponent(pulse.opacity).cgColor
pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransform(scaleX: 0, y: 0)) pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransform(scaleX: 0, y: 0))
}) })
bLayer.setValue(false, forKey: "animated") bLayer.setValue(false, forKey: "animated")
let duration: CFTimeInterval = .center == pulseAnimation ? 0.16125 : 0.325 let duration: CFTimeInterval = .center == pulse.animation ? 0.16125 : 0.325
switch pulseAnimation { switch pulse.animation {
case .centerWithBacking, .backing, .pointWithBacking: case .centerWithBacking, .backing, .pointWithBacking:
bLayer.add(Animation.backgroundColor(color: pulseColor.withAlphaComponent(pulseOpacity / 2), duration: duration), forKey: nil) bLayer.add(Animation.backgroundColor(color: pulse.color.withAlphaComponent(pulse.opacity / 2), duration: duration), forKey: nil)
default:break default:break
} }
switch pulseAnimation { switch pulse.animation {
case .center, .centerWithBacking, .centerRadialBeyondBounds, .radialBeyondBounds, .point, .pointWithBacking: case .center, .centerWithBacking, .centerRadialBeyondBounds, .radialBeyondBounds, .point, .pointWithBacking:
pLayer.add(Animation.scale(scale: 1, duration: duration), forKey: nil) pLayer.add(Animation.scale(scale: 1, duration: duration), forKey: nil)
default:break default:break
...@@ -110,11 +109,11 @@ internal extension Animation { ...@@ -110,11 +109,11 @@ internal extension Animation {
/** /**
Triggers the contracting animation. Triggers the contracting animation.
- Parameter layer: Container CALayer. - Parameter layer: Container CALayer.
- Parameter pulseColor: The UIColor for the pulse. - Parameter visualLayer: A CAShapeLayer.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation. - Parameter pulse: A Pulse instance.
*/ */
internal static func pulseContractAnimation(layer: CALayer, visualLayer: CALayer, pulseColor: UIColor, pulseLayers: inout Array<CAShapeLayer>, pulseAnimation: PulseAnimation) { internal static func pulseContractAnimation(layer: CALayer, visualLayer: CALayer, pulse: inout Pulse) {
guard let bLayer = pulseLayers.popLast() else { guard let bLayer = pulse.layers.popLast() else {
return return
} }
...@@ -122,24 +121,24 @@ internal extension Animation { ...@@ -122,24 +121,24 @@ internal extension Animation {
return return
} }
Animation.delay(time: animated ? 0 : 0.15) { Animation.delay(time: animated ? 0 : 0.15) { [pulse = pulse] in
guard let pLayer = bLayer.sublayers?.first as? CAShapeLayer else { guard let pLayer = bLayer.sublayers?.first as? CAShapeLayer else {
return return
} }
let duration = 0.325 let duration = 0.325
switch pulseAnimation { switch pulse.animation {
case .centerWithBacking, .backing, .pointWithBacking: case .centerWithBacking, .backing, .pointWithBacking:
bLayer.add(Animation.backgroundColor(color: pulseColor.withAlphaComponent(0), duration: duration), forKey: nil) bLayer.add(Animation.backgroundColor(color: pulse.color.withAlphaComponent(0), duration: duration), forKey: nil)
default:break default:break
} }
switch pulseAnimation { switch pulse.animation {
case .center, .centerWithBacking, .centerRadialBeyondBounds, .radialBeyondBounds, .point, .pointWithBacking: case .center, .centerWithBacking, .centerRadialBeyondBounds, .radialBeyondBounds, .point, .pointWithBacking:
pLayer.add(Animation.animationGroup(animations: [ pLayer.add(Animation.animationGroup(animations: [
Animation.scale(scale: .center == pulseAnimation ? 1 : 1.325), Animation.scale(scale: .center == pulse.animation ? 1 : 1.325),
Animation.backgroundColor(color: pulseColor.withAlphaComponent(0)) Animation.backgroundColor(color: pulse.color.withAlphaComponent(0))
], duration: duration), forKey: nil) ], duration: duration), forKey: nil)
default:break default:break
} }
......
...@@ -31,19 +31,9 @@ ...@@ -31,19 +31,9 @@
import UIKit import UIKit
open class PulseView: View { open class PulseView: View {
/// An Array of pulse layers. /// A Pulse reference.
open private(set) lazy var pulseLayers = [CAShapeLayer]()
/// The opcaity value for the pulse animation.
@IBInspectable
open var pulseOpacity: CGFloat = 0.25
/// The color of the pulse effect.
@IBInspectable @IBInspectable
open var pulseColor = Color.grey.base open internal(set) lazy var pulse: Pulse = Pulse()
/// The type of PulseAnimation.
open var pulseAnimation = PulseAnimation.pointWithBacking
/** /**
Triggers the pulse animation. Triggers the pulse animation.
...@@ -52,12 +42,12 @@ open class PulseView: View { ...@@ -52,12 +42,12 @@ open class PulseView: View {
*/ */
open func pulse(point: CGPoint? = nil) { open func pulse(point: CGPoint? = nil) {
let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: p, width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: p, width: width, height: height, pulse: &pulse)
Animation.delay(time: 0.35) { [weak self] in Animation.delay(time: 0.35) { [weak self] in
guard let s = self else { guard let s = self else {
return return
} }
Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulseColor: s.pulseColor, pulseLayers: &s.pulseLayers, pulseAnimation: s.pulseAnimation) Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulse: &s.pulse)
} }
} }
...@@ -69,7 +59,7 @@ open class PulseView: View { ...@@ -69,7 +59,7 @@ open class PulseView: View {
*/ */
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)
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulse: &pulse)
} }
/** /**
...@@ -80,7 +70,7 @@ open class PulseView: View { ...@@ -80,7 +70,7 @@ open class PulseView: View {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
...@@ -91,6 +81,6 @@ open class PulseView: View { ...@@ -91,6 +81,6 @@ open class PulseView: View {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
} }
...@@ -413,7 +413,7 @@ open class Switch: UIControl { ...@@ -413,7 +413,7 @@ open class Switch: UIControl {
/// Prepares the button. /// Prepares the button.
private func prepareButton() { private func prepareButton() {
button.pulseAnimation = .none button.pulse.animation = .none
button.addTarget(self, action: #selector(handleTouchUpInside), for: .touchUpInside) button.addTarget(self, action: #selector(handleTouchUpInside), for: .touchUpInside)
button.addTarget(self, action: #selector(handleTouchDragInside), for: .touchDragInside) button.addTarget(self, action: #selector(handleTouchDragInside), for: .touchDragInside)
button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchCancel) button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchCancel)
......
...@@ -39,19 +39,9 @@ open class TableViewCell: UITableViewCell { ...@@ -39,19 +39,9 @@ open class TableViewCell: UITableViewCell {
*/ */
open private(set) lazy var visualLayer = CAShapeLayer() open private(set) lazy var visualLayer = CAShapeLayer()
/// An Array of pulse layers. /// A Pulse reference.
open private(set) lazy var pulseLayers = [CAShapeLayer]()
/// The opcaity value for the pulse animation.
@IBInspectable
open var pulseOpacity: CGFloat = 0.25
/// The color of the pulse effect.
@IBInspectable @IBInspectable
open var pulseColor = Color.grey.base open internal(set) lazy var pulse: Pulse = Pulse()
/// The type of PulseAnimation.
open var pulseAnimation = PulseAnimation.pointWithBacking
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's backgroundColor.
@IBInspectable @IBInspectable
...@@ -100,12 +90,12 @@ open class TableViewCell: UITableViewCell { ...@@ -100,12 +90,12 @@ open class TableViewCell: UITableViewCell {
*/ */
open func pulse(point: CGPoint? = nil) { open func pulse(point: CGPoint? = nil) {
let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: p, width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: p, width: width, height: height, pulse: &pulse)
Animation.delay(time: 0.35) { [weak self] in Animation.delay(time: 0.35) { [weak self] in
guard let s = self else { guard let s = self else {
return return
} }
Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulseColor: s.pulseColor, pulseLayers: &s.pulseLayers, pulseAnimation: s.pulseAnimation) Animation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulse: &s.pulse)
} }
} }
...@@ -117,7 +107,7 @@ open class TableViewCell: UITableViewCell { ...@@ -117,7 +107,7 @@ open class TableViewCell: UITableViewCell {
*/ */
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)
Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulse: &pulse)
} }
/** /**
...@@ -128,7 +118,7 @@ open class TableViewCell: UITableViewCell { ...@@ -128,7 +118,7 @@ open class TableViewCell: UITableViewCell {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
...@@ -139,7 +129,7 @@ open class TableViewCell: UITableViewCell { ...@@ -139,7 +129,7 @@ open class TableViewCell: UITableViewCell {
*/ */
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)
Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) Animation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulse: &pulse)
} }
/** /**
......
...@@ -207,7 +207,7 @@ open class TextField: UITextField { ...@@ -207,7 +207,7 @@ open class TextField: UITextField {
if nil == clearIconButton { if nil == clearIconButton {
clearIconButton = IconButton(image: Icon.cm.clear, tintColor: placeholderColor) clearIconButton = IconButton(image: Icon.cm.clear, tintColor: placeholderColor)
clearIconButton!.contentEdgeInsets = .zero clearIconButton!.contentEdgeInsets = .zero
clearIconButton!.pulseAnimation = .center clearIconButton!.pulse.animation = .center
clearButtonMode = .never clearButtonMode = .never
rightViewMode = .whileEditing rightViewMode = .whileEditing
rightView = clearIconButton rightView = clearIconButton
...@@ -242,7 +242,7 @@ open class TextField: UITextField { ...@@ -242,7 +242,7 @@ open class TextField: UITextField {
if nil == visibilityIconButton { if nil == visibilityIconButton {
visibilityIconButton = IconButton(image: Icon.visibility, tintColor: placeholderColor.withAlphaComponent(isSecureTextEntry ? 0.38 : 0.54)) visibilityIconButton = IconButton(image: Icon.visibility, tintColor: placeholderColor.withAlphaComponent(isSecureTextEntry ? 0.38 : 0.54))
visibilityIconButton!.contentEdgeInsets = .zero visibilityIconButton!.contentEdgeInsets = .zero
visibilityIconButton!.pulseAnimation = .center visibilityIconButton!.pulse.animation = .center
isSecureTextEntry = true isSecureTextEntry = true
clearButtonMode = .never clearButtonMode = .never
rightViewMode = .whileEditing rightViewMode = .whileEditing
......
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