lottie-ios 3.4.3 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.github/FUNDING.yml +0 -11
  2. package/Lottie.xcodeproj/project.pbxproj +58 -58
  3. package/Lottie.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +22 -0
  4. package/Lottie.xcworkspace/xcshareddata/swiftpm/Package.resolved +2 -2
  5. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  6. package/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +1 -1
  7. package/Sources/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +10 -7
  8. package/Sources/Private/CoreAnimation/Animations/EllipseAnimation.swift +2 -2
  9. package/Sources/Private/CoreAnimation/Animations/GradientAnimations.swift +2 -2
  10. package/Sources/Private/CoreAnimation/Animations/LayerProperty.swift +2 -2
  11. package/Sources/Private/CoreAnimation/Animations/OpacityAnimation.swift +1 -1
  12. package/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift +3 -3
  13. package/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift +16 -16
  14. package/Sources/Private/CoreAnimation/Animations/StarAnimation.swift +11 -11
  15. package/Sources/Private/CoreAnimation/Animations/StrokeAnimation.swift +4 -4
  16. package/Sources/Private/CoreAnimation/Animations/TransformAnimations.swift +13 -13
  17. package/Sources/Private/CoreAnimation/CoreAnimationLayer.swift +3 -3
  18. package/Sources/Private/CoreAnimation/Layers/AnimationLayer.swift +1 -1
  19. package/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +1 -1
  20. package/Sources/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +1 -1
  21. package/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift +1 -1
  22. package/Sources/Private/CoreAnimation/Layers/RepeaterLayer.swift +9 -9
  23. package/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift +1 -1
  24. package/Sources/Private/CoreAnimation/ValueProviderStore.swift +1 -1
  25. package/Sources/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +2 -2
  26. package/Sources/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +1 -1
  27. package/Sources/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +2 -2
  28. package/Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +3 -3
  29. package/Sources/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +10 -10
  30. package/Sources/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +1 -1
  31. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +3 -3
  32. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +2 -2
  33. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +5 -5
  34. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +3 -3
  35. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +9 -9
  36. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +14 -14
  37. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +2 -2
  38. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +3 -3
  39. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +10 -10
  40. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +14 -14
  41. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +11 -11
  42. package/Sources/Private/Model/Keyframes/KeyframeData.swift +12 -12
  43. package/Sources/Private/Model/Layers/PreCompLayerModel.swift +3 -3
  44. package/Sources/Private/Model/Objects/DashPattern.swift +2 -2
  45. package/Sources/Private/Model/Objects/Marker.swift +4 -0
  46. package/Sources/Private/Model/Objects/Mask.swift +10 -8
  47. package/Sources/Private/Model/Objects/Transform.swift +39 -35
  48. package/Sources/Private/Model/ShapeItems/Ellipse.swift +6 -6
  49. package/Sources/Private/Model/ShapeItems/Fill.swift +6 -6
  50. package/Sources/Private/Model/ShapeItems/GradientFill.swift +15 -15
  51. package/Sources/Private/Model/ShapeItems/GradientStroke.swift +18 -18
  52. package/Sources/Private/Model/ShapeItems/Rectangle.swift +9 -9
  53. package/Sources/Private/Model/ShapeItems/Repeater.swift +37 -32
  54. package/Sources/Private/Model/ShapeItems/ShapeTransform.swift +34 -28
  55. package/Sources/Private/Model/ShapeItems/Star.swift +21 -21
  56. package/Sources/Private/Model/ShapeItems/Stroke.swift +9 -9
  57. package/Sources/Private/Model/ShapeItems/Trim.swift +9 -9
  58. package/Sources/Private/Model/Text/TextAnimator.swift +33 -33
  59. package/Sources/Private/Model/Text/TextDocument.swift +8 -8
  60. package/Sources/Private/RootAnimationLayer.swift +4 -4
  61. package/Sources/Private/Utility/Interpolatable/InterpolatableExtensions.swift +1 -1
  62. package/Sources/Private/Utility/Interpolatable/KeyframeGroup+Extensions.swift +4 -4
  63. package/Sources/Private/Utility/Primitives/ColorExtension.swift +7 -7
  64. package/Sources/Private/Utility/Primitives/VectorsExtensions.swift +29 -21
  65. package/Sources/{Private/Model/Animation.swift → Public/Animation/LottieAnimation.swift} +13 -5
  66. package/Sources/Public/Animation/{AnimationPublic.swift → LottieAnimationHelpers.swift} +32 -17
  67. package/Sources/Public/Animation/{AnimationView.swift → LottieAnimationView.swift} +68 -19
  68. package/Sources/Public/Animation/{AnimationViewInitializers.swift → LottieAnimationViewInitializers.swift} +6 -6
  69. package/Sources/Public/AnimationCache/AnimationCacheProvider.swift +3 -3
  70. package/Sources/Public/AnimationCache/LRUAnimationCache.swift +3 -3
  71. package/Sources/Public/DynamicProperties/AnimationKeypath.swift +3 -3
  72. package/Sources/Public/DynamicProperties/AnyValueProvider.swift +2 -2
  73. package/Sources/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +10 -10
  74. package/Sources/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +4 -4
  75. package/Sources/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +5 -5
  76. package/Sources/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +2 -2
  77. package/Sources/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +2 -2
  78. package/Sources/Public/FontProvider/AnimationFontProvider.swift +1 -1
  79. package/Sources/Public/ImageProvider/AnimationImageProvider.swift +2 -2
  80. package/Sources/Public/Keyframes/Interpolatable.swift +17 -17
  81. package/Sources/Public/Keyframes/Keyframe.swift +10 -10
  82. package/Sources/Public/LottieConfiguration.swift +1 -1
  83. package/Sources/Public/Primitives/{Color.swift → LottieColor.swift} +10 -2
  84. package/Sources/Public/Primitives/Vectors.swift +18 -2
  85. package/Sources/Public/TextProvider/AnimationTextProvider.swift +1 -1
  86. package/Sources/Public/iOS/AnimatedButton.swift +26 -24
  87. package/Sources/Public/iOS/AnimatedControl.swift +6 -6
  88. package/Sources/Public/iOS/AnimatedSwitch.swift +16 -11
  89. package/Sources/Public/iOS/Compatibility/CompatibleAnimationView.swift +23 -8
  90. package/Sources/Public/iOS/{AnimationViewBase.swift → LottieAnimationViewBase.swift} +4 -4
  91. package/Sources/Public/iOS/UIColorExtension.swift +2 -2
  92. package/Sources/Public/macOS/{AnimationViewBase.macOS.swift → LottieAnimationViewBase.macOS.swift} +4 -4
  93. package/Tests/AnimationKeypathTests.swift +1 -1
  94. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~22UHuHHSTYh5NFeueXXSDdev_8VAbw8H8yl2ICssaC0vaCLj2G2CGZCjUMEyki9c-k-CecFJRyspvzJLiQTjUw== +0 -0
  95. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~4VqMqsI5lOfxRppnud6-VDWcNsU8J7VgFCJfW2dXPwOcAkvU-I8Um5yp9n0Zv6nr3VmcxYggaVMDFfR0U_vjKw== +1 -0
  96. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~6DmZhylL-XQx-O08NugyWINI0ugrLVgVOpbrdp0sT2tEqw-jVD2vvBWYRnYHALkM2_qP2yy-VoovSMzfYALY8A== +0 -0
  97. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~9dj3E5foFK2l_1CEpoRxToU1N6jCdhRVc5vhR10fHS938L9w8HxbiVCPGxYy5981O6M1yZsD4tHFbqBMbER4bQ== +0 -0
  98. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~Bys36bGK_YkCjRNoPMkq3R0OcyPNrVNka1Gz45ilbXJTqp9xAJexx6qKBh86_fm7OgBCO0WS2gJBy77DUUnOOA== +1 -0
  99. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~QJMKb50ZfaWLSHxBSGPlrzULLCqTlb_6W-X0N1-e5PfwCKjpYKOElImsOwgZKVK0cdyf-6u4Zp3mm3BfGQVQ9Q== +0 -0
  100. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~YyEdK1WNFTPo-R3Og2OWduKSikuFYneXurEZbyNLZeDmJLJkd7Ew8jNxy4mvgZw4f4Sikp4swEjJgVzXqhev5g== +1 -0
  101. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~bZd73QR3pWGndrn46_NXJw2dUT7WdBjkH5fdPZ7EnzlcZ9Ifv6WR14RKeWI9diiEjcRJE7ZOWqZ9fzf2vvTnLw== +0 -0
  102. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~baCaLsz8Sq-r6sHhJcZeowVdrnrIxKwDps5Q1Aq38G2AQ3HaopZ9m3A8IXtTFSiZGNiO2qnM9yH7iJfuzC5K0A== +0 -0
  103. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~iZXYCVJLYHKtR7eFHwefLiejC9CkRbBBSkkZmwfkiDEIdUKE4GgVkdDrcHry91RF7d9y7AuYovfGVp1-fuNg0g== +0 -0
  104. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~pTTJImrF4EktmVXGCigWBn7v6YlbH5eFCXIW35CW-iyypvzFMXXYYbQO1ly6Bf3u6CdaepZko-L9obC1mjigMA== +0 -0
  105. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~sVXLeN9UCp6IsOPeuoY76nF-bP-w2rBm61UYvs5XE3o5XhbM7itN2s1XD5i9COIaVMytmUFB-mvCLCqHfHWwpw== +0 -0
  106. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~t8Vsjx3tjPBGQIElMCvqzxLS0hDmBGuLa_CEiB64N2Vxp3qoUfNF0Sar84QnEDOKfyVF6c1KTn1QYg7fRJrk8g== +0 -0
  107. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~zUmPx8nRHLa8-g1WWSYYzveS_6qmBf-y4xyS-dHzD7c_xWwPZlsfKg8UngImNdn0gxGOBSRmCeXbYwWpLfj_Rg== +0 -0
  108. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~22UHuHHSTYh5NFeueXXSDdev_8VAbw8H8yl2ICssaC0vaCLj2G2CGZCjUMEyki9c-k-CecFJRyspvzJLiQTjUw== +0 -0
  109. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~4VqMqsI5lOfxRppnud6-VDWcNsU8J7VgFCJfW2dXPwOcAkvU-I8Um5yp9n0Zv6nr3VmcxYggaVMDFfR0U_vjKw== +0 -0
  110. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~6DmZhylL-XQx-O08NugyWINI0ugrLVgVOpbrdp0sT2tEqw-jVD2vvBWYRnYHALkM2_qP2yy-VoovSMzfYALY8A== +0 -0
  111. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~9dj3E5foFK2l_1CEpoRxToU1N6jCdhRVc5vhR10fHS938L9w8HxbiVCPGxYy5981O6M1yZsD4tHFbqBMbER4bQ== +0 -0
  112. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~Bys36bGK_YkCjRNoPMkq3R0OcyPNrVNka1Gz45ilbXJTqp9xAJexx6qKBh86_fm7OgBCO0WS2gJBy77DUUnOOA== +0 -0
  113. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~QJMKb50ZfaWLSHxBSGPlrzULLCqTlb_6W-X0N1-e5PfwCKjpYKOElImsOwgZKVK0cdyf-6u4Zp3mm3BfGQVQ9Q== +0 -0
  114. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~YyEdK1WNFTPo-R3Og2OWduKSikuFYneXurEZbyNLZeDmJLJkd7Ew8jNxy4mvgZw4f4Sikp4swEjJgVzXqhev5g== +0 -0
  115. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~bZd73QR3pWGndrn46_NXJw2dUT7WdBjkH5fdPZ7EnzlcZ9Ifv6WR14RKeWI9diiEjcRJE7ZOWqZ9fzf2vvTnLw== +0 -0
  116. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~baCaLsz8Sq-r6sHhJcZeowVdrnrIxKwDps5Q1Aq38G2AQ3HaopZ9m3A8IXtTFSiZGNiO2qnM9yH7iJfuzC5K0A== +0 -0
  117. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~iZXYCVJLYHKtR7eFHwefLiejC9CkRbBBSkkZmwfkiDEIdUKE4GgVkdDrcHry91RF7d9y7AuYovfGVp1-fuNg0g== +0 -0
  118. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~pTTJImrF4EktmVXGCigWBn7v6YlbH5eFCXIW35CW-iyypvzFMXXYYbQO1ly6Bf3u6CdaepZko-L9obC1mjigMA== +0 -0
  119. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~sVXLeN9UCp6IsOPeuoY76nF-bP-w2rBm61UYvs5XE3o5XhbM7itN2s1XD5i9COIaVMytmUFB-mvCLCqHfHWwpw== +0 -0
  120. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~t8Vsjx3tjPBGQIElMCvqzxLS0hDmBGuLa_CEiB64N2Vxp3qoUfNF0Sar84QnEDOKfyVF6c1KTn1QYg7fRJrk8g== +0 -0
  121. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~zUmPx8nRHLa8-g1WWSYYzveS_6qmBf-y4xyS-dHzD7c_xWwPZlsfKg8UngImNdn0gxGOBSRmCeXbYwWpLfj_Rg== +0 -0
  122. package/Tests/Artifacts/LottieTests.xcresult/Info.plist +29 -0
  123. package/Tests/ParsingTests.swift +2 -2
  124. package/Tests/PerformanceTests.swift +9 -9
  125. package/Tests/SnapshotConfiguration.swift +4 -4
  126. package/Tests/SnapshotTests.swift +6 -6
  127. package/lottie-ios.podspec +1 -1
  128. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  //
2
- // Color.swift
2
+ // LottieColor.swift
3
3
  // lottie-swift
4
4
  //
5
5
  // Created by Brandon Withrow on 2/4/19.
@@ -28,7 +28,15 @@ public enum ColorFormatDenominator: Hashable {
28
28
 
29
29
  // MARK: - Color
30
30
 
31
- public struct Color: Hashable {
31
+ @available(*, deprecated, renamed: "LottieColor", message: """
32
+ `Lottie.Color` has been renamed to `LottieColor`, to prevent conflicts with \
33
+ the `SwiftUI.Color` type. This notice will be removed in Lottie 4.0.
34
+ """)
35
+ public typealias Color = LottieColor
36
+
37
+ // MARK: - LottieColor
38
+
39
+ public struct LottieColor: Hashable {
32
40
 
33
41
  public var r: Double
34
42
  public var g: Double
@@ -9,7 +9,15 @@ import Foundation
9
9
 
10
10
  // MARK: - Vector1D
11
11
 
12
- public struct Vector1D: Hashable {
12
+ @available(*, deprecated, renamed: "LottieVector1D", message: """
13
+ `Lottie.Vector1D` has been renamed to `LottieVector1D` for consistency with \
14
+ the new `LottieVector3D` type. This notice will be removed in Lottie 4.0.
15
+ """)
16
+ public typealias Vector1D = LottieVector1D
17
+
18
+ // MARK: - LottieVector1D
19
+
20
+ public struct LottieVector1D: Hashable {
13
21
 
14
22
  public init(_ value: Double) {
15
23
  self.value = value
@@ -21,9 +29,17 @@ public struct Vector1D: Hashable {
21
29
 
22
30
  // MARK: - Vector3D
23
31
 
32
+ @available(*, deprecated, renamed: "LottieVector3D", message: """
33
+ `Lottie.Vector3D` has been renamed to `LottieVector3D`, to prevent conflicts with \
34
+ the Apple SDK `Spatial.Vector3D` type. This notice will be removed in Lottie 4.0.
35
+ """)
36
+ public typealias Vector3D = LottieVector3D
37
+
38
+ // MARK: - LottieVector3D
39
+
24
40
  /// A three dimensional vector.
25
41
  /// These vectors are encoded and decoded from [Double]
26
- public struct Vector3D: Hashable {
42
+ public struct LottieVector3D: Hashable {
27
43
 
28
44
  public let x: Double
29
45
  public let y: Double
@@ -9,7 +9,7 @@ import Foundation
9
9
 
10
10
  // MARK: - AnimationTextProvider
11
11
 
12
- /// Text provider is a protocol that is used to supply text to `AnimationView`.
12
+ /// Text provider is a protocol that is used to supply text to `LottieAnimationView`.
13
13
  public protocol AnimationTextProvider: AnyObject {
14
14
  func textFor(keypathName: String, sourceText: String) -> String
15
15
  }
@@ -14,7 +14,7 @@ open class AnimatedButton: AnimatedControl {
14
14
  // MARK: Lifecycle
15
15
 
16
16
  public override init(
17
- animation: Animation,
17
+ animation: LottieAnimation,
18
18
  configuration: LottieConfiguration = .shared)
19
19
  {
20
20
  super.init(animation: animation, configuration: configuration)
@@ -31,29 +31,9 @@ open class AnimatedButton: AnimatedControl {
31
31
  isAccessibilityElement = true
32
32
  }
33
33
 
34
- // MARK: Public
35
-
36
- public override var accessibilityTraits: UIAccessibilityTraits {
37
- set { super.accessibilityTraits = newValue }
38
- get { super.accessibilityTraits.union(.button) }
39
- }
40
-
41
- /// Sets the play range for the given UIControlEvent.
42
- public func setPlayRange(fromProgress: AnimationProgressTime, toProgress: AnimationProgressTime, event: UIControl.Event) {
43
- rangesForEvents[event.rawValue] = (from: fromProgress, to: toProgress)
44
- }
34
+ // MARK: Open
45
35
 
46
- /// Sets the play range for the given UIControlEvent.
47
- public func setPlayRange(fromMarker fromName: String, toMarker toName: String, event: UIControl.Event) {
48
- if
49
- let start = animationView.progressTime(forMarker: fromName),
50
- let end = animationView.progressTime(forMarker: toName)
51
- {
52
- rangesForEvents[event.rawValue] = (from: start, to: end)
53
- }
54
- }
55
-
56
- public override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
36
+ open override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
57
37
  let _ = super.beginTracking(touch, with: event)
58
38
  let touchEvent = UIControl.Event.touchDown
59
39
  if let playrange = rangesForEvents[touchEvent.rawValue] {
@@ -62,7 +42,7 @@ open class AnimatedButton: AnimatedControl {
62
42
  return true
63
43
  }
64
44
 
65
- public override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
45
+ open override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
66
46
  super.endTracking(touch, with: event)
67
47
  let touchEvent: UIControl.Event
68
48
  if let touch = touch, bounds.contains(touch.location(in: self)) {
@@ -76,6 +56,28 @@ open class AnimatedButton: AnimatedControl {
76
56
  }
77
57
  }
78
58
 
59
+ // MARK: Public
60
+
61
+ public override var accessibilityTraits: UIAccessibilityTraits {
62
+ set { super.accessibilityTraits = newValue }
63
+ get { super.accessibilityTraits.union(.button) }
64
+ }
65
+
66
+ /// Sets the play range for the given UIControlEvent.
67
+ public func setPlayRange(fromProgress: AnimationProgressTime, toProgress: AnimationProgressTime, event: UIControl.Event) {
68
+ rangesForEvents[event.rawValue] = (from: fromProgress, to: toProgress)
69
+ }
70
+
71
+ /// Sets the play range for the given UIControlEvent.
72
+ public func setPlayRange(fromMarker fromName: String, toMarker toName: String, event: UIControl.Event) {
73
+ if
74
+ let start = animationView.progressTime(forMarker: fromName),
75
+ let end = animationView.progressTime(forMarker: toName)
76
+ {
77
+ rangesForEvents[event.rawValue] = (from: start, to: end)
78
+ }
79
+ }
80
+
79
81
  // MARK: Private
80
82
 
81
83
  private var rangesForEvents: [UInt : (from: CGFloat, to: CGFloat)] =
@@ -31,10 +31,10 @@ open class AnimatedControl: UIControl {
31
31
  // MARK: Initializers
32
32
 
33
33
  public init(
34
- animation: Animation,
34
+ animation: LottieAnimation,
35
35
  configuration: LottieConfiguration = .shared)
36
36
  {
37
- animationView = AnimationView(
37
+ animationView = LottieAnimationView(
38
38
  animation: animation,
39
39
  configuration: configuration)
40
40
 
@@ -43,13 +43,13 @@ open class AnimatedControl: UIControl {
43
43
  }
44
44
 
45
45
  public init() {
46
- animationView = AnimationView()
46
+ animationView = LottieAnimationView()
47
47
  super.init(frame: .zero)
48
48
  commonInit()
49
49
  }
50
50
 
51
51
  required public init?(coder aDecoder: NSCoder) {
52
- animationView = AnimationView()
52
+ animationView = LottieAnimationView()
53
53
  super.init(coder: aDecoder)
54
54
  commonInit()
55
55
  }
@@ -105,10 +105,10 @@ open class AnimatedControl: UIControl {
105
105
  // MARK: Public
106
106
 
107
107
  /// The animation view in which the animation is rendered.
108
- public let animationView: AnimationView
108
+ public let animationView: LottieAnimationView
109
109
 
110
110
  /// The animation backing the animated control.
111
- public var animation: Animation? {
111
+ public var animation: LottieAnimation? {
112
112
  didSet {
113
113
  animationView.animation = animation
114
114
  animationView.bounds = animation?.bounds ?? .zero
@@ -18,7 +18,7 @@ open class AnimatedSwitch: AnimatedControl {
18
18
  // MARK: Lifecycle
19
19
 
20
20
  public override init(
21
- animation: Animation,
21
+ animation: LottieAnimation,
22
22
  configuration: LottieConfiguration = .shared)
23
23
  {
24
24
  /// Generate a haptic generator if available.
@@ -67,6 +67,18 @@ open class AnimatedSwitch: AnimatedControl {
67
67
  isAccessibilityElement = true
68
68
  }
69
69
 
70
+ // MARK: Open
71
+
72
+ open override func animationDidSet() {
73
+ updateOnState(isOn: _isOn, animated: animateUpdateWhenChangingAnimation, shouldFireHaptics: false)
74
+ }
75
+
76
+ open override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
77
+ super.endTracking(touch, with: event)
78
+ updateOnState(isOn: !_isOn, animated: true, shouldFireHaptics: true)
79
+ sendActions(for: .valueChanged)
80
+ }
81
+
70
82
  // MARK: Public
71
83
 
72
84
  /// Defines what happens when the user taps the switch while an
@@ -79,6 +91,9 @@ open class AnimatedSwitch: AnimatedControl {
79
91
  /// The cancel behavior for the switch. See CancelBehavior for options
80
92
  public var cancelBehavior: CancelBehavior = .reverse
81
93
 
94
+ /// If `false` the switch will not play the animation when changing between animations.
95
+ public var animateUpdateWhenChangingAnimation = true
96
+
82
97
  public override var accessibilityTraits: UIAccessibilityTraits {
83
98
  set { super.accessibilityTraits = newValue }
84
99
  get { super.accessibilityTraits.union(.button) }
@@ -119,16 +134,6 @@ open class AnimatedSwitch: AnimatedControl {
119
134
  updateOnState(isOn: _isOn, animated: false, shouldFireHaptics: false)
120
135
  }
121
136
 
122
- public override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
123
- super.endTracking(touch, with: event)
124
- updateOnState(isOn: !_isOn, animated: true, shouldFireHaptics: true)
125
- sendActions(for: .valueChanged)
126
- }
127
-
128
- public override func animationDidSet() {
129
- updateOnState(isOn: _isOn, animated: true, shouldFireHaptics: false)
130
- }
131
-
132
137
  // MARK: Internal
133
138
 
134
139
  // MARK: Animation State
@@ -25,8 +25,8 @@ public final class CompatibleAnimation: NSObject {
25
25
 
26
26
  // MARK: Internal
27
27
 
28
- internal var animation: Animation? {
29
- Animation.named(name, bundle: bundle)
28
+ internal var animation: LottieAnimation? {
29
+ LottieAnimation.named(name, bundle: bundle)
30
30
  }
31
31
 
32
32
  @objc
@@ -40,7 +40,7 @@ public final class CompatibleAnimation: NSObject {
40
40
  private let bundle: Bundle
41
41
  }
42
42
 
43
- /// An Objective-C compatible wrapper around Lottie's AnimationView.
43
+ /// An Objective-C compatible wrapper around Lottie's LottieAnimationView.
44
44
  @objc
45
45
  public final class CompatibleAnimationView: UIView {
46
46
 
@@ -48,7 +48,7 @@ public final class CompatibleAnimationView: UIView {
48
48
 
49
49
  @objc
50
50
  public init(compatibleAnimation: CompatibleAnimation) {
51
- animationView = AnimationView(animation: compatibleAnimation.animation)
51
+ animationView = LottieAnimationView(animation: compatibleAnimation.animation)
52
52
  self.compatibleAnimation = compatibleAnimation
53
53
  super.init(frame: .zero)
54
54
  commonInit()
@@ -56,7 +56,7 @@ public final class CompatibleAnimationView: UIView {
56
56
 
57
57
  @objc
58
58
  public override init(frame: CGRect) {
59
- animationView = AnimationView()
59
+ animationView = LottieAnimationView()
60
60
  super.init(frame: frame)
61
61
  commonInit()
62
62
  }
@@ -186,6 +186,16 @@ public final class CompatibleAnimationView: UIView {
186
186
  completion: completion)
187
187
  }
188
188
 
189
+ @objc
190
+ public func play(
191
+ marker: String,
192
+ completion: ((Bool) -> Void)? = nil)
193
+ {
194
+ animationView.play(
195
+ marker: marker,
196
+ completion: completion)
197
+ }
198
+
189
199
  @objc
190
200
  public func stop() {
191
201
  animationView.stop()
@@ -242,14 +252,14 @@ public final class CompatibleAnimationView: UIView {
242
252
  color.getRed(&red, green: &green, blue: &blue, alpha: &alpha)
243
253
  }
244
254
 
245
- let valueProvider = ColorValueProvider(Color(r: Double(red), g: Double(green), b: Double(blue), a: Double(alpha)))
255
+ let valueProvider = ColorValueProvider(LottieColor(r: Double(red), g: Double(green), b: Double(blue), a: Double(alpha)))
246
256
  animationView.setValueProvider(valueProvider, keypath: keypath.animationKeypath)
247
257
  }
248
258
 
249
259
  @objc
250
260
  public func getColorValue(for keypath: CompatibleAnimationKeypath, atFrame: CGFloat) -> UIColor? {
251
261
  let value = animationView.getValue(for: keypath.animationKeypath, atFrame: atFrame)
252
- guard let colorValue = value as? Color else {
262
+ guard let colorValue = value as? LottieColor else {
253
263
  return nil;
254
264
  }
255
265
 
@@ -302,9 +312,14 @@ public final class CompatibleAnimationView: UIView {
302
312
  animationView.frameTime(forMarker: named) ?? 0
303
313
  }
304
314
 
315
+ @objc
316
+ public func durationFrameTime(forMarker named: String) -> CGFloat {
317
+ animationView.durationFrameTime(forMarker: named) ?? 0
318
+ }
319
+
305
320
  // MARK: Private
306
321
 
307
- private let animationView: AnimationView
322
+ private let animationView: LottieAnimationView
308
323
 
309
324
  private func commonInit() {
310
325
  translatesAutoresizingMaskIntoConstraints = false
@@ -1,5 +1,5 @@
1
1
  //
2
- // AnimationViewBase.swift
2
+ // LottieAnimationViewBase.swift
3
3
  // lottie-swift-iOS
4
4
  //
5
5
  // Created by Brandon Withrow on 2/6/19.
@@ -8,10 +8,10 @@
8
8
  #if os(iOS) || os(tvOS) || os(watchOS) || targetEnvironment(macCatalyst)
9
9
  import UIKit
10
10
 
11
- /// The base view for `AnimationView` on iOS, tvOS, watchOS, and macCatalyst.
11
+ /// The base view for `LottieAnimationView` on iOS, tvOS, watchOS, and macCatalyst.
12
12
  ///
13
- /// Enables the `AnimationView` implementation to be shared across platforms.
14
- public class AnimationViewBase: UIView {
13
+ /// Enables the `LottieAnimationView` implementation to be shared across platforms.
14
+ public class LottieAnimationViewBase: UIView {
15
15
 
16
16
  // MARK: Public
17
17
 
@@ -11,10 +11,10 @@ import UIKit
11
11
 
12
12
  extension UIColor {
13
13
 
14
- public var lottieColorValue: Color {
14
+ public var lottieColorValue: LottieColor {
15
15
  var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
16
16
  getRed(&r, green: &g, blue: &b, alpha: &a)
17
- return Color(r: Double(r), g: Double(g), b: Double(b), a: Double(a))
17
+ return LottieColor(r: Double(r), g: Double(g), b: Double(b), a: Double(a))
18
18
  }
19
19
 
20
20
  }
@@ -1,5 +1,5 @@
1
1
  //
2
- // AnimationViewBase.swift
2
+ // LottieAnimationViewBase.swift
3
3
  // lottie-swift-iOS
4
4
  //
5
5
  // Created by Brandon Withrow on 2/6/19.
@@ -24,10 +24,10 @@ public enum LottieContentMode: Int {
24
24
  case bottomRight
25
25
  }
26
26
 
27
- /// The base view for `AnimationView` on macOs.
27
+ /// The base view for `LottieAnimationView` on macOs.
28
28
  ///
29
- /// Enables the `AnimationView` implementation to be shared across platforms.
30
- public class AnimationViewBase: NSView {
29
+ /// Enables the `LottieAnimationView` implementation to be shared across platforms.
30
+ public class LottieAnimationViewBase: NSView {
31
31
 
32
32
  // MARK: Public
33
33
 
@@ -29,7 +29,7 @@ final class AnimationKeypathTests: XCTestCase {
29
29
  }
30
30
 
31
31
  func testLayerForKeypath() {
32
- let animationView = AnimationView(
32
+ let animationView = LottieAnimationView(
33
33
  animation: Samples.animation(named: "Boat_Loader"),
34
34
  configuration: LottieConfiguration(renderingEngine: .mainThread))
35
35
 
@@ -0,0 +1 @@
1
+ [{"name":"LottieTests-D2EA3CFB-B5FF-47F6-B3AB-804D6728A9BA","type":2},{"name":"scheduling.log","type":1}]
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>dateCreated</key>
6
+ <date>2022-10-11T00:03:18Z</date>
7
+ <key>externalLocations</key>
8
+ <array/>
9
+ <key>rootId</key>
10
+ <dict>
11
+ <key>hash</key>
12
+ <string>0~22UHuHHSTYh5NFeueXXSDdev_8VAbw8H8yl2ICssaC0vaCLj2G2CGZCjUMEyki9c-k-CecFJRyspvzJLiQTjUw==</string>
13
+ </dict>
14
+ <key>storage</key>
15
+ <dict>
16
+ <key>backend</key>
17
+ <string>fileBacked2</string>
18
+ <key>compression</key>
19
+ <string>standard</string>
20
+ </dict>
21
+ <key>version</key>
22
+ <dict>
23
+ <key>major</key>
24
+ <integer>3</integer>
25
+ <key>minor</key>
26
+ <integer>39</integer>
27
+ </dict>
28
+ </dict>
29
+ </plist>
@@ -18,8 +18,8 @@ final class ParsingTests: XCTestCase {
18
18
  for url in Samples.sampleAnimationURLs {
19
19
  do {
20
20
  let data = try Data(contentsOf: url)
21
- let codableAnimation = try Animation.from(data: data, strategy: .codable)
22
- let dictAnimation = try Animation.from(data: data, strategy: .dictionaryBased)
21
+ let codableAnimation = try LottieAnimation.from(data: data, strategy: .codable)
22
+ let dictAnimation = try LottieAnimation.from(data: data, strategy: .dictionaryBased)
23
23
 
24
24
  XCTAssertNoDiff(codableAnimation, dictAnimation)
25
25
  } catch {
@@ -85,12 +85,12 @@ final class PerformanceTests: XCTestCase {
85
85
 
86
86
  // MARK: Private
87
87
 
88
- private let simpleAnimation = Animation.named(
88
+ private let simpleAnimation = LottieAnimation.named(
89
89
  "loading_dots_1",
90
90
  bundle: .module,
91
91
  subdirectory: "Samples/LottieFiles")!
92
92
 
93
- private let complexAnimation = Animation.named(
93
+ private let complexAnimation = LottieAnimation.named(
94
94
  "LottieLogo2",
95
95
  bundle: .module,
96
96
  subdirectory: "Samples")!
@@ -100,7 +100,7 @@ final class PerformanceTests: XCTestCase {
100
100
  private func compareEngineSetupPerformance(
101
101
  of engineA: RenderingEngineOption,
102
102
  with engineB: RenderingEngineOption,
103
- for animation: Animation,
103
+ for animation: LottieAnimation,
104
104
  iterations: Int)
105
105
  -> Double
106
106
  {
@@ -125,7 +125,7 @@ final class PerformanceTests: XCTestCase {
125
125
  return ratio
126
126
  }
127
127
 
128
- private func setUpAndTearDownAnimationView(with animation: Animation, configuration: LottieConfiguration) {
128
+ private func setUpAndTearDownAnimationView(with animation: LottieAnimation, configuration: LottieConfiguration) {
129
129
  // Each animation setup needs to be wrapped in its own `CATransaction`
130
130
  // in order for the layers to be deallocated immediately. Otherwise
131
131
  // the layers aren't deallocated until the end of the test run,
@@ -142,7 +142,7 @@ final class PerformanceTests: XCTestCase {
142
142
 
143
143
  /// Compares performance of scrubbing the given animation with both the Main Thread and Core Animation engine,
144
144
  /// and returns the ratio of how much slower the Core Animation is than the Main Thread engine
145
- private func compareEngineScrubbingPerformance(for animation: Animation, iterations: Int) -> Double {
145
+ private func compareEngineScrubbingPerformance(for animation: LottieAnimation, iterations: Int) -> Double {
146
146
  let mainThreadAnimationView = setupAnimationView(with: animation, configuration: .init(renderingEngine: .mainThread))
147
147
  let mainThreadEnginePerformance = measurePerformance {
148
148
  for i in 0..<iterations {
@@ -177,7 +177,7 @@ final class PerformanceTests: XCTestCase {
177
177
  private func compareDeserializationPerformance(data: Data, iterations: Int) throws -> Double {
178
178
  let codablePerformance = try measurePerformance {
179
179
  for _ in 0..<iterations {
180
- _ = try Animation.from(data: data, strategy: .codable)
180
+ _ = try LottieAnimation.from(data: data, strategy: .codable)
181
181
  }
182
182
  }
183
183
 
@@ -185,7 +185,7 @@ final class PerformanceTests: XCTestCase {
185
185
 
186
186
  let dictPerformance = try measurePerformance {
187
187
  for _ in 0..<iterations {
188
- _ = try Animation.from(data: data, strategy: .dictionaryBased)
188
+ _ = try LottieAnimation.from(data: data, strategy: .dictionaryBased)
189
189
  }
190
190
  }
191
191
 
@@ -196,8 +196,8 @@ final class PerformanceTests: XCTestCase {
196
196
  }
197
197
 
198
198
  @discardableResult
199
- private func setupAnimationView(with animation: Animation, configuration: LottieConfiguration) -> AnimationView {
200
- let animationView = AnimationView(animation: animation, configuration: configuration)
199
+ private func setupAnimationView(with animation: LottieAnimation, configuration: LottieConfiguration) -> LottieAnimationView {
200
+ let animationView = LottieAnimationView(animation: animation, configuration: configuration)
201
201
  animationView.frame.size = CGSize(width: animation.width, height: animation.height)
202
202
  animationView.layoutIfNeeded()
203
203
  return animationView
@@ -59,9 +59,9 @@ extension SnapshotConfiguration {
59
59
  AnimationKeypath(keypath: "Checkmark Outlines 2.Group 1.Stroke 1.Color"): ColorValueProvider(.black),
60
60
  AnimationKeypath(keypath: "X Outlines.Group 1.Stroke 1.Color"): ColorValueProvider(.black),
61
61
  AnimationKeypath(keypath: "Switch Outline Outlines.Fill 1.Color"): ColorValueProvider([
62
- Keyframe(value: Color.black, time: 0),
62
+ Keyframe(value: LottieColor.black, time: 0),
63
63
  Keyframe(value: Color(r: 0.76, g: 0.76, b: 0.76, a: 1), time: 75),
64
- Keyframe(value: Color.black, time: 150),
64
+ Keyframe(value: LottieColor.black, time: 150),
65
65
  ]),
66
66
  ]),
67
67
 
@@ -163,9 +163,9 @@ extension SnapshotConfiguration {
163
163
  }
164
164
  }
165
165
 
166
- // MARK: - Color helpers
166
+ // MARK: - LottieColor helpers
167
167
 
168
- extension Color {
168
+ extension LottieColor {
169
169
  static let black = Color(r: 0, g: 0, b: 0, a: 1)
170
170
  static let red = Color(r: 1, g: 0, b: 0, a: 1)
171
171
  }