Skip to content

Commit

Permalink
Migrating to Swift 3 and fix all build errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeLin committed Sep 2, 2016
1 parent 6a8ba7a commit 337a289
Show file tree
Hide file tree
Showing 81 changed files with 566 additions and 589 deletions.
8 changes: 4 additions & 4 deletions IBAnimatable/ActivityIndicatorAnimatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public protocol ActivityIndicatorAnimatable: class {
public extension ActivityIndicatorAnimatable where Self: UIView {

public func startAnimating() {
hidden = false
isHidden = false
configLayer()
isAnimating = true
}
Expand All @@ -23,7 +23,7 @@ public extension ActivityIndicatorAnimatable where Self: UIView {
layer.sublayers = nil
isAnimating = false
if hidesWhenStopped {
hidden = true
isHidden = true
}
}

Expand All @@ -36,12 +36,12 @@ private extension ActivityIndicatorAnimatable where Self: UIView {
return
}

let type = ActivityIndicatorType.fromString(animationType)
let type = ActivityIndicatorType.fromString(string: animationType)
guard type != .None else {
return
}

let activityIndicator = ActivityIndicatorFactory.generateActivityIndicator(type)
let activityIndicator = ActivityIndicatorFactory.generateActivityIndicator(activityIndicatorType: type)
activityIndicator.configAnimation(in: layer, size: bounds.size, color: color)
layer.speed = 1
}
Expand Down
16 changes: 8 additions & 8 deletions IBAnimatable/ActivityIndicatorAnimationAudioEqualizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class ActivityIndicatorAnimationAudioEqualizer: ActivityIndicatorAnimatin

// MARK: Properties

private var size: CGSize = .zero
private var lineSize: CGFloat = 0
fileprivate var size: CGSize = .zero
fileprivate var lineSize: CGFloat = 0

// MARK: ActivityIndicatorAnimating

Expand All @@ -24,14 +24,14 @@ public class ActivityIndicatorAnimationAudioEqualizer: ActivityIndicatorAnimatin

// Draw lines
for i in 0 ..< 4 {
let animation = createAnimation(duration[i], values: values)
let animation = createAnimation(duration: duration[i], values: values)
let line = ActivityIndicatorShape.Line.createLayerWith(size: CGSize(width: lineSize, height: size.height), color: color)
let frame = CGRect(x: x + lineSize * 2 * CGFloat(i),
y: y,
width: lineSize,
height: size.height)
line.frame = frame
line.addAnimation(animation, forKey: "animation")
line.add(animation, forKey: "animation")
layer.addSublayer(line)
}
}
Expand All @@ -40,25 +40,25 @@ public class ActivityIndicatorAnimationAudioEqualizer: ActivityIndicatorAnimatin

// MARK: - Setup

private extension ActivityIndicatorAnimationAudioEqualizer {
fileprivate extension ActivityIndicatorAnimationAudioEqualizer {

func createAnimation(duration: CFTimeInterval, values: [Double]) -> CAKeyframeAnimation {
let animation = CAKeyframeAnimation()
animation.keyPath = "path"
animation.additive = true
animation.isAdditive = true
animation.values = []

for j in 0..<values.count {
let heightFactor = values[j]
let height = size.height * CGFloat(heightFactor)
let point = CGPoint(x: 0, y: size.height - height)
let path = UIBezierPath(rect: CGRect(origin: point, size: CGSize(width: lineSize, height: height)))
animation.values?.append(path.CGPath)
animation.values?.append(path.cgPath)
}

animation.duration = duration
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
return animation
}

Expand Down
8 changes: 4 additions & 4 deletions IBAnimatable/ActivityIndicatorAnimationBallBeat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ActivityIndicatorAnimationBallBeat: ActivityIndicatorAnimating {

// MARK: Properties

private let duration: CFTimeInterval = 0.7
fileprivate let duration: CFTimeInterval = 0.7

// MARK: ActivityIndicatorAnimating

Expand All @@ -30,7 +30,7 @@ public class ActivityIndicatorAnimationBallBeat: ActivityIndicatorAnimating {
height: circleSize)
animation.beginTime = beginTime + beginTimes[i]
circle.frame = frame
circle.addAnimation(animation, forKey: "animation")
circle.add(animation, forKey: "animation")
layer.addSublayer(circle)
}
}
Expand All @@ -39,7 +39,7 @@ public class ActivityIndicatorAnimationBallBeat: ActivityIndicatorAnimating {

// MARK: - Setup

private extension ActivityIndicatorAnimationBallBeat {
fileprivate extension ActivityIndicatorAnimationBallBeat {

var scaleAnimation: CAKeyframeAnimation {
let scaleAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
Expand All @@ -63,7 +63,7 @@ private extension ActivityIndicatorAnimationBallBeat {
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
animation.duration = duration
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
return animation
}

Expand Down
8 changes: 4 additions & 4 deletions IBAnimatable/ActivityIndicatorAnimationBallClipRotate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ActivityIndicatorAnimationBallClipRotate: ActivityIndicatorAnimatin

// MARK: Properties

private let duration: CFTimeInterval = 0.75
fileprivate let duration: CFTimeInterval = 0.75

// MARK: ActivityIndicatorAnimating

Expand All @@ -24,15 +24,15 @@ public class ActivityIndicatorAnimationBallClipRotate: ActivityIndicatorAnimatin
height: size.height)

circle.frame = frame
circle.addAnimation(animation, forKey: "animation")
circle.add(animation, forKey: "animation")
layer.addSublayer(circle)
}

}

// MARK: - Setup

private extension ActivityIndicatorAnimationBallClipRotate {
fileprivate extension ActivityIndicatorAnimationBallClipRotate {

var scaleAnimation: CAKeyframeAnimation {
let scaleAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
Expand All @@ -54,7 +54,7 @@ private extension ActivityIndicatorAnimationBallClipRotate {
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
animation.duration = duration
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
return animation
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ActivityIndicatorAnimationBallClipRotateMultiple: ActivityIndicator

// MARK: Properties

private let duration: CFTimeInterval = 0.7
fileprivate let duration: CFTimeInterval = 0.7

// MARK: ActivityIndicatorAnimating

Expand All @@ -36,9 +36,9 @@ public class ActivityIndicatorAnimationBallClipRotateMultiple: ActivityIndicator

// MARK: - Setup

private extension ActivityIndicatorAnimationBallClipRotateMultiple {
fileprivate extension ActivityIndicatorAnimationBallClipRotateMultiple {

func createAnimationIn(duration duration: CFTimeInterval, timingFunction: CAMediaTimingFunction, reverse: Bool) -> CAAnimation {
func createAnimationIn(duration: CFTimeInterval, timingFunction: CAMediaTimingFunction, reverse: Bool) -> CAAnimation {
// Scale animation
let scaleAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
scaleAnimation.keyTimes = [0, 0.5, 1]
Expand All @@ -62,13 +62,13 @@ private extension ActivityIndicatorAnimationBallClipRotateMultiple {
animation.animations = [scaleAnimation, rotateAnimation]
animation.duration = duration
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false

return animation
}

// swiftlint:disable:next function_parameter_count
func circleOf(shape shape: ActivityIndicatorShape, duration: CFTimeInterval, timingFunction: CAMediaTimingFunction, layer: CALayer, size: CGFloat, color: UIColor, reverse: Bool) {
func circleOf(shape: ActivityIndicatorShape, duration: CFTimeInterval, timingFunction: CAMediaTimingFunction, layer: CALayer, size: CGFloat, color: UIColor, reverse: Bool) {
let circle = shape.createLayerWith(size: CGSize(width: size, height: size), color: color)
let frame = CGRect(x: (layer.bounds.size.width - size) / 2,
y: (layer.bounds.size.height - size) / 2,
Expand All @@ -77,7 +77,7 @@ private extension ActivityIndicatorAnimationBallClipRotateMultiple {
let animation = createAnimationIn(duration: duration, timingFunction: timingFunction, reverse: reverse)

circle.frame = frame
circle.addAnimation(animation, forKey: "animation")
circle.add(animation, forKey: "animation")
layer.addSublayer(circle)
}

Expand Down
20 changes: 10 additions & 10 deletions IBAnimatable/ActivityIndicatorAnimationBallClipRotatePulse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class ActivityIndicatorAnimationBallClipRotatePulse: ActivityIndicatorAni

// MARK: Properties

private let duration: CFTimeInterval = 1
private let timingFunction = CAMediaTimingFunction(controlPoints: 0.09, 0.57, 0.49, 0.9)
fileprivate let duration: CFTimeInterval = 1
fileprivate let timingFunction = CAMediaTimingFunction(controlPoints: 0.09, 0.57, 0.49, 0.9)

// MARK: ActivityIndicatorAnimating

Expand All @@ -23,9 +23,9 @@ public class ActivityIndicatorAnimationBallClipRotatePulse: ActivityIndicatorAni

// MARK: Small circle

private extension ActivityIndicatorAnimationBallClipRotatePulse {
fileprivate extension ActivityIndicatorAnimationBallClipRotatePulse {

func smallCircleWith(duration duration: CFTimeInterval, timingFunction: CAMediaTimingFunction, layer: CALayer, size: CGSize, color: UIColor) {
func smallCircleWith(duration: CFTimeInterval, timingFunction: CAMediaTimingFunction, layer: CALayer, size: CGSize, color: UIColor) {
let animation = createSmallCircleAanimation()
let circleSize = size.width / 2
let circle = ActivityIndicatorShape.Circle.createLayerWith(size: CGSize(width: circleSize, height: circleSize), color: color)
Expand All @@ -34,7 +34,7 @@ private extension ActivityIndicatorAnimationBallClipRotatePulse {
width: circleSize,
height: circleSize)
circle.frame = frame
circle.addAnimation(animation, forKey: "animation")
circle.add(animation, forKey: "animation")
layer.addSublayer(circle)
}

Expand All @@ -45,25 +45,25 @@ private extension ActivityIndicatorAnimationBallClipRotatePulse {
animation.values = [1, 0.3, 1]
animation.duration = duration
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
return animation
}

}

// MARK: Big circle

private extension ActivityIndicatorAnimationBallClipRotatePulse {
fileprivate extension ActivityIndicatorAnimationBallClipRotatePulse {

func bigCircleWith(duration duration: CFTimeInterval, timingFunction: CAMediaTimingFunction, layer: CALayer, size: CGSize, color: UIColor) {
func bigCircleWith(duration: CFTimeInterval, timingFunction: CAMediaTimingFunction, layer: CALayer, size: CGSize, color: UIColor) {
let animation = createBigCircleAanimation()
let circle = ActivityIndicatorShape.RingTwoHalfVertical.createLayerWith(size: size, color: color)
let frame = CGRect(x: (layer.bounds.size.width - size.width) / 2,
y: (layer.bounds.size.height - size.height) / 2,
width: size.width,
height: size.height)
circle.frame = frame
circle.addAnimation(animation, forKey: "animation")
circle.add(animation, forKey: "animation")
layer.addSublayer(circle)
}

Expand All @@ -72,7 +72,7 @@ private extension ActivityIndicatorAnimationBallClipRotatePulse {
animation.animations = [scaleAnimation, rotateAnimation]
animation.duration = duration
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
return animation
}

Expand Down
8 changes: 4 additions & 4 deletions IBAnimatable/ActivityIndicatorAnimationBallGridBeat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ActivityIndicatorAnimationBallGridBeat: ActivityIndicatorAnimating

// MARK: Properties

private let timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
fileprivate let timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)

// MARK: ActivityIndicatorAnimating

Expand All @@ -35,7 +35,7 @@ public class ActivityIndicatorAnimationBallGridBeat: ActivityIndicatorAnimating
animation.duration = durations[3 * i + j]
animation.beginTime = beginTime + beginTimes[3 * i + j]
circle.frame = frame
circle.addAnimation(animation, forKey: "animation")
circle.add(animation, forKey: "animation")
layer.addSublayer(circle)
}
}
Expand All @@ -44,15 +44,15 @@ public class ActivityIndicatorAnimationBallGridBeat: ActivityIndicatorAnimating

// MARK: - Setup

private extension ActivityIndicatorAnimationBallGridBeat {
fileprivate extension ActivityIndicatorAnimationBallGridBeat {

var animation: CAKeyframeAnimation {
let animation = CAKeyframeAnimation(keyPath: "opacity")
animation.keyTimes = [0, 0.5, 1]
animation.timingFunctions = [timingFunction, timingFunction]
animation.values = [1, 0.7, 1]
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
return animation
}

Expand Down
8 changes: 4 additions & 4 deletions IBAnimatable/ActivityIndicatorAnimationBallGridPulse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ActivityIndicatorAnimationBallGridPulse: ActivityIndicatorAnimating

// MARK: Properties

private let timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
fileprivate let timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)

// MARK: ActivityIndicatorAnimating

Expand All @@ -35,7 +35,7 @@ public class ActivityIndicatorAnimationBallGridPulse: ActivityIndicatorAnimating
animation.duration = durations[3 * i + j]
animation.beginTime = beginTime + beginTimes[3 * i + j]
circle.frame = frame
circle.addAnimation(animation, forKey: "animation")
circle.add(animation, forKey: "animation")
layer.addSublayer(circle)
}
}
Expand All @@ -44,13 +44,13 @@ public class ActivityIndicatorAnimationBallGridPulse: ActivityIndicatorAnimating

// MARK: - Setup

private extension ActivityIndicatorAnimationBallGridPulse {
fileprivate extension ActivityIndicatorAnimationBallGridPulse {

var animation: CAAnimationGroup {
let animation = CAAnimationGroup()
animation.animations = [scaleAnimation, opacityAnimation]
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
return animation
}

Expand Down
6 changes: 3 additions & 3 deletions IBAnimatable/ActivityIndicatorAnimationBallPulse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public class ActivityIndicatorAnimationBallPulse: ActivityIndicatorAnimating {

animation.beginTime = beginTime + beginTimes[i]
circle.frame = frame
circle.addAnimation(animation, forKey: "animation")
circle.add(animation, forKey: "animation")
layer.addSublayer(circle)
}
}
}

// MARK: - Setup

private extension ActivityIndicatorAnimationBallPulse {
fileprivate extension ActivityIndicatorAnimationBallPulse {

var animation: CAKeyframeAnimation {
let duration: CFTimeInterval = 0.75
Expand All @@ -48,7 +48,7 @@ private extension ActivityIndicatorAnimationBallPulse {
animation.values = [1, 0.3, 1]
animation.duration = duration
animation.repeatCount = .infinity
animation.removedOnCompletion = false
animation.isRemovedOnCompletion = false
return animation
}

Expand Down
Loading

0 comments on commit 337a289

Please sign in to comment.