Skip to content

Commit

Permalink
Migrated to swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
buba447 committed Mar 18, 2019
1 parent aa654ec commit 24df501
Show file tree
Hide file tree
Showing 20 changed files with 1,827 additions and 1,827 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
lottie-ios: 8563142c9d9032a42d811fbe95603fa3064bd710
lottie-ios: 6bfae5abcc50a6c40a652bfc7f614638c4867ed4

PODFILE CHECKSUM: d7d1d3df3df6c9862ab67dbbfb2f695895dc9d7b

Expand Down
2 changes: 1 addition & 1 deletion Example/Pods/Local Podspecs/lottie-ios.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3,534 changes: 1,767 additions & 1,767 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Example/lottie-swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
669CBA494BD2722D6FA87704 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
90A6D05A7336A0F45A1084BE /* Pods-lottie-swift_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-lottie-swift_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-lottie-swift_Example/Pods-lottie-swift_Example.debug.xcconfig"; sourceTree = "<group>"; };
91240075B0C8FCDB8EE7FA52 /* lottie-swift.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = "lottie-swift.podspec"; path = "../lottie-swift.podspec"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
91240075B0C8FCDB8EE7FA52 /* lottie-ios.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = "lottie-ios.podspec"; path = "../lottie-ios.podspec"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
990C0AA8A35456B23B51C127 /* Pods-lottie-swift_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-lottie-swift_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-lottie-swift_Example/Pods-lottie-swift_Example.release.xcconfig"; sourceTree = "<group>"; };
9BE45D36D5254BD996E95AB1 /* Pods-lottie-swift_macOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-lottie-swift_macOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-lottie-swift_macOS/Pods-lottie-swift_macOS.release.xcconfig"; sourceTree = "<group>"; };
9C512735B8BB596E2E2D58CE /* Pods-lottie-swift_tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-lottie-swift_tvOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-lottie-swift_tvOS/Pods-lottie-swift_tvOS.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -263,7 +263,7 @@
607FACF51AFB993E008FA782 /* Podspec Metadata */ = {
isa = PBXGroup;
children = (
91240075B0C8FCDB8EE7FA52 /* lottie-swift.podspec */,
91240075B0C8FCDB8EE7FA52 /* lottie-ios.podspec */,
0695C7B5BDA439EA2E490058 /* README.md */,
669CBA494BD2722D6FA87704 /* LICENSE */,
);
Expand Down
4 changes: 2 additions & 2 deletions Example/lottie-swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down
20 changes: 10 additions & 10 deletions Lottie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.airbnb.Lottie-iOS";
PRODUCT_NAME = Lottie;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -2334,7 +2334,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.airbnb.Lottie-iOS";
PRODUCT_NAME = Lottie;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -2360,7 +2360,7 @@
PRODUCT_NAME = Lottie;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -2387,7 +2387,7 @@
PRODUCT_NAME = Lottie;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand Down Expand Up @@ -2417,7 +2417,7 @@
PRODUCT_NAME = Lottie;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -2445,7 +2445,7 @@
PRODUCT_NAME = Lottie;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -2458,7 +2458,7 @@
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Lottie;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -2471,7 +2471,7 @@
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Lottie;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -2488,7 +2488,7 @@
PRODUCT_NAME = Lottie;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -2503,7 +2503,7 @@
PRODUCT_NAME = Lottie;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ Lottie comes prepacked with a two Animated Controls, `AnimatedSwitch` and `Anima

`AnimatedControl` is a subclass of `UIControl` that provides an interactive mechanism for controlling the visual state of an animation in response to user actions.

The `AnimatedControl` will show and hide layers depending on the current `UIControlState` of the control.
The `AnimatedControl` will show and hide layers depending on the current `UIControl.State` of the control.

Users of `AnimationControl` can set a Layer Name for each `UIControlState`. When the state is change the `AnimationControl` will change the visibility of its layers.
Users of `AnimationControl` can set a Layer Name for each `UIControl.State`. When the state is change the `AnimationControl` will change the visibility of its layers.

[Back to contents](#contents)
## Animated Switch
Expand All @@ -642,16 +642,16 @@ public func setProgressForState(fromProgress: AnimationProgressTime,
![HeartButton](_Gifs/HeartButton.gif)

An interactive button that plays an animation when pressed.
The `AnimatedButton` can play a variety of time ranges for different `UIControlEvents`. Play ranges are set using either:
The `AnimatedButton` can play a variety of time ranges for different `UIControl.Event`. Play ranges are set using either:
```swift
/// Set a play range with Progress Time.
public func setPlayRange(fromProgress: AnimationProgressTime,
toProgress: AnimationProgressTime,
event: UIControlEvents)
event: UIControl.Event)
/// Set a play range with Marker Keys.
public func setPlayRange(fromMarker fromName: String,
toMarker toName: String,
event: UIControlEvents)
event: UIControl.Event)
```
Once set the animation will automatically play when the event is triggered.

Expand Down
2 changes: 1 addition & 1 deletion lottie-ios.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DESC
s.author = { 'Brandon Withrow' => '[email protected]' }
s.source = { :git => 'https://github.com/airbnb/lottie-ios.git', :tag => s.version.to_s }

s.swift_version = '4.0'
s.swift_version = '4.2'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.10'
s.tvos.deployment_target = '9.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class AnimationContainer: CALayer {
override public func action(forKey event: String) -> CAAction? {
if event == "currentFrame" {
let animation = CABasicAnimation(keyPath: event)
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
animation.fromValue = self.presentation()?.currentFrame
return animation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ImageCompositionLayer: CompositionLayer {
self.imageReferenceID = imageLayer.referenceID
super.init(layer: imageLayer, size: size)
contentsLayer.masksToBounds = true
contentsLayer.contentsGravity = kCAGravityResize
contentsLayer.contentsGravity = CALayerContentsGravity.resize
}

override init(layer: Any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fileprivate class MaskLayer: CALayer {
anchorPoint = .zero
maskLayer.fillColor = mask.mode == .add ? CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1, 0, 0, 1]) :
CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [0, 1, 0, 1])
maskLayer.fillRule = kCAFillRuleEvenOdd
maskLayer.fillRule = CAShapeLayerFillRule.evenOdd
self.actions = [
"opacity" : NSNull()
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ class TextCompositionLayer: CompositionLayer {
let matrix = rootNode?.textOutputNode.xform ?? CATransform3DIdentity
let ctFont = CTFontCreateWithName(text.fontFamily as CFString, CGFloat(text.fontSize), nil)

var attributes: [NSAttributedStringKey : Any] = [
NSAttributedStringKey.font: ctFont,
NSAttributedStringKey.foregroundColor: fillColor,
NSAttributedStringKey.kern: tracking,
var attributes: [NSAttributedString.Key : Any] = [
NSAttributedString.Key.font: ctFont,
NSAttributedString.Key.foregroundColor: fillColor,
NSAttributedString.Key.kern: tracking,
]

if let strokeColor = strokeColor {
attributes[NSAttributedStringKey.strokeColor] = strokeColor
attributes[NSAttributedStringKey.strokeWidth] = strokeWidth
attributes[NSAttributedString.Key.strokeColor] = strokeColor
attributes[NSAttributedString.Key.strokeWidth] = strokeWidth
}

let attributedString = NSAttributedString(string: text.text, attributes: attributes )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ extension FillRule {
}
}

var caFillRule: String {
var caFillRule: CAShapeLayerFillRule {
switch self {
case .evenOdd:
return kCAFillRuleEvenOdd
return CAShapeLayerFillRule.evenOdd
default:
return kCAFillRuleNonZero
return CAShapeLayerFillRule.nonZero
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ extension LineJoin {
}
}

var caLineJoin: String {
var caLineJoin: CAShapeLayerLineJoin {
switch self {
case .none:
return kCALineJoinMiter
return CAShapeLayerLineJoin.miter
case .miter:
return kCALineJoinMiter
return CAShapeLayerLineJoin.miter
case .round:
return kCALineJoinRound
return CAShapeLayerLineJoin.round
case .bevel:
return kCALineJoinBevel
return CAShapeLayerLineJoin.bevel
}
}
}
Expand All @@ -50,16 +50,16 @@ extension LineCap {
}
}

var caLineCap: String {
var caLineCap: CAShapeLayerLineCap {
switch self {
case .none:
return kCALineCapButt
return CAShapeLayerLineCap.butt
case .butt:
return kCALineCapButt
return CAShapeLayerLineCap.butt
case .round:
return kCALineCapRound
return CAShapeLayerLineCap.round
case .square:
return kCALineCapSquare
return CAShapeLayerLineCap.square
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lottie-swift/src/Public/Animation/AnimationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ final public class AnimationView: LottieView {
layerAnimation.toValue = playTo
layerAnimation.speed = Float(animationSpeed)
layerAnimation.duration = TimeInterval(duration)
layerAnimation.fillMode = kCAFillModeBoth
layerAnimation.fillMode = CAMediaTimingFillMode.both

layerAnimation.repeatCount = loopMode == .playOnce ? 1 : HUGE
layerAnimation.autoreverses = loopMode == .autoReverse ? true : false
Expand Down
12 changes: 6 additions & 6 deletions lottie-swift/src/Public/iOS/AnimatedButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import UIKit
final public class AnimatedButton: AnimatedControl {

/// Sets the play range for the given UIControlEvent.
public func setPlayRange(fromProgress: AnimationProgressTime, toProgress: AnimationProgressTime, event: UIControlEvents) {
public func setPlayRange(fromProgress: AnimationProgressTime, toProgress: AnimationProgressTime, event: UIControl.Event) {
rangesForEvents[event.rawValue] = (from: fromProgress, to: toProgress)
}

/// Sets the play range for the given UIControlEvent.
public func setPlayRange(fromMarker fromName: String, toMarker toName: String, event: UIControlEvents) {
public func setPlayRange(fromMarker fromName: String, toMarker toName: String, event: UIControl.Event) {
if let start = animationView.progressTime(forMarker: fromName),
let end = animationView.progressTime(forMarker: toName) {
rangesForEvents[event.rawValue] = (from: start, to: end)
Expand All @@ -27,15 +27,15 @@ final public class AnimatedButton: AnimatedControl {

public override init(animation: Animation) {
super.init(animation: animation)
self.accessibilityTraits = UIAccessibilityTraitButton
self.accessibilityTraits = UIAccessibilityTraits.button
}

public override init() {
super.init()
self.accessibilityTraits = UIAccessibilityTraitButton
self.accessibilityTraits = UIAccessibilityTraits.button
}

fileprivate var rangesForEvents: [UInt : (from: CGFloat, to: CGFloat)] = [UIControlEvents.touchUpInside.rawValue : (from: 0, to: 1)]
fileprivate var rangesForEvents: [UInt : (from: CGFloat, to: CGFloat)] = [UIControl.Event.touchUpInside.rawValue : (from: 0, to: 1)]

required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
Expand All @@ -53,7 +53,7 @@ final public class AnimatedButton: AnimatedControl {

public override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
super.endTracking(touch, with: event)
let touchEvent: UIControlEvents
let touchEvent: UIControl.Event
if let touch = touch, bounds.contains(touch.location(in: self)) {
touchEvent = UIControl.Event.touchUpInside
} else {
Expand Down
6 changes: 3 additions & 3 deletions lottie-swift/src/Public/iOS/AnimatedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import UIKit
user actions.
The `AnimatedControl` will show and hide layers depending on the current
`UIControlState` of the control.
`UIControl.State` of the control.
Users of `AnimationControl` can set a Layer Name for each `UIControlState`.
Users of `AnimationControl` can set a Layer Name for each `UIControl.State`.
When the state is change the `AnimationControl` will change the visibility
of its layers.
Expand All @@ -40,7 +40,7 @@ open class AnimatedControl: UIControl {
}

/// Sets which Animation Layer should be visible for the given state.
public func setLayer(named: String, forState: UIControlState) {
public func setLayer(named: String, forState: UIControl.State) {
stateMap[forState.rawValue] = named
updateForState()
}
Expand Down
4 changes: 2 additions & 2 deletions lottie-swift/src/Public/iOS/AnimatedSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final public class AnimatedSwitch: AnimatedControl {
self.hapticGenerator = NullHapticGenerator()
#endif
super.init(animation: animation)
self.accessibilityTraits = UIAccessibilityTraitButton
self.accessibilityTraits = UIAccessibilityTraits.button
}

public override init() {
Expand All @@ -68,7 +68,7 @@ final public class AnimatedSwitch: AnimatedControl {
self.hapticGenerator = NullHapticGenerator()
#endif
super.init()
self.accessibilityTraits = UIAccessibilityTraitButton
self.accessibilityTraits = UIAccessibilityTraits.button
}

required public init?(coder aDecoder: NSCoder) {
Expand Down
Loading

0 comments on commit 24df501

Please sign in to comment.