lottie-ios 3.2.2 → 3.4.1

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 (316) hide show
  1. package/.github/actions/setup/action.yml +32 -0
  2. package/.github/issue_template.md +6 -23
  3. package/.github/workflows/main.yml +98 -0
  4. package/.spi.yml +6 -0
  5. package/.swift-version +1 -0
  6. package/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +7 -0
  7. package/.swiftpm/xcode/package.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  8. package/.swiftpm/xcode/xcuserdata/{brandonwithrow.xcuserdatad → cal.xcuserdatad}/xcschemes/xcschememanagement.plist +25 -15
  9. package/.swiftpm/xcode/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  10. package/Gemfile +4 -0
  11. package/Gemfile.lock +102 -0
  12. package/Lottie.xcodeproj/project.pbxproj +2003 -1972
  13. package/Lottie.xcodeproj/project.xcworkspace/contents.xcworkspacedata +1 -1
  14. package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  15. package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_iOS.xcscheme → Lottie (iOS).xcscheme } +15 -18
  16. package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_macOS.xcscheme → Lottie (macOS).xcscheme } +7 -20
  17. package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_tvOS.xcscheme → Lottie (tvOS).xcscheme } +5 -18
  18. package/Lottie.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +37 -0
  19. package/Lottie.xcodeproj/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +24 -0
  20. package/Lottie.xcworkspace/contents.xcworkspacedata +10 -0
  21. package/Lottie.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  22. package/Lottie.xcworkspace/xcshareddata/swiftpm/Package.resolved +115 -0
  23. package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  24. package/{Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad → Lottie.xcworkspace/xcuserdata/cal.xcuserdatad}/xcdebugger/Breakpoints_v2.xcbkptlist +2 -2
  25. package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/xcdebugger/Expressions.xcexplist +153 -0
  26. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  27. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +39 -0
  28. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Expressions.xcexplist +25 -0
  29. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +30 -0
  30. package/Package.resolved +88 -0
  31. package/Package.swift +10 -15
  32. package/README.md +40 -60
  33. package/Rakefile +121 -0
  34. package/Sources/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
  35. package/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +448 -0
  36. package/Sources/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +53 -0
  37. package/Sources/Private/CoreAnimation/Animations/CustomPathAnimation.swift +41 -0
  38. package/Sources/Private/CoreAnimation/Animations/EllipseAnimation.swift +28 -0
  39. package/Sources/Private/CoreAnimation/Animations/GradientAnimations.swift +210 -0
  40. package/Sources/Private/CoreAnimation/Animations/LayerProperty.swift +229 -0
  41. package/Sources/Private/CoreAnimation/Animations/OpacityAnimation.swift +52 -0
  42. package/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift +31 -0
  43. package/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
  44. package/Sources/Private/CoreAnimation/Animations/StarAnimation.swift +95 -0
  45. package/Sources/Private/CoreAnimation/Animations/StrokeAnimation.swift +70 -0
  46. package/Sources/Private/CoreAnimation/Animations/TransformAnimations.swift +205 -0
  47. package/Sources/Private/CoreAnimation/Animations/VisibilityAnimation.swift +37 -0
  48. package/Sources/Private/CoreAnimation/CompatibilityTracker.swift +130 -0
  49. package/Sources/Private/CoreAnimation/CoreAnimationLayer.swift +492 -0
  50. package/Sources/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
  51. package/Sources/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +37 -0
  52. package/Sources/Private/CoreAnimation/Extensions/Keyframes+combinedIfPossible.swift +73 -0
  53. package/Sources/Private/CoreAnimation/Layers/AnimationLayer.swift +83 -0
  54. package/Sources/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +33 -0
  55. package/Sources/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +87 -0
  56. package/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +131 -0
  57. package/Sources/Private/CoreAnimation/Layers/GradientRenderLayer.swift +94 -0
  58. package/Sources/Private/CoreAnimation/Layers/ImageLayer.swift +79 -0
  59. package/Sources/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +60 -0
  60. package/Sources/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +138 -0
  61. package/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift +140 -0
  62. package/Sources/Private/CoreAnimation/Layers/ShapeItemLayer.swift +302 -0
  63. package/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift +319 -0
  64. package/Sources/Private/CoreAnimation/Layers/SolidLayer.swift +47 -0
  65. package/Sources/Private/CoreAnimation/Layers/TextLayer.swift +91 -0
  66. package/Sources/Private/CoreAnimation/Layers/TransformLayer.swift +11 -0
  67. package/Sources/Private/CoreAnimation/ValueProviderStore.swift +139 -0
  68. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/CompositionLayer.swift +93 -85
  69. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/ImageCompositionLayer.swift +24 -21
  70. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/MaskContainerLayer.swift +75 -54
  71. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/NullCompositionLayer.swift +5 -5
  72. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/PreCompositionLayer.swift +61 -44
  73. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/ShapeCompositionLayer.swift +22 -20
  74. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/SolidCompositionLayer.swift +26 -17
  75. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/TextCompositionLayer.swift +42 -36
  76. package/{lottie-swift/src/Private/LayerContainers/AnimationContainer.swift → Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift} +200 -140
  77. package/Sources/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +47 -0
  78. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/CompositionLayersInitializer.swift +33 -24
  79. package/{lottie-swift/src/Private/LayerContainers/Utility/TextLayer.swift → Sources/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift} +120 -106
  80. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/InvertedMatteLayer.swift +25 -24
  81. package/Sources/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +41 -0
  82. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/LayerImageProvider.swift +20 -16
  83. package/Sources/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +40 -0
  84. package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/LayerTransformNode.swift +82 -67
  85. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Extensions/ItemsExtension.swift +4 -4
  86. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/NodeProperty.swift +29 -21
  87. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +16 -10
  88. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +6 -6
  89. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +5 -5
  90. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +10 -8
  91. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueContainer.swift +25 -21
  92. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +23 -17
  93. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/KeyframeInterpolator.swift +125 -108
  94. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +22 -17
  95. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +110 -79
  96. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +22 -16
  97. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +19 -15
  98. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +22 -20
  99. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +22 -23
  100. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +242 -0
  101. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +30 -24
  102. package/{lottie-swift/src/Private/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift → Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift} +93 -66
  103. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +23 -19
  104. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +139 -0
  105. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +170 -0
  106. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +95 -58
  107. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +42 -29
  108. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +108 -69
  109. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +155 -0
  110. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +51 -37
  111. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +54 -42
  112. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +65 -57
  113. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +84 -58
  114. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +138 -119
  115. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/AnimatorNode.swift +80 -79
  116. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/PathNode.swift +5 -3
  117. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/RenderNode.swift +22 -17
  118. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +27 -24
  119. package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +34 -25
  120. package/Sources/Private/Model/Animation.swift +160 -0
  121. package/Sources/Private/Model/Assets/Asset.swift +43 -0
  122. package/{lottie-swift/src → Sources}/Private/Model/Assets/AssetLibrary.swift +40 -13
  123. package/Sources/Private/Model/Assets/ImageAsset.swift +112 -0
  124. package/{lottie-swift/src → Sources}/Private/Model/Assets/PrecompAsset.swift +20 -10
  125. package/Sources/Private/Model/DictionaryInitializable.swift +67 -0
  126. package/Sources/Private/Model/Extensions/Bundle.swift +34 -0
  127. package/{lottie-swift/src → Sources}/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +8 -4
  128. package/Sources/Private/Model/Keyframes/KeyframeData.swift +113 -0
  129. package/Sources/Private/Model/Keyframes/KeyframeGroup.swift +197 -0
  130. package/{lottie-swift/src → Sources}/Private/Model/Layers/ImageLayerModel.swift +21 -11
  131. package/Sources/Private/Model/Layers/LayerModel.swift +228 -0
  132. package/{lottie-swift/src → Sources}/Private/Model/Layers/PreCompLayerModel.swift +39 -22
  133. package/{lottie-swift/src → Sources}/Private/Model/Layers/ShapeLayerModel.swift +23 -12
  134. package/{lottie-swift/src → Sources}/Private/Model/Layers/SolidLayerModel.swift +31 -19
  135. package/{lottie-swift/src → Sources}/Private/Model/Layers/TextLayerModel.swift +33 -19
  136. package/Sources/Private/Model/Objects/DashPattern.swift +44 -0
  137. package/Sources/Private/Model/Objects/Marker.swift +33 -0
  138. package/Sources/Private/Model/Objects/Mask.swift +80 -0
  139. package/Sources/Private/Model/Objects/Transform.swift +179 -0
  140. package/Sources/Private/Model/ShapeItems/Ellipse.swift +75 -0
  141. package/Sources/Private/Model/ShapeItems/Fill.swift +74 -0
  142. package/Sources/Private/Model/ShapeItems/GradientFill.swift +124 -0
  143. package/Sources/Private/Model/ShapeItems/GradientStroke.swift +186 -0
  144. package/Sources/Private/Model/ShapeItems/Group.swift +48 -0
  145. package/{lottie-swift/src → Sources}/Private/Model/ShapeItems/Merge.swift +29 -11
  146. package/Sources/Private/Model/ShapeItems/Rectangle.swift +73 -0
  147. package/Sources/Private/Model/ShapeItems/Repeater.swift +136 -0
  148. package/Sources/Private/Model/ShapeItems/Shape.swift +56 -0
  149. package/Sources/Private/Model/ShapeItems/ShapeItem.swift +163 -0
  150. package/Sources/Private/Model/ShapeItems/ShapeTransform.swift +136 -0
  151. package/Sources/Private/Model/ShapeItems/Star.swift +132 -0
  152. package/Sources/Private/Model/ShapeItems/Stroke.swift +102 -0
  153. package/Sources/Private/Model/ShapeItems/Trim.swift +78 -0
  154. package/Sources/Private/Model/Text/Font.swift +61 -0
  155. package/{lottie-swift/src → Sources}/Private/Model/Text/Glyph.swift +63 -39
  156. package/Sources/Private/Model/Text/TextAnimator.swift +164 -0
  157. package/Sources/Private/Model/Text/TextDocument.swift +123 -0
  158. package/Sources/Private/RootAnimationLayer.swift +51 -0
  159. package/{lottie-swift/src → Sources}/Private/Utility/Debugging/AnimatorNodeDebugging.swift +7 -7
  160. package/{lottie-swift/src → Sources}/Private/Utility/Debugging/LayerDebugging.swift +72 -48
  161. package/Sources/Private/Utility/Debugging/TestHelpers.swift +10 -0
  162. package/{lottie-swift/src → Sources}/Private/Utility/Extensions/AnimationKeypathExtension.swift +69 -59
  163. package/Sources/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
  164. package/Sources/Private/Utility/Extensions/CGColor+RGB.swift +22 -0
  165. package/{lottie-swift/src → Sources}/Private/Utility/Extensions/CGFloatExtensions.swift +70 -67
  166. package/Sources/Private/Utility/Extensions/DataExtension.swift +27 -0
  167. package/Sources/Private/Utility/Extensions/MathKit.swift +450 -0
  168. package/Sources/Private/Utility/Extensions/StringExtensions.swift +38 -0
  169. package/{lottie-swift/src → Sources}/Private/Utility/Helpers/AnimationContext.swift +42 -16
  170. package/Sources/Private/Utility/Interpolatable/InterpolatableExtensions.swift +134 -0
  171. package/{lottie-swift/src → Sources}/Private/Utility/Interpolatable/KeyframeExtensions.swift +13 -10
  172. package/Sources/Private/Utility/Interpolatable/KeyframeGroup+Extensions.swift +59 -0
  173. package/{lottie-swift/src → Sources}/Private/Utility/Primitives/BezierPath.swift +229 -143
  174. package/Sources/Private/Utility/Primitives/CGPointExtension.swift +35 -0
  175. package/{lottie-swift/src → Sources}/Private/Utility/Primitives/ColorExtension.swift +46 -14
  176. package/{lottie-swift/src → Sources}/Private/Utility/Primitives/CompoundBezierPath.swift +58 -49
  177. package/Sources/Private/Utility/Primitives/CurveVertex.swift +184 -0
  178. package/Sources/Private/Utility/Primitives/PathElement.swift +75 -0
  179. package/Sources/Private/Utility/Primitives/UnitBezier.swift +115 -0
  180. package/Sources/Private/Utility/Primitives/VectorsExtensions.swift +341 -0
  181. package/Sources/Public/Animation/AnimationPublic.swift +266 -0
  182. package/Sources/Public/Animation/AnimationView.swift +1335 -0
  183. package/Sources/Public/Animation/AnimationViewInitializers.swift +109 -0
  184. package/Sources/Public/AnimationCache/AnimationCacheProvider.swift +22 -0
  185. package/{lottie-swift/src → Sources}/Public/AnimationCache/LRUAnimationCache.swift +22 -18
  186. package/Sources/Public/DynamicProperties/AnimationKeypath.swift +49 -0
  187. package/Sources/Public/DynamicProperties/AnyValueProvider.swift +132 -0
  188. package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +54 -36
  189. package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +40 -36
  190. package/Sources/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +123 -0
  191. package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +40 -35
  192. package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +40 -35
  193. package/{lottie-swift/src → Sources}/Public/FontProvider/AnimationFontProvider.swift +15 -8
  194. package/Sources/Public/ImageProvider/AnimationImageProvider.swift +21 -0
  195. package/Sources/Public/Keyframes/Interpolatable.swift +253 -0
  196. package/Sources/Public/Keyframes/Keyframe.swift +92 -0
  197. package/Sources/Public/Logging/LottieLogger.swift +137 -0
  198. package/Sources/Public/LottieConfiguration.swift +143 -0
  199. package/{lottie-swift/src → Sources}/Public/Primitives/AnimationTime.swift +1 -1
  200. package/{lottie-swift/src → Sources}/Public/Primitives/Color.swift +10 -6
  201. package/{lottie-swift/src → Sources}/Public/Primitives/Vectors.swift +13 -12
  202. package/Sources/Public/TextProvider/AnimationTextProvider.swift +53 -0
  203. package/{lottie-swift/src → Sources}/Public/iOS/AnimatedButton.swift +42 -26
  204. package/{lottie-swift/src → Sources}/Public/iOS/AnimatedControl.swift +100 -91
  205. package/{lottie-swift/src → Sources}/Public/iOS/AnimatedSwitch.swift +128 -94
  206. package/{lottie-swift/src → Sources}/Public/iOS/AnimationSubview.swift +3 -3
  207. package/Sources/Public/iOS/AnimationViewBase.swift +78 -0
  208. package/{lottie-swift/src → Sources}/Public/iOS/BundleImageProvider.swift +36 -34
  209. package/{lottie-swift/src → Sources}/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +4 -0
  210. package/{lottie-swift/src → Sources}/Public/iOS/Compatibility/CompatibleAnimationView.swift +38 -29
  211. package/{lottie-swift/src → Sources}/Public/iOS/FilepathImageProvider.swift +24 -21
  212. package/{lottie-swift/src → Sources}/Public/iOS/UIColorExtension.swift +4 -4
  213. package/{lottie-swift/src/Public/MacOS/AnimationSubview.swift → Sources/Public/macOS/AnimationSubview.macOS.swift} +4 -5
  214. package/{lottie-swift/src/Public/MacOS/LottieView.swift → Sources/Public/macOS/AnimationViewBase.macOS.swift} +58 -50
  215. package/{lottie-swift/src/Public/MacOS/BundleImageProvider.swift → Sources/Public/macOS/BundleImageProvider.macOS.swift} +31 -32
  216. package/Sources/Public/macOS/FilepathImageProvider.macOS.swift +67 -0
  217. package/Tests/AnimationKeypathTests.swift +94 -0
  218. package/Tests/AutomaticEngineTests.swift +57 -0
  219. package/Tests/BundleTests.swift +25 -0
  220. package/Tests/DataURLTests.swift +64 -0
  221. package/Tests/ParsingTests.swift +43 -0
  222. package/Tests/PerformanceTests.swift +215 -0
  223. package/Tests/SnapshotConfiguration.swift +153 -0
  224. package/Tests/SnapshotTests.swift +265 -0
  225. package/Tests/Utils/Bundle+Module.swift +30 -0
  226. package/Tests/Utils/HardcodedFontProvider.swift +19 -0
  227. package/Tests/Utils/HardcodedImageProvider.swift +23 -0
  228. package/Tests/Utils/Snapshotting+presentationLayer.swift +47 -0
  229. package/Tests/ValueProvidersTests.swift +27 -0
  230. package/lottie-ios.podspec +11 -12
  231. package/package.json +1 -1
  232. package/script/test-carthage/Cartfile +1 -0
  233. package/script/test-carthage/Cartfile.resolved +1 -0
  234. package/script/test-carthage/CarthageTest/AppDelegate.swift +26 -0
  235. package/script/test-carthage/CarthageTest/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  236. package/script/test-carthage/CarthageTest/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
  237. package/script/test-carthage/CarthageTest/Assets.xcassets/Contents.json +6 -0
  238. package/script/test-carthage/CarthageTest/Base.lproj/LaunchScreen.storyboard +25 -0
  239. package/script/test-carthage/CarthageTest/Base.lproj/Main.storyboard +24 -0
  240. package/script/test-carthage/CarthageTest/Info.plist +66 -0
  241. package/script/test-carthage/CarthageTest/SceneDelegate.swift +10 -0
  242. package/script/test-carthage/CarthageTest/ViewController.swift +15 -0
  243. package/script/test-carthage/CarthageTest-macOS/AppDelegate.swift +7 -0
  244. package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  245. package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
  246. package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/Contents.json +6 -0
  247. package/script/test-carthage/CarthageTest-macOS/Base.lproj/Main.storyboard +717 -0
  248. package/script/test-carthage/CarthageTest-macOS/CarthageTest_macOS.entitlements +10 -0
  249. package/script/test-carthage/CarthageTest-macOS/ViewController.swift +15 -0
  250. package/script/test-carthage/CarthageTest.xcodeproj/project.pbxproj +532 -0
  251. package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  252. package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  253. package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  254. package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  255. package/script/test-carthage/CarthageTest.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  256. package/script/test-carthage/CarthageTest.xcodeproj/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  257. package/script/test-carthage/Mintfile +1 -0
  258. package/script/test-spm/LottieSPM.xcworkspace/contents.xcworkspacedata +7 -0
  259. package/script/test-spm/LottieSPM.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  260. package/script/test-spm/Mintfile +1 -0
  261. package/.swiftpm/xcode/package.xcworkspace/xcuserdata/brandonwithrow.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  262. package/Lottie/Info.plist +0 -22
  263. package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/brandonwithrow.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  264. package/Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad/xcschemes/LottieLibraryMacOS.xcscheme +0 -80
  265. package/Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad/xcschemes/xcschememanagement.plist +0 -57
  266. package/lottie-swift/Assets/.gitkeep +0 -0
  267. package/lottie-swift/src/Private/LayerContainers/Utility/LayerFontProvider.swift +0 -37
  268. package/lottie-swift/src/Private/LayerContainers/Utility/LayerTextProvider.swift +0 -36
  269. package/lottie-swift/src/Private/Model/Animation.swift +0 -107
  270. package/lottie-swift/src/Private/Model/Assets/Asset.swift +0 -27
  271. package/lottie-swift/src/Private/Model/Assets/ImageAsset.swift +0 -48
  272. package/lottie-swift/src/Private/Model/Keyframes/Keyframe.swift +0 -128
  273. package/lottie-swift/src/Private/Model/Keyframes/KeyframeGroup.swift +0 -108
  274. package/lottie-swift/src/Private/Model/Layers/LayerModel.swift +0 -150
  275. package/lottie-swift/src/Private/Model/Objects/DashPattern.swift +0 -24
  276. package/lottie-swift/src/Private/Model/Objects/Marker.swift +0 -23
  277. package/lottie-swift/src/Private/Model/Objects/Mask.swift +0 -48
  278. package/lottie-swift/src/Private/Model/Objects/Transform.swift +0 -105
  279. package/lottie-swift/src/Private/Model/ShapeItems/Ellipse.swift +0 -50
  280. package/lottie-swift/src/Private/Model/ShapeItems/FillI.swift +0 -49
  281. package/lottie-swift/src/Private/Model/ShapeItems/GradientFill.swift +0 -86
  282. package/lottie-swift/src/Private/Model/ShapeItems/GradientStroke.swift +0 -125
  283. package/lottie-swift/src/Private/Model/ShapeItems/Group.swift +0 -32
  284. package/lottie-swift/src/Private/Model/ShapeItems/Rectangle.swift +0 -50
  285. package/lottie-swift/src/Private/Model/ShapeItems/Repeater.swift +0 -80
  286. package/lottie-swift/src/Private/Model/ShapeItems/Shape.swift +0 -37
  287. package/lottie-swift/src/Private/Model/ShapeItems/ShapeItem.swift +0 -95
  288. package/lottie-swift/src/Private/Model/ShapeItems/ShapeTransform.swift +0 -68
  289. package/lottie-swift/src/Private/Model/ShapeItems/Star.swift +0 -86
  290. package/lottie-swift/src/Private/Model/ShapeItems/Stroke.swift +0 -67
  291. package/lottie-swift/src/Private/Model/ShapeItems/Trim.swift +0 -53
  292. package/lottie-swift/src/Private/Model/Text/Font.swift +0 -35
  293. package/lottie-swift/src/Private/Model/Text/TextAnimator.swift +0 -99
  294. package/lottie-swift/src/Private/Model/Text/TextDocument.swift +0 -70
  295. package/lottie-swift/src/Private/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +0 -109
  296. package/lottie-swift/src/Private/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +0 -132
  297. package/lottie-swift/src/Private/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +0 -141
  298. package/lottie-swift/src/Private/Utility/Extensions/MathKit.swift +0 -539
  299. package/lottie-swift/src/Private/Utility/Extensions/StringExtensions.swift +0 -32
  300. package/lottie-swift/src/Private/Utility/Interpolatable/Interpolatable.swift +0 -18
  301. package/lottie-swift/src/Private/Utility/Interpolatable/InterpolatableExtensions.swift +0 -170
  302. package/lottie-swift/src/Private/Utility/Primitives/CurveVertex.swift +0 -177
  303. package/lottie-swift/src/Private/Utility/Primitives/PathElement.swift +0 -68
  304. package/lottie-swift/src/Private/Utility/Primitives/VectorsExtensions.swift +0 -218
  305. package/lottie-swift/src/Public/Animation/AnimationPublic.swift +0 -196
  306. package/lottie-swift/src/Public/Animation/AnimationView.swift +0 -1006
  307. package/lottie-swift/src/Public/Animation/AnimationViewInitializers.swift +0 -83
  308. package/lottie-swift/src/Public/AnimationCache/AnimationCacheProvider.swift +0 -24
  309. package/lottie-swift/src/Public/DynamicProperties/AnimationKeypath.swift +0 -46
  310. package/lottie-swift/src/Public/DynamicProperties/AnyValueProvider.swift +0 -29
  311. package/lottie-swift/src/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +0 -114
  312. package/lottie-swift/src/Public/ImageProvider/AnimationImageProvider.swift +0 -23
  313. package/lottie-swift/src/Public/MacOS/FilepathImageProvider.swift +0 -67
  314. package/lottie-swift/src/Public/TextProvider/AnimationTextProvider.swift +0 -39
  315. package/lottie-swift/src/Public/iOS/LottieView.swift +0 -62
  316. package/lottie-swift-testing.podspec +0 -32
@@ -5,51 +5,47 @@
5
5
  // Created by Brandon Withrow on 1/25/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import CoreGraphics
9
+ import Foundation
10
10
  #if os(iOS) || os(tvOS) || os(watchOS) || targetEnvironment(macCatalyst)
11
11
  import UIKit
12
12
 
13
- /**
14
- An `AnimationImageProvider` that provides images by name from a specific bundle.
15
- The BundleImageProvider is initialized with a bundle and an optional searchPath.
16
- */
13
+ /// An `AnimationImageProvider` that provides images by name from a specific bundle.
14
+ /// The BundleImageProvider is initialized with a bundle and an optional searchPath.
17
15
  public class BundleImageProvider: AnimationImageProvider {
18
-
19
- let bundle: Bundle
20
- let searchPath: String?
21
-
22
- /**
23
- Initializes an image provider with a bundle and an optional subpath.
24
-
25
- Provides images for an animation from a bundle. Additionally the provider can
26
- search a specific subpath for the images.
27
-
28
- - Parameter bundle: The bundle containing images for the provider.
29
- - Parameter searchPath: The subpath is a path within the bundle to search for image assets.
30
-
31
- */
16
+
17
+ // MARK: Lifecycle
18
+
19
+ /// Initializes an image provider with a bundle and an optional subpath.
20
+ ///
21
+ /// Provides images for an animation from a bundle. Additionally the provider can
22
+ /// search a specific subpath for the images.
23
+ ///
24
+ /// - Parameter bundle: The bundle containing images for the provider.
25
+ /// - Parameter searchPath: The subpath is a path within the bundle to search for image assets.
26
+ ///
32
27
  public init(bundle: Bundle, searchPath: String?) {
33
28
  self.bundle = bundle
34
29
  self.searchPath = searchPath
35
30
  }
36
-
31
+
32
+ // MARK: Public
33
+
37
34
  public func imageForAsset(asset: ImageAsset) -> CGImage? {
38
-
39
- if asset.name.hasPrefix("data:"),
40
- let url = URL(string: asset.name),
41
- let data = try? Data(contentsOf: url),
42
- let image = UIImage(data: data) {
35
+ if
36
+ let data = Data(imageAsset: asset),
37
+ let image = UIImage(data: data)
38
+ {
43
39
  return image.cgImage
44
40
  }
45
-
41
+
46
42
  let imagePath: String?
47
43
  /// Try to find the image in the bundle.
48
44
  if let searchPath = searchPath {
49
45
  /// Search in the provided search path for the image
50
46
  var directoryPath = URL(fileURLWithPath: searchPath)
51
47
  directoryPath.appendPathComponent(asset.directory)
52
-
48
+
53
49
  if let path = bundle.path(forResource: asset.name, ofType: nil, inDirectory: directoryPath.path) {
54
50
  /// First search for the image in the asset provided sub directory.
55
51
  imagePath = path
@@ -68,20 +64,26 @@ public class BundleImageProvider: AnimationImageProvider {
68
64
  imagePath = bundle.path(forResource: asset.name, ofType: nil)
69
65
  }
70
66
  }
71
-
67
+
72
68
  if imagePath == nil {
73
- guard let image = UIImage(named: asset.name, in: bundle, compatibleWith: nil) else {
74
- return nil
75
- }
76
- return image.cgImage
69
+ guard let image = UIImage(named: asset.name, in: bundle, compatibleWith: nil) else {
70
+ LottieLogger.shared.assertionFailure("Could not find image \"\(asset.name)\" in bundle")
71
+ return nil
72
+ }
73
+ return image.cgImage
77
74
  }
78
-
75
+
79
76
  guard let foundPath = imagePath, let image = UIImage(contentsOfFile: foundPath) else {
80
77
  /// No image found.
78
+ LottieLogger.shared.assertionFailure("Could not find image \"\(asset.name)\" in bundle")
81
79
  return nil
82
80
  }
83
81
  return image.cgImage
84
82
  }
85
-
83
+
84
+ // MARK: Internal
85
+
86
+ let bundle: Bundle
87
+ let searchPath: String?
86
88
  }
87
89
  #endif
@@ -12,6 +12,8 @@ import Foundation
12
12
  @objc
13
13
  public final class CompatibleAnimationKeypath: NSObject {
14
14
 
15
+ // MARK: Lifecycle
16
+
15
17
  /// Creates a keypath from a dot separated string. The string is separated by "."
16
18
  @objc
17
19
  public init(keypath: String) {
@@ -24,6 +26,8 @@ public final class CompatibleAnimationKeypath: NSObject {
24
26
  animationKeypath = AnimationKeypath(keys: keys)
25
27
  }
26
28
 
29
+ // MARK: Public
30
+
27
31
  public let animationKeypath: AnimationKeypath
28
32
  }
29
33
  #endif
@@ -14,10 +14,7 @@ import UIKit
14
14
  @objc
15
15
  public final class CompatibleAnimation: NSObject {
16
16
 
17
- @objc
18
- static func named(_ name: String) -> CompatibleAnimation {
19
- return CompatibleAnimation(name: name)
20
- }
17
+ // MARK: Lifecycle
21
18
 
22
19
  @objc
23
20
  public init(name: String, bundle: Bundle = Bundle.main) {
@@ -26,8 +23,15 @@ public final class CompatibleAnimation: NSObject {
26
23
  super.init()
27
24
  }
28
25
 
26
+ // MARK: Internal
27
+
29
28
  internal var animation: Animation? {
30
- return Animation.named(name, bundle: bundle)
29
+ Animation.named(name, bundle: bundle)
30
+ }
31
+
32
+ @objc
33
+ static func named(_ name: String) -> CompatibleAnimation {
34
+ CompatibleAnimation(name: name)
31
35
  }
32
36
 
33
37
  // MARK: Private
@@ -40,8 +44,10 @@ public final class CompatibleAnimation: NSObject {
40
44
  @objc
41
45
  public final class CompatibleAnimationView: UIView {
42
46
 
47
+ // MARK: Lifecycle
48
+
43
49
  @objc
44
- init(compatibleAnimation: CompatibleAnimation) {
50
+ public init(compatibleAnimation: CompatibleAnimation) {
45
51
  animationView = AnimationView(animation: compatibleAnimation.animation)
46
52
  self.compatibleAnimation = compatibleAnimation
47
53
  super.init(frame: .zero)
@@ -55,7 +61,7 @@ public final class CompatibleAnimationView: UIView {
55
61
  commonInit()
56
62
  }
57
63
 
58
- required init?(coder aDecoder: NSCoder) {
64
+ required init?(coder _: NSCoder) {
59
65
  fatalError("init(coder:) has not been implemented")
60
66
  }
61
67
 
@@ -78,58 +84,58 @@ public final class CompatibleAnimationView: UIView {
78
84
  @objc
79
85
  public override var contentMode: UIView.ContentMode {
80
86
  set { animationView.contentMode = newValue }
81
- get { return animationView.contentMode }
87
+ get { animationView.contentMode }
82
88
  }
83
89
 
84
90
  @objc
85
91
  public var shouldRasterizeWhenIdle: Bool {
86
92
  set { animationView.shouldRasterizeWhenIdle = newValue }
87
- get { return animationView.shouldRasterizeWhenIdle }
93
+ get { animationView.shouldRasterizeWhenIdle }
88
94
  }
89
95
 
90
96
  @objc
91
97
  public var currentProgress: CGFloat {
92
98
  set { animationView.currentProgress = newValue }
93
- get { return animationView.currentProgress }
99
+ get { animationView.currentProgress }
94
100
  }
95
101
 
96
102
  @objc
97
103
  public var currentTime: TimeInterval {
98
104
  set { animationView.currentTime = newValue }
99
- get { return animationView.currentTime }
105
+ get { animationView.currentTime }
100
106
  }
101
107
 
102
108
  @objc
103
109
  public var currentFrame: CGFloat {
104
110
  set { animationView.currentFrame = newValue }
105
- get { return animationView.currentFrame }
111
+ get { animationView.currentFrame }
106
112
  }
107
113
 
108
114
  @objc
109
115
  public var realtimeAnimationFrame: CGFloat {
110
- return animationView.realtimeAnimationFrame
116
+ animationView.realtimeAnimationFrame
111
117
  }
112
118
 
113
119
  @objc
114
120
  public var realtimeAnimationProgress: CGFloat {
115
- return animationView.realtimeAnimationProgress
121
+ animationView.realtimeAnimationProgress
116
122
  }
117
123
 
118
124
  @objc
119
125
  public var animationSpeed: CGFloat {
120
126
  set { animationView.animationSpeed = newValue }
121
- get { return animationView.animationSpeed }
127
+ get { animationView.animationSpeed }
122
128
  }
123
129
 
124
130
  @objc
125
131
  public var respectAnimationFrameRate: Bool {
126
132
  set { animationView.respectAnimationFrameRate = newValue }
127
- get { return animationView.respectAnimationFrameRate }
133
+ get { animationView.respectAnimationFrameRate }
128
134
  }
129
135
 
130
136
  @objc
131
137
  public var isAnimationPlaying: Bool {
132
- return animationView.isAnimationPlaying
138
+ animationView.isAnimationPlaying
133
139
  }
134
140
 
135
141
  @objc
@@ -203,9 +209,10 @@ public final class CompatibleAnimationView: UIView {
203
209
  @objc
204
210
  public func getValue(
205
211
  for keypath: CompatibleAnimationKeypath,
206
- atFrame: CGFloat) -> Any?
212
+ atFrame: CGFloat)
213
+ -> Any?
207
214
  {
208
- return animationView.getValue(
215
+ animationView.getValue(
209
216
  for: keypath.animationKeypath,
210
217
  atFrame: atFrame)
211
218
  }
@@ -216,8 +223,7 @@ public final class CompatibleAnimationView: UIView {
216
223
  }
217
224
 
218
225
  @objc
219
- public func setColorValue(_ color: UIColor, forKeypath keypath: CompatibleAnimationKeypath)
220
- {
226
+ public func setColorValue(_ color: UIColor, forKeypath keypath: CompatibleAnimationKeypath) {
221
227
  var red: CGFloat = 0
222
228
  var green: CGFloat = 0
223
229
  var blue: CGFloat = 0
@@ -241,14 +247,17 @@ public final class CompatibleAnimationView: UIView {
241
247
  }
242
248
 
243
249
  @objc
244
- public func getColorValue(for keypath: CompatibleAnimationKeypath, atFrame: CGFloat) -> UIColor?
245
- {
250
+ public func getColorValue(for keypath: CompatibleAnimationKeypath, atFrame: CGFloat) -> UIColor? {
246
251
  let value = animationView.getValue(for: keypath.animationKeypath, atFrame: atFrame)
247
252
  guard let colorValue = value as? Color else {
248
- return nil;
253
+ return nil;
249
254
  }
250
255
 
251
- return UIColor(red: CGFloat(colorValue.r), green: CGFloat(colorValue.g), blue: CGFloat(colorValue.b), alpha: CGFloat(colorValue.a))
256
+ return UIColor(
257
+ red: CGFloat(colorValue.r),
258
+ green: CGFloat(colorValue.g),
259
+ blue: CGFloat(colorValue.b),
260
+ alpha: CGFloat(colorValue.a))
252
261
  }
253
262
 
254
263
  @objc
@@ -267,7 +276,7 @@ public final class CompatibleAnimationView: UIView {
267
276
  toLayerAt keypath: CompatibleAnimationKeypath?)
268
277
  -> CGRect
269
278
  {
270
- return animationView.convert(
279
+ animationView.convert(
271
280
  rect,
272
281
  toLayerAt: keypath?.animationKeypath) ?? .zero
273
282
  }
@@ -278,19 +287,19 @@ public final class CompatibleAnimationView: UIView {
278
287
  toLayerAt keypath: CompatibleAnimationKeypath?)
279
288
  -> CGPoint
280
289
  {
281
- return animationView.convert(
290
+ animationView.convert(
282
291
  point,
283
292
  toLayerAt: keypath?.animationKeypath) ?? .zero
284
293
  }
285
294
 
286
295
  @objc
287
296
  public func progressTime(forMarker named: String) -> CGFloat {
288
- return animationView.progressTime(forMarker: named) ?? 0
297
+ animationView.progressTime(forMarker: named) ?? 0
289
298
  }
290
299
 
291
300
  @objc
292
301
  public func frameTime(forMarker named: String) -> CGFloat {
293
- return animationView.frameTime(forMarker: named) ?? 0
302
+ animationView.frameTime(forMarker: named) ?? 0
294
303
  }
295
304
 
296
305
  // MARK: Private
@@ -9,48 +9,51 @@ import Foundation
9
9
  #if os(iOS) || os(tvOS) || os(watchOS) || targetEnvironment(macCatalyst)
10
10
  import UIKit
11
11
 
12
- /**
13
- Provides an image for a lottie animation from a provided Bundle.
14
- */
12
+ /// Provides an image for a lottie animation from a provided Bundle.
15
13
  public class FilepathImageProvider: AnimationImageProvider {
16
-
17
- let filepath: URL
18
-
19
- /**
20
- Initializes an image provider with a specific filepath.
21
-
22
- - Parameter filepath: The absolute filepath containing the images.
23
-
24
- */
14
+
15
+ // MARK: Lifecycle
16
+
17
+ /// Initializes an image provider with a specific filepath.
18
+ ///
19
+ /// - Parameter filepath: The absolute filepath containing the images.
20
+ ///
25
21
  public init(filepath: String) {
26
22
  self.filepath = URL(fileURLWithPath: filepath)
27
23
  }
28
-
24
+
29
25
  public init(filepath: URL) {
30
26
  self.filepath = filepath
31
27
  }
32
-
33
- public func imageForAsset(asset: ImageAsset) -> CGImage? {
34
28
 
35
- if asset.name.hasPrefix("data:"),
29
+ // MARK: Public
30
+
31
+ public func imageForAsset(asset: ImageAsset) -> CGImage? {
32
+ if
33
+ asset.name.hasPrefix("data:"),
36
34
  let url = URL(string: asset.name),
37
35
  let data = try? Data(contentsOf: url),
38
- let image = UIImage(data: data) {
36
+ let image = UIImage(data: data)
37
+ {
39
38
  return image.cgImage
40
39
  }
41
-
40
+
42
41
  let directPath = filepath.appendingPathComponent(asset.name).path
43
42
  if FileManager.default.fileExists(atPath: directPath) {
44
43
  return UIImage(contentsOfFile: directPath)?.cgImage
45
44
  }
46
-
45
+
47
46
  let pathWithDirectory = filepath.appendingPathComponent(asset.directory).appendingPathComponent(asset.name).path
48
47
  if FileManager.default.fileExists(atPath: pathWithDirectory) {
49
48
  return UIImage(contentsOfFile: pathWithDirectory)?.cgImage
50
49
  }
51
-
50
+
51
+ LottieLogger.shared.assertionFailure("Could not find image \"\(asset.name)\" in bundle")
52
52
  return nil
53
53
  }
54
-
54
+
55
+ // MARK: Internal
56
+
57
+ let filepath: URL
55
58
  }
56
59
  #endif
@@ -9,13 +9,13 @@ import Foundation
9
9
  #if os(iOS) || os(tvOS) || os(watchOS) || targetEnvironment(macCatalyst)
10
10
  import UIKit
11
11
 
12
- public extension UIColor {
13
-
14
- var lottieColorValue: Color {
12
+ extension UIColor {
13
+
14
+ public var lottieColorValue: Color {
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
17
  return Color(r: Double(r), g: Double(g), b: Double(b), a: Double(a))
18
18
  }
19
-
19
+
20
20
  }
21
21
  #endif
@@ -5,16 +5,15 @@
5
5
  // Created by Brandon Withrow on 2/5/19.
6
6
  //
7
7
 
8
- import Foundation
9
- #if os(OSX)
8
+ #if os(macOS)
10
9
  import AppKit
11
10
 
12
11
  /// A view that can be added to a keypath of an AnimationView
13
12
  public final class AnimationSubview: NSView {
14
-
13
+
15
14
  var viewLayer: CALayer? {
16
- return layer
15
+ layer
17
16
  }
18
-
17
+
19
18
  }
20
19
  #endif
@@ -1,12 +1,11 @@
1
1
  //
2
- // LottieView.swift
2
+ // AnimationViewBase.swift
3
3
  // lottie-swift-iOS
4
4
  //
5
5
  // Created by Brandon Withrow on 2/6/19.
6
6
  //
7
7
 
8
- import Foundation
9
- #if os(OSX)
8
+ #if os(macOS)
10
9
  import AppKit
11
10
 
12
11
  public enum LottieContentMode: Int {
@@ -25,70 +24,79 @@ public enum LottieContentMode: Int {
25
24
  case bottomRight
26
25
  }
27
26
 
28
- /// A wrapper around NSView for cross platform compatibility.
27
+ /// The base view for `AnimationView` on macOs.
28
+ ///
29
+ /// Enables the `AnimationView` implementation to be shared across platforms.
30
+ public class AnimationViewBase: NSView {
31
+
32
+ // MARK: Public
29
33
 
30
- public class LottieView: NSView {
31
-
32
- var screenScale: CGFloat {
33
- return NSApp.mainWindow?.backingScaleFactor ?? 1
34
- }
35
-
36
- var viewLayer: CALayer? {
37
- return layer
38
- }
39
-
40
- func layoutAnimation() {
41
-
42
- }
43
-
44
- func animationMovedToWindow() {
45
-
46
- }
47
-
48
- public override func viewDidMoveToWindow() {
49
- super.viewDidMoveToWindow()
50
- animationMovedToWindow()
51
- }
52
-
53
- func commonInit() {
54
- self.wantsLayer = true
55
- }
56
-
57
- func setNeedsLayout() {
58
- self.needsLayout = true
59
- }
60
-
61
- func layoutIfNeeded() {
62
-
63
- }
64
-
65
34
  public override var wantsUpdateLayer: Bool {
66
- return true
35
+ true
67
36
  }
68
-
37
+
69
38
  public override var isFlipped: Bool {
70
- return true
39
+ true
71
40
  }
72
-
41
+
73
42
  public var contentMode: LottieContentMode = .scaleAspectFit {
74
43
  didSet {
75
44
  setNeedsLayout()
76
45
  }
77
46
  }
78
-
47
+
48
+ public override func viewDidMoveToWindow() {
49
+ super.viewDidMoveToWindow()
50
+ animationMovedToWindow()
51
+ }
52
+
79
53
  public override func layout() {
80
54
  super.layout()
81
55
  CATransaction.begin()
82
56
  CATransaction.setDisableActions(true)
83
- self.layoutAnimation()
57
+ layoutAnimation()
84
58
  CATransaction.commit()
85
59
  }
86
-
87
- @objc func animationWillMoveToBackground() {
60
+
61
+ // MARK: Internal
62
+
63
+ var screenScale: CGFloat {
64
+ NSApp.mainWindow?.backingScaleFactor ?? 1
65
+ }
66
+
67
+ var viewLayer: CALayer? {
68
+ layer
69
+ }
70
+
71
+ func layoutAnimation() {
72
+ // Implemented by subclasses.
73
+ }
74
+
75
+ func animationMovedToWindow() {
76
+ // Implemented by subclasses.
77
+ }
78
+
79
+ func commonInit() {
80
+ wantsLayer = true
88
81
  }
89
-
90
- @objc func animationWillEnterForeground() {
82
+
83
+ func setNeedsLayout() {
84
+ needsLayout = true
91
85
  }
92
-
86
+
87
+ func layoutIfNeeded() {
88
+ // Implemented by subclasses.
89
+ }
90
+
91
+ @objc
92
+ func animationWillMoveToBackground() {
93
+ // Implemented by subclasses.
94
+ }
95
+
96
+ @objc
97
+ func animationWillEnterForeground() {
98
+ // Implemented by subclasses.
99
+ }
100
+
93
101
  }
94
102
  #endif
@@ -5,49 +5,44 @@
5
5
  // Created by Brandon Withrow on 1/25/19.
6
6
  //
7
7
 
8
- import Foundation
9
- #if os(OSX)
8
+ #if os(macOS)
10
9
  import AppKit
11
10
 
12
- /**
13
- Provides an image for a lottie animation from a provided Bundle.
14
- */
11
+ /// Provides an image for a lottie animation from a provided Bundle.
15
12
  public class BundleImageProvider: AnimationImageProvider {
16
-
17
- let bundle: Bundle
18
- let searchPath: String?
19
-
20
- /**
21
- Initializes an image provider with a bundle and an optional subpath.
22
-
23
- Provides images for an animation from a bundle. Additionally the provider can
24
- search a specific subpath for the images.
25
-
26
- - Parameter bundle: The bundle containing images for the provider.
27
- - Parameter searchPath: The subpath is a path within the bundle to search for image assets.
28
-
29
- */
13
+
14
+ // MARK: Lifecycle
15
+
16
+ /// Initializes an image provider with a bundle and an optional subpath.
17
+ ///
18
+ /// Provides images for an animation from a bundle. Additionally the provider can
19
+ /// search a specific subpath for the images.
20
+ ///
21
+ /// - Parameter bundle: The bundle containing images for the provider.
22
+ /// - Parameter searchPath: The subpath is a path within the bundle to search for image assets.
23
+ ///
30
24
  public init(bundle: Bundle, searchPath: String?) {
31
25
  self.bundle = bundle
32
26
  self.searchPath = searchPath
33
27
  }
34
-
28
+
29
+ // MARK: Public
30
+
35
31
  public func imageForAsset(asset: ImageAsset) -> CGImage? {
36
-
37
- if asset.name.hasPrefix("data:"),
38
- let url = URL(string: asset.name),
39
- let data = try? Data(contentsOf: url),
40
- let image = NSImage(data: data) {
41
- return image.CGImage
32
+ if
33
+ let data = Data(imageAsset: asset),
34
+ let image = NSImage(data: data)
35
+ {
36
+ return image.lottie_CGImage
42
37
  }
43
-
38
+
44
39
  let imagePath: String?
45
40
  /// Try to find the image in the bundle.
46
41
  if let searchPath = searchPath {
47
42
  /// Search in the provided search path for the image
48
43
  var directoryPath = URL(fileURLWithPath: searchPath)
49
44
  directoryPath.appendPathComponent(asset.directory)
50
-
45
+
51
46
  if let path = bundle.path(forResource: asset.name, ofType: nil, inDirectory: directoryPath.path) {
52
47
  /// First search for the image in the asset provided sub directory.
53
48
  imagePath = path
@@ -66,15 +61,19 @@ public class BundleImageProvider: AnimationImageProvider {
66
61
  imagePath = bundle.path(forResource: asset.name, ofType: nil)
67
62
  }
68
63
  }
69
-
70
-
64
+
71
65
  guard let foundPath = imagePath, let image = NSImage(contentsOfFile: foundPath) else {
72
66
  /// No image found.
67
+ LottieLogger.shared.assertionFailure("Could not find image \"\(asset.name)\" in bundle")
73
68
  return nil
74
69
  }
75
- return image.CGImage
70
+ return image.lottie_CGImage
76
71
  }
77
-
72
+
73
+ // MARK: Internal
74
+
75
+ let bundle: Bundle
76
+ let searchPath: String?
78
77
  }
79
78
 
80
79
  #endif