From 12ca56a0215cb03ae120523c717ce76df5b00755 Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Fri, 19 Jan 2018 10:37:20 +0530 Subject: [PATCH 1/7] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 910a28d..50f813b 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,11 @@ view.addSubview(bt1) [ShineButton](https://github.com/ChadCSong/ShineButton) +## Third Party Bindings + +### React Native +You may now use this library with [React Native](https://github.com/facebook/react-native) via the module [here](https://github.com/prscX/react-native-shine-button) + ## **License** WCLShineButton is released under the [MIT license](https://github.com/631106979/WCLShineButton/blob/master/LICENSE). See LICENSE for details. From ddd4deb3df47a451daecaf42417ce2948240a009 Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Sun, 22 Apr 2018 10:54:04 +0530 Subject: [PATCH 2/7] added support for react native projects - Added function to pass shine button type from objective-c - Added support for passing custom icons - Added getSelection API - Added @objc to initLayers --- WCLShineButton/WCLShineButton.swift | 37 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/WCLShineButton/WCLShineButton.swift b/WCLShineButton/WCLShineButton.swift index 9039daa..9feb4d0 100644 --- a/WCLShineButton/WCLShineButton.swift +++ b/WCLShineButton/WCLShineButton.swift @@ -52,9 +52,28 @@ public class WCLShineButton: UIControl { } /// button的图片 - public var image: WCLShineImage = .heart { + @IBInspectable public var image: NSString = ".heart" { willSet { - clickLayer.image = newValue + switch newValue { + case ".heart": + clickLayer.image = .heart + case ".like": + clickLayer.image = .like + case ".smile": + clickLayer.image = .smile + case ".star": + clickLayer.image = .star + default: + clickLayer.image = .heart + } +// clickLayer.image = newValue + } + } + + @objc public var customImage: UIImage = UIImage() { + willSet { + let image = WCLShineImage.custom(newValue) + clickLayer.image = image } } @@ -64,6 +83,11 @@ public class WCLShineButton: UIControl { clickLayer.clicked = isSelected } } + + @IBInspectable public var getSelection: Bool { + print("Clicked: \(clickLayer.clicked)") + return clickLayer.clicked + } private var clickLayer = WCLShineClickLayer() @@ -89,6 +113,7 @@ public class WCLShineButton: UIControl { initLayers() } + @objc public func setClicked(_ clicked: Bool, animated: Bool = true) { guard clicked != clickLayer.clicked else { return @@ -117,11 +142,12 @@ public class WCLShineButton: UIControl { super.touchesEnded(touches, with: event) if clickLayer.clicked == false { shineLayer.endAnim = { [weak self] in - self?.clickLayer.clicked = !(self?.clickLayer.clicked ?? false) +// self?.clickLayer.clicked = !(self?.clickLayer.clicked ?? false) self?.clickLayer.startAnim() - self?.isSelected = self?.clickLayer.clicked ?? false +// self?.isSelected = self?.clickLayer.clicked ?? false self?.sendActions(for: .valueChanged) } + clickLayer.clicked = true shineLayer.startAnim() }else { clickLayer.clicked = !clickLayer.clicked @@ -131,7 +157,8 @@ public class WCLShineButton: UIControl { } //MARK: Privater Methods - private func initLayers() { + @objc + public func initLayers() { clickLayer.animDuration = params.animDuration/3 shineLayer.params = params clickLayer.frame = bounds From 3c7233c688f604fe233a041c8428b23fbd57349e Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Sun, 26 Jan 2020 16:27:14 +0530 Subject: [PATCH 3/7] Update WCLShineButton.podspec --- WCLShineButton.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WCLShineButton.podspec b/WCLShineButton.podspec index 3b33f9f..cf908b1 100644 --- a/WCLShineButton.podspec +++ b/WCLShineButton.podspec @@ -20,5 +20,5 @@ Pod::Spec.new do |s| s.resources = 'WCLShineButton/WCLShineButton.bundle' s.frameworks = "UIKit" s.requires_arc = true - + s.swift_version = '4.2' end From 39ca8add060a595677bbe37d48c0d1666cd61dc5 Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Sun, 26 Jan 2020 17:10:24 +0530 Subject: [PATCH 4/7] Update WCLShineButton.swift --- WCLShineButton/WCLShineButton.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WCLShineButton/WCLShineButton.swift b/WCLShineButton/WCLShineButton.swift index 9feb4d0..a577340 100644 --- a/WCLShineButton/WCLShineButton.swift +++ b/WCLShineButton/WCLShineButton.swift @@ -167,3 +167,4 @@ public class WCLShineButton: UIControl { layer.addSublayer(shineLayer) } } + From d79a2bcc63f350f44321b11eb1dbf76f682ba131 Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Sun, 26 Jan 2020 17:10:46 +0530 Subject: [PATCH 5/7] Update WCLShineAngleLayer.swift --- WCLShineButton/WCLShineAngleLayer.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/WCLShineButton/WCLShineAngleLayer.swift b/WCLShineButton/WCLShineAngleLayer.swift index 7717364..7436edb 100644 --- a/WCLShineButton/WCLShineAngleLayer.swift +++ b/WCLShineButton/WCLShineAngleLayer.swift @@ -76,7 +76,7 @@ class WCLShineAngleLayer: CALayer, CAAnimationDelegate { } let angleAnim = CABasicAnimation(keyPath: "transform.rotation") angleAnim.duration = params.animDuration * 0.87 - angleAnim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) + angleAnim.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) angleAnim.fromValue = 0 angleAnim.toValue = CGFloat(params.shineTurnAngle)*CGFloat(Double.pi)/180 angleAnim.delegate = self @@ -94,7 +94,7 @@ class WCLShineAngleLayer: CALayer, CAAnimationDelegate { }else { displaylink?.frameInterval = 6 } - displaylink?.add(to: .current, forMode: .commonModes) + displaylink?.add(to: .current, forMode: RunLoop.Mode.common) } private func addShines() { @@ -145,9 +145,9 @@ class WCLShineAngleLayer: CALayer, CAAnimationDelegate { let center = getShineCenter(angle: angle, radius: radius) let path = UIBezierPath(arcCenter: center, radius: 0.1, startAngle: 0, endAngle: CGFloat(Double.pi)*2, clockwise: false) anim.toValue = path.cgPath - anim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) + anim.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut) anim.isRemovedOnCompletion = false - anim.fillMode = kCAFillModeForwards + anim.fillMode = CAMediaTimingFillMode.forwards return anim } @@ -160,7 +160,7 @@ class WCLShineAngleLayer: CALayer, CAAnimationDelegate { flash.repeatCount = MAXFLOAT flash.isRemovedOnCompletion = false flash.autoreverses = true - flash.fillMode = kCAFillModeForwards + flash.fillMode = CAMediaTimingFillMode.forwards return flash } From 2f31519fb36c8b6b377f1c0bb95658627e58a775 Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Sun, 26 Jan 2020 17:11:22 +0530 Subject: [PATCH 6/7] Update WCLShineClickLayer.swift --- WCLShineButton/WCLShineClickLayer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WCLShineButton/WCLShineClickLayer.swift b/WCLShineButton/WCLShineClickLayer.swift index 984dbcd..2354fc9 100644 --- a/WCLShineButton/WCLShineClickLayer.swift +++ b/WCLShineButton/WCLShineClickLayer.swift @@ -71,7 +71,7 @@ class WCLShineClickLayer: CALayer { let anim = CAKeyframeAnimation(keyPath: "transform.scale") anim.duration = animDuration anim.values = [0.4, 1, 0.9, 1] - anim.calculationMode = kCAAnimationCubic + anim.calculationMode = CAAnimationCalculationMode.cubic if image.isDefaultAndSelect() { add(anim, forKey: "scale") }else { From 0f72f109f31ed1bd0fc3bf9cac3efe51937254ae Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Sun, 26 Jan 2020 17:11:36 +0530 Subject: [PATCH 7/7] Update WCLShineLayer.swift --- WCLShineButton/WCLShineLayer.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WCLShineButton/WCLShineLayer.swift b/WCLShineButton/WCLShineLayer.swift index 94327ba..1584635 100644 --- a/WCLShineButton/WCLShineLayer.swift +++ b/WCLShineButton/WCLShineLayer.swift @@ -50,9 +50,9 @@ class WCLShineLayer: CALayer, CAAnimationDelegate { let toPath = UIBezierPath(arcCenter: CGPoint.init(x: size.width/2, y: size.height/2), radius: size.width/2 * CGFloat(params.shineDistanceMultiple), startAngle: 0, endAngle: CGFloat(Double.pi) * 2.0, clockwise: false).cgPath anim.delegate = self anim.values = [fromPath, toPath] - anim.timingFunctions = [CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)] + anim.timingFunctions = [CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut)] anim.isRemovedOnCompletion = false - anim.fillMode = kCAFillModeForwards + anim.fillMode = CAMediaTimingFillMode.forwards shapeLayer.add(anim, forKey: "path") if params.enableFlashing { startFlash() @@ -90,7 +90,7 @@ class WCLShineLayer: CALayer, CAAnimationDelegate { }else { displaylink?.frameInterval = 10 } - displaylink?.add(to: .current, forMode: .commonModes) + displaylink?.add(to: .current, forMode: RunLoop.Mode.common) } @objc private func flashAction() {