Skip to content

Commit

Permalink
14.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
relatedcode committed Oct 14, 2023
1 parent 08ef7ed commit 6e83dce
Show file tree
Hide file tree
Showing 30 changed files with 214 additions and 146 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Change Log

## [14.0.0](https://github.com/relatedcode/ProgressHUD/releases/tag/14.0.0)

Released on 2023-10-14.

#### Added

- Introduced the 'SF Symbol Bounce' animation feature, allowing for the display of over 5000 animated SF Symbols to enhance visual engagement.

#### Changed

- Enhanced the existing animations through various code optimizations.

## [13.8.6](https://github.com/relatedcode/ProgressHUD/releases/tag/13.8.6)

Released on 2023-10-13.
Expand Down
2 changes: 1 addition & 1 deletion ProgressHUD.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ProgressHUD'
s.version = '13.8.6'
s.version = '14.0.0'
s.license = 'MIT'

s.summary = 'A lightweight and easy-to-use Progress HUD for iOS.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import UIKit
// MARK: - Activity Indicator
extension ProgressHUD {

func animationActivityIndicator(_ view: UIView, _ color: UIColor) {
func animationActivityIndicator(_ view: UIView) {
let spinner = UIActivityIndicatorView(style: .large)
let scale = view.frame.size.width / spinner.frame.size.width
spinner.transform = CGAffineTransform(scaleX: scale, y: scale)
spinner.frame = view.bounds
spinner.color = color
spinner.color = colorAnimation
spinner.hidesWhenStopped = true
spinner.startAnimating()
view.addSubview(spinner)
Expand Down
26 changes: 13 additions & 13 deletions ProgressHUD/Sources/Animations/ProgressHUD+BallVerticalBounce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import UIKit
// MARK: - Ball Vertical Bounce
extension ProgressHUD {

func animationBallVerticalBounce(_ view: UIView, _ color: UIColor) {
func animationBallVerticalBounce(_ view: UIView) {
let line = CAShapeLayer()
line.strokeColor = color.cgColor
line.strokeColor = colorAnimation.cgColor
line.lineWidth = view.frame.height / 15
line.lineCap = .round
line.fillColor = UIColor.clear.cgColor
Expand All @@ -26,14 +26,14 @@ extension ProgressHUD {
let animationDownCurve = CAKeyframeAnimation(keyPath: "path")
animationDownCurve.timingFunction = CAMediaTimingFunction(name: .easeOut)
animationDownCurve.duration = 2.1 * speed
animationDownCurve.values = [initialCurvePath(in: view).cgPath, downCurvePath(in: view).cgPath]
animationDownCurve.values = [initialCurvePath(view).cgPath, downCurvePath(view).cgPath]
animationDownCurve.autoreverses = true
animationDownCurve.beginTime = 2.9 * speed

let animationTopCurve = CAKeyframeAnimation(keyPath: "path")
animationTopCurve.timingFunction = CAMediaTimingFunction(name: .easeOut)
animationTopCurve.duration = 0.4 * speed
animationTopCurve.values = [initialCurvePath(in: view).cgPath, topCurvePath(in: view).cgPath]
animationTopCurve.values = [initialCurvePath(view).cgPath, topCurvePath(view).cgPath]
animationTopCurve.autoreverses = true
animationTopCurve.beginTime = 7.1 * speed

Expand All @@ -43,12 +43,12 @@ extension ProgressHUD {
animationGroup.repeatCount = .infinity

line.add(animationGroup, forKey: "pathAnimation")
line.path = initialCurvePath(in: view).cgPath
line.path = initialCurvePath(view).cgPath

createBallAnimation(in: view, with: color, speed: speed)
createBallAnimation(view, speed)
}

private func initialCurvePath(in view: UIView) -> UIBezierPath {
private func initialCurvePath(_ view: UIView) -> UIBezierPath {
let width = view.frame.size.width
let height = view.frame.size.height + view.frame.size.height / 3
let path = UIBezierPath()
Expand All @@ -57,7 +57,7 @@ extension ProgressHUD {
return path
}

private func downCurvePath(in view: UIView) -> UIBezierPath {
private func downCurvePath(_ view: UIView) -> UIBezierPath {
let width = view.frame.size.width
let height = view.frame.size.height + view.frame.size.height / 3
let path = UIBezierPath()
Expand All @@ -66,7 +66,7 @@ extension ProgressHUD {
return path
}

private func topCurvePath(in view: UIView) -> UIBezierPath {
private func topCurvePath(_ view: UIView) -> UIBezierPath {
let width = view.frame.size.width
let height = view.frame.size.height + view.frame.size.height / 3
let path = UIBezierPath()
Expand All @@ -75,13 +75,13 @@ extension ProgressHUD {
return path
}

private func createBallAnimation(in view: UIView, with color: UIColor, speed: Double) {
private func createBallAnimation(_ view: UIView, _ speed: Double) {
let width = view.frame.size.width
let height = view.frame.size.height
let size = width / 4
let yPosition = height - height / 3

let circle = drawCircleWith(CGSize(width: size, height: size), color)
let circle = drawCircleWith(CGSize(width: size, height: size))
circle.frame = CGRect(x: width / 2 - size / 2, y: height / 20, width: size, height: size)

let animation = CABasicAnimation(keyPath: "transform.translation.y")
Expand All @@ -96,15 +96,15 @@ extension ProgressHUD {
view.layer.addSublayer(circle)
}

private func drawCircleWith(_ size: CGSize, _ color: UIColor) -> CALayer {
private func drawCircleWith(_ size: CGSize) -> CALayer {
let path = UIBezierPath()
let radius = size.width / 4
let center = CGPoint(x: size.width / 2, y: size.height / 2)
path.addArc(withCenter: center, radius: radius, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true)

let layer = CAShapeLayer()
layer.fillColor = nil
layer.strokeColor = color.cgColor
layer.strokeColor = colorAnimation.cgColor
layer.lineWidth = size.width / 2
layer.backgroundColor = nil
layer.path = path.cgPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Bar Sweep Toggle
extension ProgressHUD {

func animationBarSweepToggle(_ view: UIView, _ color: UIColor) {
func animationBarSweepToggle(_ view: UIView) {
let height = view.frame.size.height
let width = view.frame.size.width

Expand All @@ -29,7 +29,7 @@ extension ProgressHUD {

let layerBar = CAShapeLayer()
layerBar.path = pathBar.cgPath
layerBar.strokeColor = color.cgColor
layerBar.strokeColor = colorAnimation.cgColor
layerBar.lineWidth = heightBar
layerBar.lineCap = .round
view.layer.addSublayer(layerBar)
Expand Down Expand Up @@ -65,11 +65,11 @@ extension ProgressHUD {
layerBar.add(animationPosition, forKey: "position")

let frame = CGRect(x: -border, y: (height - heightBar) / 2 - border, width: width + 2 * border, height: heightBar + 2 * border)

let pathBorder = UIBezierPath(roundedRect: frame, cornerRadius: height)

let layerBorder = CAShapeLayer()
layerBorder.path = pathBorder.cgPath
layerBorder.strokeColor = color.cgColor
layerBorder.strokeColor = colorAnimation.cgColor
layerBorder.fillColor = UIColor.clear.cgColor
layerBorder.lineWidth = border
view.layer.addSublayer(layerBorder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Arc Dot Spin
extension ProgressHUD {

func animationCircleArcDotSpin(_ view: UIView, _ color: UIColor) {
func animationCircleArcDotSpin(_ view: UIView) {
let space = view.frame.width / 8
let x = view.bounds.minX + space / 2
let y = view.bounds.minY + space / 2
Expand All @@ -35,7 +35,7 @@ extension ProgressHUD {
let y = center.y + radius * sin(angle)

let circle = UIView(frame: CGRect(x: x - size / 2, y: y - size / 2, width: size, height: size))
circle.backgroundColor = color
circle.backgroundColor = colorAnimation
circle.layer.cornerRadius = size / 2
containerView.addSubview(circle)

Expand All @@ -47,10 +47,10 @@ extension ProgressHUD {
circle.layer.add(animation, forKey: "circleAnimation")
}

animateArcRotation(containerView, color)
animateArcRotation(containerView)
}

private func animateArcRotation(_ view: UIView, _ color: UIColor) {
private func animateArcRotation(_ view: UIView) {
let width = view.frame.size.width
let height = view.frame.size.height
let center = CGPoint(x: width / 2, y: height / 2)
Expand Down Expand Up @@ -80,7 +80,7 @@ extension ProgressHUD {
layer.frame = CGRect(x: 0, y: 0, width: width, height: height)
layer.path = path.cgPath
layer.fillColor = nil
layer.strokeColor = color.cgColor
layer.strokeColor = colorAnimation.cgColor
layer.lineWidth = view.frame.width / 6
layer.lineCap = .round

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Bar Spin Fade
extension ProgressHUD {

func animationCircleBarSpinFade(_ view: UIView, _ color: UIColor) {
func animationCircleBarSpinFade(_ view: UIView) {
let width = view.frame.size.width
let height = view.frame.size.height

Expand Down Expand Up @@ -43,15 +43,19 @@ extension ProgressHUD {
let angle = .pi / 4 * CGFloat(i)

let line = CAShapeLayer()
line.frame = CGRect(x: (containerSize - lineWidth) / 2, y: (containerSize - lineHeight) / 2, width: lineWidth, height: lineHeight)
let lineX = (containerSize - lineWidth) / 2
let lineY = (containerSize - lineHeight) / 2
line.frame = CGRect(x: lineX, y: lineY, width: lineWidth, height: lineHeight)
line.path = path.cgPath
line.backgroundColor = nil
line.fillColor = color.cgColor
line.fillColor = colorAnimation.cgColor

let container = CALayer()
container.frame = CGRect(x: radius * (cos(angle) + 1), y: radius * (sin(angle) + 1), width: containerSize, height: containerSize)
container.addSublayer(line)
let containerX = radius * (cos(angle) + 1)
let containerY = radius * (sin(angle) + 1)
container.frame = CGRect(x: containerX, y: containerY, width: containerSize, height: containerSize)
container.sublayerTransform = CATransform3DMakeRotation(.pi / 2 + angle, 0, 0, 1)
container.addSublayer(line)

animation.beginTime = beginTime - beginTimes[i]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Dot Spin Fade
extension ProgressHUD {

func animationCircleDotSpinFade(_ view: UIView, _ color: UIColor) {
func animationCircleDotSpinFade(_ view: UIView) {
let width = view.frame.size.width

let spacing = 3.0
Expand Down Expand Up @@ -50,7 +50,7 @@ extension ProgressHUD {

let layer = CAShapeLayer()
layer.path = path.cgPath
layer.fillColor = color.cgColor
layer.fillColor = colorAnimation.cgColor
layer.backgroundColor = nil
layer.frame = CGRect(x: radiusX * (cos(angle) + 1), y: radiusX * (sin(angle) + 1), width: radius, height: radius)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Pulse Multiple
extension ProgressHUD {

func animationCirclePulseMultiple(_ view: UIView, _ color: UIColor) {
func animationCirclePulseMultiple(_ view: UIView) {
let width = view.frame.size.width
let height = view.frame.size.height
let center = CGPoint(x: width / 2, y: height / 2)
Expand Down Expand Up @@ -47,7 +47,7 @@ extension ProgressHUD {
let layer = CAShapeLayer()
layer.frame = CGRect(x: 0, y: 0, width: width, height: height)
layer.path = path.cgPath
layer.fillColor = color.cgColor
layer.fillColor = colorAnimation.cgColor
layer.opacity = 0

animation.beginTime = beginTime + beginTimes[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Pulse Single
extension ProgressHUD {

func animationCirclePulseSingle(_ view: UIView, _ color: UIColor) {
func animationCirclePulseSingle(_ view: UIView) {
let width = view.frame.size.width
let height = view.frame.size.height
let center = CGPoint(x: width / 2, y: height / 2)
Expand Down Expand Up @@ -44,7 +44,7 @@ extension ProgressHUD {
let layer = CAShapeLayer()
layer.frame = CGRect(x: 0, y: 0, width: width, height: height)
layer.path = path.cgPath
layer.fillColor = color.cgColor
layer.fillColor = colorAnimation.cgColor

layer.add(animation, forKey: "animation")
view.layer.addSublayer(layer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Ripple Multiple
extension ProgressHUD {

func animationCircleRippleMultiple(_ view: UIView, _ color: UIColor) {
func animationCircleRippleMultiple(_ view: UIView) {
let width = view.frame.size.width
let height = view.frame.size.height
let center = CGPoint(x: width / 2, y: height / 2)
Expand Down Expand Up @@ -50,7 +50,7 @@ extension ProgressHUD {
layer.frame = CGRect(x: 0, y: 0, width: width, height: height)
layer.path = path.cgPath
layer.backgroundColor = nil
layer.strokeColor = color.cgColor
layer.strokeColor = colorAnimation.cgColor
layer.lineWidth = 3
layer.fillColor = nil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Ripple Single
extension ProgressHUD {

func animationCircleRippleSingle(_ view: UIView, _ color: UIColor) {
func animationCircleRippleSingle(_ view: UIView) {
let width = view.frame.size.width
let height = view.frame.size.height
let center = CGPoint(x: width / 2, y: height / 2)
Expand Down Expand Up @@ -48,7 +48,7 @@ extension ProgressHUD {
layer.path = path.cgPath
layer.backgroundColor = nil
layer.fillColor = nil
layer.strokeColor = color.cgColor
layer.strokeColor = colorAnimation.cgColor
layer.lineWidth = 3

layer.add(animation, forKey: "animation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Rotate Chase
extension ProgressHUD {

func animationCircleRotateChase(_ view: UIView, _ color: UIColor) {
func animationCircleRotateChase(_ view: UIView) {
let width = view.frame.size.width
let height = view.frame.size.height
let center1 = CGPoint(x: width / 2, y: height / 2)
Expand Down Expand Up @@ -55,7 +55,7 @@ extension ProgressHUD {
let layer = CAShapeLayer()
layer.frame = CGRect(x: 0, y: 0, width: radius, height: radius)
layer.path = path2.cgPath
layer.fillColor = color.cgColor
layer.fillColor = colorAnimation.cgColor

layer.add(animation, forKey: "animation")
view.layer.addSublayer(layer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
// MARK: - Circle Stroke Spin
extension ProgressHUD {

func animationCircleStrokeSpin(_ view: UIView, _ color: UIColor) {
func animationCircleStrokeSpin(_ view: UIView) {
let width = view.frame.size.width
let height = view.frame.size.height
let center = CGPoint(x: width / 2, y: height / 2)
Expand Down Expand Up @@ -53,7 +53,7 @@ extension ProgressHUD {
layer.frame = CGRect(x: 0, y: 0, width: width, height: height)
layer.path = path.cgPath
layer.fillColor = nil
layer.strokeColor = color.cgColor
layer.strokeColor = colorAnimation.cgColor
layer.lineWidth = 3

layer.add(animation, forKey: "animation")
Expand Down
Loading

0 comments on commit 6e83dce

Please sign in to comment.