diff --git a/EZProgressHUD.podspec b/EZProgressHUD.podspec index ca6f3d6..2d44fe4 100644 --- a/EZProgressHUD.podspec +++ b/EZProgressHUD.podspec @@ -1,24 +1,22 @@ Pod::Spec.new do |spec| - spec.name = "EZProgressHUD" - spec.version = "1.5.3" - spec.summary = "A very cool and easy to use activity indicator for iOS Application ;) Hope you fellas enjoy it 😊😊" - + spec.name = "EZProgressHUD" + spec.version = "1.5.4" + spec.summary = "A very cool and easy to use activity indicator for iOS Application ;) Hope you fellas enjoy it 😊😊" spec.description = <<-DESC -As we said, this is a very cool and easy to use activity indicator for iOS and guess what!!?? Android Application(coming soon...) -hope you guys enjoy it. -shndrs -hnk + As we said, this is a very cool and easy to use activity indicator for iOS + hope you guys enjoy it. -shndrs DESC - spec.homepage = "https://github.com/shndrs/EZProgressHUD" - spec.license = { :type => "MIT", :file => "LICENSE" } - spec.author = { "shndrs" => "sahandraeisi1994@gmail.com" } + spec.homepage = "https://github.com/shndrs/EZProgressHUD" + spec.license = { :type => "MIT", :file => "LICENSE" } + spec.author = { "shndrs" => "sahandraeisi1994@gmail.com" } spec.ios.deployment_target = "9.3" spec.swift_version = "5" - - spec.source = { :git => "https://github.com/shndrs/EZProgressHUD.git", :tag => "#{spec.version}" } + spec.source = { :git => "https://github.com/shndrs/EZProgressHUD.git", :tag => "#{spec.version}" } spec.source_files = "EZProgressHUD/**/*.{h,m,swift}" spec.exclude_files = "Classes/Exclude" diff --git a/EZProgressHUD.xcodeproj/project.pbxproj b/EZProgressHUD.xcodeproj/project.pbxproj index 38d864c..c315a52 100644 --- a/EZProgressHUD.xcodeproj/project.pbxproj +++ b/EZProgressHUD.xcodeproj/project.pbxproj @@ -649,6 +649,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MARKETING_VERSION = 1.5.4; PRODUCT_BUNDLE_IDENTIFIER = shndrs.EZProgressHUD; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -677,6 +678,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MARKETING_VERSION = 1.5.4; PRODUCT_BUNDLE_IDENTIFIER = shndrs.EZProgressHUD; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; diff --git a/EZProgressHUD.xcodeproj/project.xcworkspace/xcuserdata/home.xcuserdatad/UserInterfaceState.xcuserstate b/EZProgressHUD.xcodeproj/project.xcworkspace/xcuserdata/home.xcuserdatad/UserInterfaceState.xcuserstate index 09f0c88..2ebe2f9 100644 Binary files a/EZProgressHUD.xcodeproj/project.xcworkspace/xcuserdata/home.xcuserdatad/UserInterfaceState.xcuserstate and b/EZProgressHUD.xcodeproj/project.xcworkspace/xcuserdata/home.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/EZProgressHUD/EZAnimations/EZAnimationArgument.swift b/EZProgressHUD/EZAnimations/EZAnimationArgument.swift index 58bb490..8c9bf6e 100644 --- a/EZProgressHUD/EZAnimations/EZAnimationArgument.swift +++ b/EZProgressHUD/EZAnimations/EZAnimationArgument.swift @@ -17,6 +17,7 @@ public class BaseAnimationArgument { self.duration = duration self.option = option } + } public final class TransformArguments: BaseAnimationArgument { @@ -32,6 +33,7 @@ public final class TransformArguments: BaseAnimationArgument { self.toValue = toValue super.init(duration: base.duration, option: base.option) } + } public final class LineDashPhaseArguments: BaseAnimationArgument { @@ -46,4 +48,5 @@ public final class LineDashPhaseArguments: BaseAnimationArgument { self.autoreverse = autoreverse super.init(duration: base.duration, option: base.option) } + } diff --git a/EZProgressHUD/EZAnimations/EZAnimations.swift b/EZProgressHUD/EZAnimations/EZAnimations.swift index 7571b14..2562444 100644 --- a/EZProgressHUD/EZAnimations/EZAnimations.swift +++ b/EZProgressHUD/EZAnimations/EZAnimations.swift @@ -29,7 +29,6 @@ public class EZAnimations { @discardableResult public static func transformX() -> CABasicAnimation { - let transformXScaleAnimation = CABasicAnimation(keyPath: EZStrings.transformScaleX.rawValue) transformXScaleAnimation.fromValue = 1 transformXScaleAnimation.toValue = 1.02 @@ -43,9 +42,7 @@ public class EZAnimations { public static func rotation(duration: CFTimeInterval, rotationMode:RotationMode) -> CABasicAnimation { var rotationAnimation = CABasicAnimation() - switch rotationMode { - case .xRotation: rotationAnimation = CABasicAnimation(keyPath: EZStrings.transformRotationX.rawValue) case .yRotation: @@ -57,7 +54,6 @@ public class EZAnimations { @discardableResult public static func opacity() -> CABasicAnimation { - let opacityAnimation = CABasicAnimation(keyPath: EZStrings.opacity.rawValue) opacityAnimation.fromValue = 1 opacityAnimation.toValue = 0.5 @@ -69,7 +65,6 @@ public class EZAnimations { @discardableResult public static func lineWidth(toValue: Any, duration: CFTimeInterval) -> CABasicAnimation { - let lineWidthAnimation = CABasicAnimation(keyPath: EZStrings.lineWidth.rawValue) lineWidthAnimation.toValue = toValue lineWidthAnimation.duration = duration @@ -80,7 +75,6 @@ public class EZAnimations { @discardableResult public static func lineDashPhase(with object: LineDashPhaseArguments) -> CABasicAnimation { - let lineDashPhaseAnimation = CABasicAnimation(keyPath: EZStrings.lineDashPhase.rawValue) lineDashPhaseAnimation.byValue = object.byValue lineDashPhaseAnimation.duration = object.duration @@ -94,7 +88,6 @@ public class EZAnimations { public static func strokeEndAnimation(toValue:Any = 1.0, duration:CFTimeInterval = 0.75, option:CAMediaTimingFunctionName = .easeInEaseOut) -> CABasicAnimation { - let strokeEndAnimation = CABasicAnimation(keyPath: EZStrings.strokeEnd.rawValue) strokeEndAnimation.toValue = 1.0 strokeEndAnimation.duration = 0.75 @@ -102,15 +95,18 @@ public class EZAnimations { setCommonAnimationProperties(animation: strokeEndAnimation) return strokeEndAnimation } + } // MARK: - Set common animation properties extension EZAnimations { + fileprivate class func setCommonAnimationProperties(animation: CABasicAnimation) { animation.autoreverses = true animation.repeatCount = .infinity } + fileprivate class func rotationsCommons(animation: CABasicAnimation, duration: CFTimeInterval) { animation.fromValue = 0 animation.toValue = CGFloat.pi * 2 @@ -118,4 +114,5 @@ extension EZAnimations { animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) setCommonAnimationProperties(animation: animation) } + } diff --git a/EZProgressHUD/EZBaseView/EZBaseView.swift b/EZProgressHUD/EZBaseView/EZBaseView.swift index 413238a..c55e14e 100644 --- a/EZProgressHUD/EZBaseView/EZBaseView.swift +++ b/EZProgressHUD/EZBaseView/EZBaseView.swift @@ -64,9 +64,7 @@ open class EZBaseView: UIView { /// this method set the circles position, path, fillColor and......... public func layerGenerator(shapeLayer: CAShapeLayer, type: ShapeLayerType) { - switch type { - case .firstShapeLayer: shapeLayer.strokeColor = options.firstLayerStrokeColor.cgColor case .secondShapeLayer: @@ -74,12 +72,10 @@ open class EZBaseView: UIView { case .thirdShapeLayer: shapeLayer.strokeColor = options.thirdLayerStrokeColor.cgColor } - let circularTrackPath = UIBezierPath(arcCenter: .zero, radius: options.radius, startAngle: -(.pi) , endAngle:2 * .pi, clockwise: true) - shapeLayer.position = transView.center shapeLayer.path = circularTrackPath.cgPath shapeLayer.lineWidth = options.strokeWidth @@ -88,14 +84,12 @@ open class EZBaseView: UIView { } public func showBlock() { - UIApplication.shared.keyWindow?.isUserInteractionEnabled = false UIApplication.shared.keyWindow?.addSubview(transView) transViewAnimation(completion: nil) } public func dismissBlock(completion: (() -> Void)?) { - let completionHandler = { (success:Bool) in self.transView.removeFromSuperview() UIApplication.shared.keyWindow?.isUserInteractionEnabled = true @@ -109,10 +103,9 @@ open class EZBaseView: UIView { UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseInOut, animations: { [weak self] in - guard let self = self else { return } - (self.transView.alpha != 0) ? (self.transView.alpha = 0) : (self.transView.alpha = 1) }, completion: completion) } + } diff --git a/EZProgressHUD/EZFactory/EZFactory.swift b/EZProgressHUD/EZFactory/EZFactory.swift index db15edd..c02a28d 100644 --- a/EZProgressHUD/EZFactory/EZFactory.swift +++ b/EZProgressHUD/EZFactory/EZFactory.swift @@ -16,25 +16,15 @@ public struct EZProgressHUD { @discardableResult public static func setProgress(with options:EZProgressOptions) -> EZProgress { - switch options.animationOption { - case .heartBeat: - return HeartBeat(options: options) - case .lineLayer: - return LineLayer(options: options) - case .lordOfTheRings: - return LordOfTheRings(options: options) - case .antColony: - return AntColony(options: options) - default: return rotationBasedProgress(with: options) } @@ -43,27 +33,19 @@ public struct EZProgressHUD { @discardableResult private static func rotationBasedProgress(with options:EZProgressOptions) -> EZProgress { - switch options.animationOption { case .xRotation: - return XRotation(options: options) - case .xyRotation: - return XYRotation(options: options) - case .yRotation: - return YRotation(options: options) - case .hnk: - return HNK(options: options) - default: return HeartBeat(options: options) } } + } diff --git a/EZProgressHUD/EZOthers/EZStrings.swift b/EZProgressHUD/EZOthers/EZStrings.swift index d1d8337..1d04afc 100644 --- a/EZProgressHUD/EZOthers/EZStrings.swift +++ b/EZProgressHUD/EZOthers/EZStrings.swift @@ -30,5 +30,5 @@ public enum EZStrings:String { case hsKey7 case hsKey8 case hsKey9 + } - diff --git a/EZProgressHUD/EZProgressOptions/EZProgressOptions.swift b/EZProgressHUD/EZProgressOptions/EZProgressOptions.swift index d7a2738..9a33f54 100644 --- a/EZProgressHUD/EZProgressOptions/EZProgressOptions.swift +++ b/EZProgressHUD/EZProgressOptions/EZProgressOptions.swift @@ -33,6 +33,7 @@ public class EZTitleOptions { /// color of title text (by default is white) public var titleTextColor: UIColor = .white + } @requires_stored_property_inits @@ -51,6 +52,7 @@ public class EZProgressColorOptions: EZTitleOptions { /// the background transparent view color (by default is black) public var transViewBackgroundColor: UIColor = UIColor.black + } @requires_stored_property_inits @@ -73,5 +75,5 @@ public class EZProgressOptions: EZProgressColorOptions { super.init() options(self) } + } - diff --git a/EZProgressHUD/EZProgresses/AntColony.swift b/EZProgressHUD/EZProgresses/AntColony.swift index 13fe7e9..b8ef63d 100644 --- a/EZProgressHUD/EZProgresses/AntColony.swift +++ b/EZProgressHUD/EZProgresses/AntColony.swift @@ -17,6 +17,7 @@ final public class AntColony: EZBaseProgresses { titleAnimations() lineDashAnimation() } + } // MARK: - Methods diff --git a/EZProgressHUD/EZProgresses/EZBaseProgresses.swift b/EZProgressHUD/EZProgresses/EZBaseProgresses.swift index 1d1c981..f047cfc 100644 --- a/EZProgressHUD/EZProgresses/EZBaseProgresses.swift +++ b/EZProgressHUD/EZProgresses/EZBaseProgresses.swift @@ -13,6 +13,7 @@ public class EZBaseProgresses: EZBaseView {} // MARK: EZProgressProtocol Impelementation extension EZBaseProgresses: EZProgress { + public func show() { setLayers() showBlock() @@ -21,6 +22,7 @@ extension EZBaseProgresses: EZProgress { public func dismiss(completion: (() -> Void)?) { dismissBlock(completion: completion) } + } // MARK: Set Animation And Layers diff --git a/EZProgressHUD/EZProgresses/HNK.swift b/EZProgressHUD/EZProgresses/HNK.swift index a54cf91..b5a11c7 100644 --- a/EZProgressHUD/EZProgresses/HNK.swift +++ b/EZProgressHUD/EZProgresses/HNK.swift @@ -17,6 +17,7 @@ final public class HNK: EZBaseProgresses { dashAnimations() strokeEndAndTitleAnimations() } + } // MARK: - Methods @@ -70,4 +71,5 @@ extension HNK { titleLabel.layer.add(opacityAnimation, forKey: EZStrings.hsKey3.rawValue) firstShapeLayer.add(strokeEndAnimation, forKey: EZStrings.hsKey7.rawValue) } + } diff --git a/EZProgressHUD/EZProgresses/HeartBeat.swift b/EZProgressHUD/EZProgresses/HeartBeat.swift index 93f12bd..a499f2f 100644 --- a/EZProgressHUD/EZProgresses/HeartBeat.swift +++ b/EZProgressHUD/EZProgresses/HeartBeat.swift @@ -9,10 +9,12 @@ import UIKit final public class HeartBeat: EZBaseProgresses { + public override func setAnimation() { transformAnimations() titleAnimations() } + } // MARK: - Methods @@ -35,10 +37,10 @@ extension HeartBeat { private func titleAnimations() { let opacityAnimation = EZAnimations.opacity() let transformXScaleAnimation = EZAnimations.transformX() - titleLabel.layer.add(opacityAnimation, forKey: EZStrings.hsKey2.rawValue) titleLabel.layer.add(transformXScaleAnimation, forKey: EZStrings.hsKey3.rawValue) } + } diff --git a/EZProgressHUD/EZProgresses/LineLayer.swift b/EZProgressHUD/EZProgresses/LineLayer.swift index a67e088..5e71997 100644 --- a/EZProgressHUD/EZProgresses/LineLayer.swift +++ b/EZProgressHUD/EZProgresses/LineLayer.swift @@ -9,6 +9,7 @@ import UIKit final public class LineLayer: EZBaseProgresses { + fileprivate func setProperties() { firstShapeLayer.lineWidth = (options.strokeWidth / 4) + 1 firstShapeLayer.lineDashPattern = [5] @@ -23,6 +24,7 @@ final public class LineLayer: EZBaseProgresses { lineDashAnimations() opacityAndStrokeAnimations() } + } // MARK: - Methods diff --git a/EZProgressHUD/EZProgresses/LordOfTheRings.swift b/EZProgressHUD/EZProgresses/LordOfTheRings.swift index 84b2b6d..17c2771 100644 --- a/EZProgressHUD/EZProgresses/LordOfTheRings.swift +++ b/EZProgressHUD/EZProgresses/LordOfTheRings.swift @@ -9,12 +9,14 @@ import UIKit final public class LordOfTheRings: EZBaseProgresses { + public override func setAnimation() { firstLayerNTitleAnimations() secondLayerAnimations() thirdLayerAnimation() titleOpacityAnimation() } + } // MARK: - Methods diff --git a/EZProgressHUD/EZProgresses/XRotation.swift b/EZProgressHUD/EZProgresses/XRotation.swift index 7c275bf..e78cd79 100644 --- a/EZProgressHUD/EZProgresses/XRotation.swift +++ b/EZProgressHUD/EZProgresses/XRotation.swift @@ -9,11 +9,13 @@ import UIKit final public class XRotation: EZBaseProgresses { + public override func setAnimation() { transformScale() xRotation() opacity() } + } // MARK: - Methods diff --git a/EZProgressHUD/EZProgresses/XYRotation.swift b/EZProgressHUD/EZProgresses/XYRotation.swift index d202383..f7a8d6e 100644 --- a/EZProgressHUD/EZProgresses/XYRotation.swift +++ b/EZProgressHUD/EZProgresses/XYRotation.swift @@ -9,11 +9,13 @@ import UIKit final public class XYRotation: EZBaseProgresses { + public override func setAnimation() { rotationAnimations() transformScaleAnimation() opacityAnimation() } + } // MARK: - Methods diff --git a/EZProgressHUD/EZProgresses/YRotation.swift b/EZProgressHUD/EZProgresses/YRotation.swift index f54d107..bcc5649 100644 --- a/EZProgressHUD/EZProgresses/YRotation.swift +++ b/EZProgressHUD/EZProgresses/YRotation.swift @@ -9,11 +9,13 @@ import UIKit final public class YRotation: EZBaseProgresses { + public override func setAnimation() { transformScaleAnimations() rotationYAnimation() opacityAnimation() } + } // MARK: - Methods diff --git a/EZProgressHUD/Info.plist b/EZProgressHUD/Info.plist index 683c5ec..82790df 100644 --- a/EZProgressHUD/Info.plist +++ b/EZProgressHUD/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.5.0 + $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) diff --git a/EZProgressHUDExamples/Resources/AppDelegate.swift b/EZProgressHUDExamples/Resources/AppDelegate.swift index 1ef073c..fb98665 100644 --- a/EZProgressHUDExamples/Resources/AppDelegate.swift +++ b/EZProgressHUDExamples/Resources/AppDelegate.swift @@ -18,4 +18,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate { [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } + } diff --git a/EZProgressHUDExamples/ViewController/ViewController.swift b/EZProgressHUDExamples/ViewController/ViewController.swift index 1b38f83..2c27d10 100644 --- a/EZProgressHUDExamples/ViewController/ViewController.swift +++ b/EZProgressHUDExamples/ViewController/ViewController.swift @@ -34,7 +34,6 @@ final class ViewController: UIViewController { // MARK: - LineLayer HUD @IBAction private func lineLayerButtonPressed(_ sender: UIButton) { - let color = UIColor(red: 255/255, green: 190/255, blue: 0/255, alpha: 1) let options = EZProgressOptions { (option) in option.radius = 120 @@ -45,10 +44,8 @@ final class ViewController: UIViewController { option.title = "shndrs presents" option.animationOption = EZAnimationOptions.lineLayer } - let hud = EZProgressHUD.setProgress(with: options) hud.show() - DispatchQueue.main.asyncAfter(deadline: .now() + 4) { hud.dismiss(completion: nil) } @@ -57,7 +54,6 @@ final class ViewController: UIViewController { // MARK: - LordOfTheRings HUD @IBAction private func lordOfTheRingsButtonPressed(_ sender: UIButton) { - let options = EZProgressOptions { (option) in option.radius = 120 option.secondLayerStrokeColor = .white @@ -67,10 +63,8 @@ final class ViewController: UIViewController { option.title = "shndrs presents" option.animationOption = EZAnimationOptions.lordOfTheRings } - let hud = EZProgressHUD.setProgress(with: options) hud.show() - DispatchQueue.main.asyncAfter(deadline: .now() + 4) { hud.dismiss(completion: nil) } @@ -79,7 +73,6 @@ final class ViewController: UIViewController { // MARK: - XRotation HUD @IBAction private func xRotationButtonPressed(_ sender: UIButton) { - let options = EZProgressOptions { (option) in option.radius = 115 option.secondLayerStrokeColor = .brown @@ -89,10 +82,8 @@ final class ViewController: UIViewController { option.title = "shndrs presents" option.animationOption = EZAnimationOptions.xRotation } - let hud = EZProgressHUD.setProgress(with: options) hud.show() - DispatchQueue.main.asyncAfter(deadline: .now() + 4) { hud.dismiss(completion: nil) } @@ -101,7 +92,6 @@ final class ViewController: UIViewController { // MARK: - YRotation HUD @IBAction private func yRotationButtonPressed(_ sender: UIButton) { - let options = EZProgressOptions { (option) in option.radius = 117 option.secondLayerStrokeColor = green @@ -111,10 +101,8 @@ final class ViewController: UIViewController { option.title = "shndrs presents" option.animationOption = EZAnimationOptions.yRotation } - let hud = EZProgressHUD.setProgress(with: options) hud.show() - DispatchQueue.main.asyncAfter(deadline: .now() + 4) { hud.dismiss(completion: nil) } @@ -132,10 +120,8 @@ final class ViewController: UIViewController { option.title = "shndrs presents" option.animationOption = EZAnimationOptions.xyRotation } - let hud = EZProgressHUD.setProgress(with: options) hud.show() - DispatchQueue.main.asyncAfter(deadline: .now() + 4) { hud.dismiss(completion: nil) } @@ -144,7 +130,6 @@ final class ViewController: UIViewController { // MARK: - AntColony HUD @IBAction private func antColonyButtonPressed(_ sender: UIButton) { - let options = EZProgressOptions { (option) in option.radius = 120 option.secondLayerStrokeColor = darkGray @@ -154,10 +139,8 @@ final class ViewController: UIViewController { option.title = "shndrs presents" option.animationOption = EZAnimationOptions.antColony } - let hud = EZProgressHUD.setProgress(with: options) hud.show() - DispatchQueue.main.asyncAfter(deadline: .now() + 4) { hud.dismiss(completion: nil) } @@ -166,7 +149,6 @@ final class ViewController: UIViewController { //MARK: - HNK HUD @IBAction private func hnkButtonPressed(_ sender: UIButton) { - let options = EZProgressOptions { (option) in option.radius = 115 option.secondLayerStrokeColor = niceBlue @@ -176,12 +158,11 @@ final class ViewController: UIViewController { option.title = "shndrs presents" option.animationOption = EZAnimationOptions.hnk } - let hud = EZProgressHUD.setProgress(with: options) hud.show() - DispatchQueue.main.asyncAfter(deadline: .now() + 4) { hud.dismiss(completion: nil) } } + } diff --git a/EZProgressHUDTests/EZProgressHUDTests.swift b/EZProgressHUDTests/EZProgressHUDTests.swift index 10f9948..a7b0b70 100644 --- a/EZProgressHUDTests/EZProgressHUDTests.swift +++ b/EZProgressHUDTests/EZProgressHUDTests.swift @@ -25,11 +25,8 @@ class EZProgressHUDTests: XCTestCase { options.title = "shndrs presents" options.animationOption = EZAnimationOptions.hnk } - XCTAssertNotNil(options) - let hud = EZProgressHUD.setProgress(with: options) - XCTAssertNotNil(hud) } @@ -45,34 +42,23 @@ class EZProgressHUDTests: XCTestCase { options.titleTextColor = .white options.transViewBackgroundColor = .black options.animationOption = EZAnimationOptions.lordOfTheRings - XCTAssertNotNil(options) - let hud = EZProgressHUD.setProgress(with: options) - XCTAssertNotNil(hud) } func defaultHudTest() { - let options = EZProgressOptions() - XCTAssertNotNil(options, "Not Nil") - let hud = EZProgressHUD.setProgress(with: options) - XCTAssertNotNil(hud) - let opts = EZProgressOptions { (_) in } XCTAssertNotNil(opts) - let hd = EZProgressHUD.setProgress(with: opts) - XCTAssertNotNil(hd) } func testPerformanceExample() { - self.measure { hnkTest() defaultHudTest()