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.
- package/.github/actions/setup/action.yml +32 -0
- package/.github/issue_template.md +6 -23
- package/.github/workflows/main.yml +98 -0
- package/.spi.yml +6 -0
- package/.swift-version +1 -0
- package/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +7 -0
- package/.swiftpm/xcode/package.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/.swiftpm/xcode/xcuserdata/{brandonwithrow.xcuserdatad → cal.xcuserdatad}/xcschemes/xcschememanagement.plist +25 -15
- package/.swiftpm/xcode/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/Gemfile +4 -0
- package/Gemfile.lock +102 -0
- package/Lottie.xcodeproj/project.pbxproj +2003 -1972
- package/Lottie.xcodeproj/project.xcworkspace/contents.xcworkspacedata +1 -1
- package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_iOS.xcscheme → Lottie (iOS).xcscheme } +15 -18
- package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_macOS.xcscheme → Lottie (macOS).xcscheme } +7 -20
- package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_tvOS.xcscheme → Lottie (tvOS).xcscheme } +5 -18
- package/Lottie.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +37 -0
- package/Lottie.xcodeproj/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +24 -0
- package/Lottie.xcworkspace/contents.xcworkspacedata +10 -0
- package/Lottie.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/Lottie.xcworkspace/xcshareddata/swiftpm/Package.resolved +115 -0
- package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/{Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad → Lottie.xcworkspace/xcuserdata/cal.xcuserdatad}/xcdebugger/Breakpoints_v2.xcbkptlist +2 -2
- package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/xcdebugger/Expressions.xcexplist +153 -0
- package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +39 -0
- package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Expressions.xcexplist +25 -0
- package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +30 -0
- package/Package.resolved +88 -0
- package/Package.swift +10 -15
- package/README.md +40 -60
- package/Rakefile +121 -0
- package/Sources/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
- package/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +448 -0
- package/Sources/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +53 -0
- package/Sources/Private/CoreAnimation/Animations/CustomPathAnimation.swift +41 -0
- package/Sources/Private/CoreAnimation/Animations/EllipseAnimation.swift +28 -0
- package/Sources/Private/CoreAnimation/Animations/GradientAnimations.swift +210 -0
- package/Sources/Private/CoreAnimation/Animations/LayerProperty.swift +229 -0
- package/Sources/Private/CoreAnimation/Animations/OpacityAnimation.swift +52 -0
- package/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift +31 -0
- package/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
- package/Sources/Private/CoreAnimation/Animations/StarAnimation.swift +95 -0
- package/Sources/Private/CoreAnimation/Animations/StrokeAnimation.swift +70 -0
- package/Sources/Private/CoreAnimation/Animations/TransformAnimations.swift +205 -0
- package/Sources/Private/CoreAnimation/Animations/VisibilityAnimation.swift +37 -0
- package/Sources/Private/CoreAnimation/CompatibilityTracker.swift +130 -0
- package/Sources/Private/CoreAnimation/CoreAnimationLayer.swift +492 -0
- package/Sources/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
- package/Sources/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +37 -0
- package/Sources/Private/CoreAnimation/Extensions/Keyframes+combinedIfPossible.swift +73 -0
- package/Sources/Private/CoreAnimation/Layers/AnimationLayer.swift +83 -0
- package/Sources/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +33 -0
- package/Sources/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +87 -0
- package/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +131 -0
- package/Sources/Private/CoreAnimation/Layers/GradientRenderLayer.swift +94 -0
- package/Sources/Private/CoreAnimation/Layers/ImageLayer.swift +79 -0
- package/Sources/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +60 -0
- package/Sources/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +138 -0
- package/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift +140 -0
- package/Sources/Private/CoreAnimation/Layers/ShapeItemLayer.swift +302 -0
- package/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift +319 -0
- package/Sources/Private/CoreAnimation/Layers/SolidLayer.swift +47 -0
- package/Sources/Private/CoreAnimation/Layers/TextLayer.swift +91 -0
- package/Sources/Private/CoreAnimation/Layers/TransformLayer.swift +11 -0
- package/Sources/Private/CoreAnimation/ValueProviderStore.swift +139 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/CompositionLayer.swift +93 -85
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/ImageCompositionLayer.swift +24 -21
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/MaskContainerLayer.swift +75 -54
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/NullCompositionLayer.swift +5 -5
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/PreCompositionLayer.swift +61 -44
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/ShapeCompositionLayer.swift +22 -20
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/SolidCompositionLayer.swift +26 -17
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/TextCompositionLayer.swift +42 -36
- package/{lottie-swift/src/Private/LayerContainers/AnimationContainer.swift → Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift} +200 -140
- package/Sources/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +47 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/CompositionLayersInitializer.swift +33 -24
- package/{lottie-swift/src/Private/LayerContainers/Utility/TextLayer.swift → Sources/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift} +120 -106
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/InvertedMatteLayer.swift +25 -24
- package/Sources/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +41 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/LayerImageProvider.swift +20 -16
- package/Sources/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +40 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/LayerTransformNode.swift +82 -67
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Extensions/ItemsExtension.swift +4 -4
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/NodeProperty.swift +29 -21
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +16 -10
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +6 -6
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +5 -5
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +10 -8
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueContainer.swift +25 -21
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +23 -17
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/KeyframeInterpolator.swift +125 -108
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +22 -17
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +110 -79
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +22 -16
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +19 -15
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +22 -20
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +22 -23
- package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +242 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +30 -24
- package/{lottie-swift/src/Private/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift → Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift} +93 -66
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +23 -19
- package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +139 -0
- package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +170 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +95 -58
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +42 -29
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +108 -69
- package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +155 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +51 -37
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +54 -42
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +65 -57
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +84 -58
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +138 -119
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/AnimatorNode.swift +80 -79
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/PathNode.swift +5 -3
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/RenderNode.swift +22 -17
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +27 -24
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +34 -25
- package/Sources/Private/Model/Animation.swift +160 -0
- package/Sources/Private/Model/Assets/Asset.swift +43 -0
- package/{lottie-swift/src → Sources}/Private/Model/Assets/AssetLibrary.swift +40 -13
- package/Sources/Private/Model/Assets/ImageAsset.swift +112 -0
- package/{lottie-swift/src → Sources}/Private/Model/Assets/PrecompAsset.swift +20 -10
- package/Sources/Private/Model/DictionaryInitializable.swift +67 -0
- package/Sources/Private/Model/Extensions/Bundle.swift +34 -0
- package/{lottie-swift/src → Sources}/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +8 -4
- package/Sources/Private/Model/Keyframes/KeyframeData.swift +113 -0
- package/Sources/Private/Model/Keyframes/KeyframeGroup.swift +197 -0
- package/{lottie-swift/src → Sources}/Private/Model/Layers/ImageLayerModel.swift +21 -11
- package/Sources/Private/Model/Layers/LayerModel.swift +228 -0
- package/{lottie-swift/src → Sources}/Private/Model/Layers/PreCompLayerModel.swift +39 -22
- package/{lottie-swift/src → Sources}/Private/Model/Layers/ShapeLayerModel.swift +23 -12
- package/{lottie-swift/src → Sources}/Private/Model/Layers/SolidLayerModel.swift +31 -19
- package/{lottie-swift/src → Sources}/Private/Model/Layers/TextLayerModel.swift +33 -19
- package/Sources/Private/Model/Objects/DashPattern.swift +44 -0
- package/Sources/Private/Model/Objects/Marker.swift +33 -0
- package/Sources/Private/Model/Objects/Mask.swift +80 -0
- package/Sources/Private/Model/Objects/Transform.swift +179 -0
- package/Sources/Private/Model/ShapeItems/Ellipse.swift +75 -0
- package/Sources/Private/Model/ShapeItems/Fill.swift +74 -0
- package/Sources/Private/Model/ShapeItems/GradientFill.swift +124 -0
- package/Sources/Private/Model/ShapeItems/GradientStroke.swift +186 -0
- package/Sources/Private/Model/ShapeItems/Group.swift +48 -0
- package/{lottie-swift/src → Sources}/Private/Model/ShapeItems/Merge.swift +29 -11
- package/Sources/Private/Model/ShapeItems/Rectangle.swift +73 -0
- package/Sources/Private/Model/ShapeItems/Repeater.swift +136 -0
- package/Sources/Private/Model/ShapeItems/Shape.swift +56 -0
- package/Sources/Private/Model/ShapeItems/ShapeItem.swift +163 -0
- package/Sources/Private/Model/ShapeItems/ShapeTransform.swift +136 -0
- package/Sources/Private/Model/ShapeItems/Star.swift +132 -0
- package/Sources/Private/Model/ShapeItems/Stroke.swift +102 -0
- package/Sources/Private/Model/ShapeItems/Trim.swift +78 -0
- package/Sources/Private/Model/Text/Font.swift +61 -0
- package/{lottie-swift/src → Sources}/Private/Model/Text/Glyph.swift +63 -39
- package/Sources/Private/Model/Text/TextAnimator.swift +164 -0
- package/Sources/Private/Model/Text/TextDocument.swift +123 -0
- package/Sources/Private/RootAnimationLayer.swift +51 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Debugging/AnimatorNodeDebugging.swift +7 -7
- package/{lottie-swift/src → Sources}/Private/Utility/Debugging/LayerDebugging.swift +72 -48
- package/Sources/Private/Utility/Debugging/TestHelpers.swift +10 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Extensions/AnimationKeypathExtension.swift +69 -59
- package/Sources/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
- package/Sources/Private/Utility/Extensions/CGColor+RGB.swift +22 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Extensions/CGFloatExtensions.swift +70 -67
- package/Sources/Private/Utility/Extensions/DataExtension.swift +27 -0
- package/Sources/Private/Utility/Extensions/MathKit.swift +450 -0
- package/Sources/Private/Utility/Extensions/StringExtensions.swift +38 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Helpers/AnimationContext.swift +42 -16
- package/Sources/Private/Utility/Interpolatable/InterpolatableExtensions.swift +134 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Interpolatable/KeyframeExtensions.swift +13 -10
- package/Sources/Private/Utility/Interpolatable/KeyframeGroup+Extensions.swift +59 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Primitives/BezierPath.swift +229 -143
- package/Sources/Private/Utility/Primitives/CGPointExtension.swift +35 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Primitives/ColorExtension.swift +46 -14
- package/{lottie-swift/src → Sources}/Private/Utility/Primitives/CompoundBezierPath.swift +58 -49
- package/Sources/Private/Utility/Primitives/CurveVertex.swift +184 -0
- package/Sources/Private/Utility/Primitives/PathElement.swift +75 -0
- package/Sources/Private/Utility/Primitives/UnitBezier.swift +115 -0
- package/Sources/Private/Utility/Primitives/VectorsExtensions.swift +341 -0
- package/Sources/Public/Animation/AnimationPublic.swift +266 -0
- package/Sources/Public/Animation/AnimationView.swift +1335 -0
- package/Sources/Public/Animation/AnimationViewInitializers.swift +109 -0
- package/Sources/Public/AnimationCache/AnimationCacheProvider.swift +22 -0
- package/{lottie-swift/src → Sources}/Public/AnimationCache/LRUAnimationCache.swift +22 -18
- package/Sources/Public/DynamicProperties/AnimationKeypath.swift +49 -0
- package/Sources/Public/DynamicProperties/AnyValueProvider.swift +132 -0
- package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +54 -36
- package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +40 -36
- package/Sources/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +123 -0
- package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +40 -35
- package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +40 -35
- package/{lottie-swift/src → Sources}/Public/FontProvider/AnimationFontProvider.swift +15 -8
- package/Sources/Public/ImageProvider/AnimationImageProvider.swift +21 -0
- package/Sources/Public/Keyframes/Interpolatable.swift +253 -0
- package/Sources/Public/Keyframes/Keyframe.swift +92 -0
- package/Sources/Public/Logging/LottieLogger.swift +137 -0
- package/Sources/Public/LottieConfiguration.swift +143 -0
- package/{lottie-swift/src → Sources}/Public/Primitives/AnimationTime.swift +1 -1
- package/{lottie-swift/src → Sources}/Public/Primitives/Color.swift +10 -6
- package/{lottie-swift/src → Sources}/Public/Primitives/Vectors.swift +13 -12
- package/Sources/Public/TextProvider/AnimationTextProvider.swift +53 -0
- package/{lottie-swift/src → Sources}/Public/iOS/AnimatedButton.swift +42 -26
- package/{lottie-swift/src → Sources}/Public/iOS/AnimatedControl.swift +100 -91
- package/{lottie-swift/src → Sources}/Public/iOS/AnimatedSwitch.swift +128 -94
- package/{lottie-swift/src → Sources}/Public/iOS/AnimationSubview.swift +3 -3
- package/Sources/Public/iOS/AnimationViewBase.swift +78 -0
- package/{lottie-swift/src → Sources}/Public/iOS/BundleImageProvider.swift +36 -34
- package/{lottie-swift/src → Sources}/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +4 -0
- package/{lottie-swift/src → Sources}/Public/iOS/Compatibility/CompatibleAnimationView.swift +38 -29
- package/{lottie-swift/src → Sources}/Public/iOS/FilepathImageProvider.swift +24 -21
- package/{lottie-swift/src → Sources}/Public/iOS/UIColorExtension.swift +4 -4
- package/{lottie-swift/src/Public/MacOS/AnimationSubview.swift → Sources/Public/macOS/AnimationSubview.macOS.swift} +4 -5
- package/{lottie-swift/src/Public/MacOS/LottieView.swift → Sources/Public/macOS/AnimationViewBase.macOS.swift} +58 -50
- package/{lottie-swift/src/Public/MacOS/BundleImageProvider.swift → Sources/Public/macOS/BundleImageProvider.macOS.swift} +31 -32
- package/Sources/Public/macOS/FilepathImageProvider.macOS.swift +67 -0
- package/Tests/AnimationKeypathTests.swift +94 -0
- package/Tests/AutomaticEngineTests.swift +57 -0
- package/Tests/BundleTests.swift +25 -0
- package/Tests/DataURLTests.swift +64 -0
- package/Tests/ParsingTests.swift +43 -0
- package/Tests/PerformanceTests.swift +215 -0
- package/Tests/SnapshotConfiguration.swift +153 -0
- package/Tests/SnapshotTests.swift +265 -0
- package/Tests/Utils/Bundle+Module.swift +30 -0
- package/Tests/Utils/HardcodedFontProvider.swift +19 -0
- package/Tests/Utils/HardcodedImageProvider.swift +23 -0
- package/Tests/Utils/Snapshotting+presentationLayer.swift +47 -0
- package/Tests/ValueProvidersTests.swift +27 -0
- package/lottie-ios.podspec +11 -12
- package/package.json +1 -1
- package/script/test-carthage/Cartfile +1 -0
- package/script/test-carthage/Cartfile.resolved +1 -0
- package/script/test-carthage/CarthageTest/AppDelegate.swift +26 -0
- package/script/test-carthage/CarthageTest/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/script/test-carthage/CarthageTest/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/script/test-carthage/CarthageTest/Assets.xcassets/Contents.json +6 -0
- package/script/test-carthage/CarthageTest/Base.lproj/LaunchScreen.storyboard +25 -0
- package/script/test-carthage/CarthageTest/Base.lproj/Main.storyboard +24 -0
- package/script/test-carthage/CarthageTest/Info.plist +66 -0
- package/script/test-carthage/CarthageTest/SceneDelegate.swift +10 -0
- package/script/test-carthage/CarthageTest/ViewController.swift +15 -0
- package/script/test-carthage/CarthageTest-macOS/AppDelegate.swift +7 -0
- package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
- package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/Contents.json +6 -0
- package/script/test-carthage/CarthageTest-macOS/Base.lproj/Main.storyboard +717 -0
- package/script/test-carthage/CarthageTest-macOS/CarthageTest_macOS.entitlements +10 -0
- package/script/test-carthage/CarthageTest-macOS/ViewController.swift +15 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.pbxproj +532 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/script/test-carthage/CarthageTest.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/script/test-carthage/CarthageTest.xcodeproj/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/script/test-carthage/Mintfile +1 -0
- package/script/test-spm/LottieSPM.xcworkspace/contents.xcworkspacedata +7 -0
- package/script/test-spm/LottieSPM.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/script/test-spm/Mintfile +1 -0
- package/.swiftpm/xcode/package.xcworkspace/xcuserdata/brandonwithrow.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/Lottie/Info.plist +0 -22
- package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/brandonwithrow.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad/xcschemes/LottieLibraryMacOS.xcscheme +0 -80
- package/Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad/xcschemes/xcschememanagement.plist +0 -57
- package/lottie-swift/Assets/.gitkeep +0 -0
- package/lottie-swift/src/Private/LayerContainers/Utility/LayerFontProvider.swift +0 -37
- package/lottie-swift/src/Private/LayerContainers/Utility/LayerTextProvider.swift +0 -36
- package/lottie-swift/src/Private/Model/Animation.swift +0 -107
- package/lottie-swift/src/Private/Model/Assets/Asset.swift +0 -27
- package/lottie-swift/src/Private/Model/Assets/ImageAsset.swift +0 -48
- package/lottie-swift/src/Private/Model/Keyframes/Keyframe.swift +0 -128
- package/lottie-swift/src/Private/Model/Keyframes/KeyframeGroup.swift +0 -108
- package/lottie-swift/src/Private/Model/Layers/LayerModel.swift +0 -150
- package/lottie-swift/src/Private/Model/Objects/DashPattern.swift +0 -24
- package/lottie-swift/src/Private/Model/Objects/Marker.swift +0 -23
- package/lottie-swift/src/Private/Model/Objects/Mask.swift +0 -48
- package/lottie-swift/src/Private/Model/Objects/Transform.swift +0 -105
- package/lottie-swift/src/Private/Model/ShapeItems/Ellipse.swift +0 -50
- package/lottie-swift/src/Private/Model/ShapeItems/FillI.swift +0 -49
- package/lottie-swift/src/Private/Model/ShapeItems/GradientFill.swift +0 -86
- package/lottie-swift/src/Private/Model/ShapeItems/GradientStroke.swift +0 -125
- package/lottie-swift/src/Private/Model/ShapeItems/Group.swift +0 -32
- package/lottie-swift/src/Private/Model/ShapeItems/Rectangle.swift +0 -50
- package/lottie-swift/src/Private/Model/ShapeItems/Repeater.swift +0 -80
- package/lottie-swift/src/Private/Model/ShapeItems/Shape.swift +0 -37
- package/lottie-swift/src/Private/Model/ShapeItems/ShapeItem.swift +0 -95
- package/lottie-swift/src/Private/Model/ShapeItems/ShapeTransform.swift +0 -68
- package/lottie-swift/src/Private/Model/ShapeItems/Star.swift +0 -86
- package/lottie-swift/src/Private/Model/ShapeItems/Stroke.swift +0 -67
- package/lottie-swift/src/Private/Model/ShapeItems/Trim.swift +0 -53
- package/lottie-swift/src/Private/Model/Text/Font.swift +0 -35
- package/lottie-swift/src/Private/Model/Text/TextAnimator.swift +0 -99
- package/lottie-swift/src/Private/Model/Text/TextDocument.swift +0 -70
- package/lottie-swift/src/Private/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +0 -109
- package/lottie-swift/src/Private/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +0 -132
- package/lottie-swift/src/Private/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +0 -141
- package/lottie-swift/src/Private/Utility/Extensions/MathKit.swift +0 -539
- package/lottie-swift/src/Private/Utility/Extensions/StringExtensions.swift +0 -32
- package/lottie-swift/src/Private/Utility/Interpolatable/Interpolatable.swift +0 -18
- package/lottie-swift/src/Private/Utility/Interpolatable/InterpolatableExtensions.swift +0 -170
- package/lottie-swift/src/Private/Utility/Primitives/CurveVertex.swift +0 -177
- package/lottie-swift/src/Private/Utility/Primitives/PathElement.swift +0 -68
- package/lottie-swift/src/Private/Utility/Primitives/VectorsExtensions.swift +0 -218
- package/lottie-swift/src/Public/Animation/AnimationPublic.swift +0 -196
- package/lottie-swift/src/Public/Animation/AnimationView.swift +0 -1006
- package/lottie-swift/src/Public/Animation/AnimationViewInitializers.swift +0 -83
- package/lottie-swift/src/Public/AnimationCache/AnimationCacheProvider.swift +0 -24
- package/lottie-swift/src/Public/DynamicProperties/AnimationKeypath.swift +0 -46
- package/lottie-swift/src/Public/DynamicProperties/AnyValueProvider.swift +0 -29
- package/lottie-swift/src/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +0 -114
- package/lottie-swift/src/Public/ImageProvider/AnimationImageProvider.swift +0 -23
- package/lottie-swift/src/Public/MacOS/FilepathImageProvider.swift +0 -67
- package/lottie-swift/src/Public/TextProvider/AnimationTextProvider.swift +0 -39
- package/lottie-swift/src/Public/iOS/LottieView.swift +0 -62
- package/lottie-swift-testing.podspec +0 -32
package/Package.resolved
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": {
|
|
3
|
+
"pins": [
|
|
4
|
+
{
|
|
5
|
+
"package": "SourceKitten",
|
|
6
|
+
"repositoryURL": "https://github.com/jpsim/SourceKitten.git",
|
|
7
|
+
"state": {
|
|
8
|
+
"branch": null,
|
|
9
|
+
"revision": "817dfa6f2e09b0476f3a6c9dbc035991f02f0241",
|
|
10
|
+
"version": "0.32.0"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"package": "AirbnbSwift",
|
|
15
|
+
"repositoryURL": "https://github.com/airbnb/swift",
|
|
16
|
+
"state": {
|
|
17
|
+
"branch": "master",
|
|
18
|
+
"revision": "b844956fd69f05e550038469a5d498462176f87a",
|
|
19
|
+
"version": null
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"package": "swift-argument-parser",
|
|
24
|
+
"repositoryURL": "https://github.com/apple/swift-argument-parser.git",
|
|
25
|
+
"state": {
|
|
26
|
+
"branch": null,
|
|
27
|
+
"revision": "e394bf350e38cb100b6bc4172834770ede1b7232",
|
|
28
|
+
"version": "1.0.3"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"package": "SwiftSyntax",
|
|
33
|
+
"repositoryURL": "https://github.com/apple/swift-syntax.git",
|
|
34
|
+
"state": {
|
|
35
|
+
"branch": null,
|
|
36
|
+
"revision": "0b6c22b97f8e9320bca62e82cdbee601cf37ad3f",
|
|
37
|
+
"version": "0.50600.1"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"package": "SwiftFormat",
|
|
42
|
+
"repositoryURL": "https://github.com/calda/SwiftFormat",
|
|
43
|
+
"state": {
|
|
44
|
+
"branch": null,
|
|
45
|
+
"revision": "2a9ed335450d3b3f66b2699d65124b9089195f5d",
|
|
46
|
+
"version": "0.49.11-beta-2"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"package": "SwiftLint",
|
|
51
|
+
"repositoryURL": "https://github.com/realm/SwiftLint",
|
|
52
|
+
"state": {
|
|
53
|
+
"branch": "e497f1f",
|
|
54
|
+
"revision": "e497f1f5b161af96ba439049d21970c6204d06c6",
|
|
55
|
+
"version": null
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"package": "SwiftyTextTable",
|
|
60
|
+
"repositoryURL": "https://github.com/scottrhoyt/SwiftyTextTable.git",
|
|
61
|
+
"state": {
|
|
62
|
+
"branch": null,
|
|
63
|
+
"revision": "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3",
|
|
64
|
+
"version": "0.9.0"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"package": "SWXMLHash",
|
|
69
|
+
"repositoryURL": "https://github.com/drmohundro/SWXMLHash.git",
|
|
70
|
+
"state": {
|
|
71
|
+
"branch": null,
|
|
72
|
+
"revision": "6469881a3f30417c5bb02404ea4b69207f297592",
|
|
73
|
+
"version": "6.0.0"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"package": "Yams",
|
|
78
|
+
"repositoryURL": "https://github.com/jpsim/Yams.git",
|
|
79
|
+
"state": {
|
|
80
|
+
"branch": null,
|
|
81
|
+
"revision": "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
|
|
82
|
+
"version": "4.0.6"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"version": 1
|
|
88
|
+
}
|
package/Package.swift
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
// swift-tools-version:5.
|
|
1
|
+
// swift-tools-version:5.3
|
|
2
2
|
import PackageDescription
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
path: "lottie-swift/src",
|
|
15
|
-
exclude: ["Public/MacOS"]
|
|
16
|
-
)
|
|
17
|
-
]
|
|
18
|
-
)
|
|
5
|
+
name: "Lottie",
|
|
6
|
+
platforms: [.iOS("11.0"), .macOS("10.10"), .tvOS("11.0")],
|
|
7
|
+
products: [.library(name: "Lottie", targets: ["Lottie"])],
|
|
8
|
+
targets: [.target(name: "Lottie", path: "Sources")])
|
|
9
|
+
|
|
10
|
+
#if swift(>=5.6)
|
|
11
|
+
// Add the Airbnb Swift formatting plugin if possible
|
|
12
|
+
package.dependencies.append(.package(url: "https://github.com/airbnb/swift", .branch("master")))
|
|
13
|
+
#endif
|
package/README.md
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
# Lottie for iOS
|
|
2
|
-
[](https://cocoapods.org/pods/lottie-ios)[](https://cocoapods.org/pods/lottie-ios)[](https://cocoapods.org/pods/lottie-ios) [](https://github.com/Carthage/Carthage) [](https://swift.org/package-manager/) [](https://cocoapods.org/pods/lottie-ios) [](https://swiftpackageindex.com/airbnb/lottie-ios) [](https://swiftpackageindex.com/airbnb/lottie-ios)
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
**View documentation, FAQ, help, examples, and more at [airbnb.io/lottie](http://airbnb.io/lottie/)**
|
|
5
5
|
|
|
6
|
-
Lottie is a
|
|
6
|
+
Lottie is a cross-platform library for iOS, macOS, tvOS, [Android](https://github.com/airbnb/lottie), and [Web](https://github.com/airbnb/lottie-web) that natively renders vector-based animations and art in realtime with minimal code.
|
|
7
7
|
|
|
8
|
-
Lottie loads and renders animations and vectors exported in the bodymovin JSON format. Bodymovin JSON can be created and exported from After Effects with [bodymovin](https://github.com/bodymovin/bodymovin), Sketch with [Lottie Sketch Export](https://github.com/buba447/Lottie-Sketch-Export), and from [Haiku](https://www.haiku.ai).
|
|
8
|
+
Lottie loads and renders animations and vectors exported in the bodymovin JSON format. Bodymovin JSON can be created and exported from After Effects with [bodymovin](https://github.com/bodymovin/bodymovin), Sketch with [Lottie Sketch Export](https://github.com/buba447/Lottie-Sketch-Export), and from [Haiku](https://www.haiku.ai).
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Designers can create **and ship** beautiful animations without an engineer painstakingly recreating it by hand.
|
|
11
11
|
Since the animation is backed by JSON they are extremely small in size but can be large in complexity!
|
|
12
12
|
Animations can be played, resized, looped, sped up, slowed down, reversed, and even interactively scrubbed.
|
|
13
13
|
Lottie can play or loop just a portion of the animation as well, the possibilities are endless!
|
|
14
|
-
Animations can even be ***changed at runtime*** in various ways! Change the color, position or any keyframable value!
|
|
15
|
-
Lottie also supports native UIViewController Transitions out of the box!
|
|
14
|
+
Animations can even be ***changed at runtime*** in various ways! Change the color, position, or any keyframable value!
|
|
16
15
|
|
|
17
16
|
Here is just a small sampling of the power of Lottie
|
|
18
17
|
|
|
@@ -26,10 +25,18 @@ Here is just a small sampling of the power of Lottie
|
|
|
26
25
|

|
|
27
26
|
|
|
28
27
|
## Installing Lottie
|
|
29
|
-
Lottie supports [CocoaPods](https://cocoapods.org/) and [Carthage](https://github.com/Carthage/Carthage) (Both dynamic and static).
|
|
28
|
+
Lottie supports [Swift Package Manager](https://www.swift.org/package-manager/), [CocoaPods](https://cocoapods.org/), and [Carthage](https://github.com/Carthage/Carthage) (Both dynamic and static).
|
|
29
|
+
|
|
30
30
|
### Github Repo
|
|
31
31
|
|
|
32
|
-
You can pull the [Lottie Github Repo](https://github.com/airbnb/lottie-ios/) and include the Lottie.xcodeproj to build a dynamic or static library.
|
|
32
|
+
You can pull the [Lottie Github Repo](https://github.com/airbnb/lottie-ios/) and include the `Lottie.xcodeproj` to build a dynamic or static library.
|
|
33
|
+
|
|
34
|
+
### Swift Package Manager
|
|
35
|
+
|
|
36
|
+
To install Lottie using [Swift Package Manager](https://github.com/apple/swift-package-manager) you can follow the [tutorial published by Apple](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) using the URL for the Lottie repo with the current version:
|
|
37
|
+
|
|
38
|
+
1. In Xcode, select “File” → “Swift Packages” → “Add Package Dependency”
|
|
39
|
+
1. Enter https://github.com/airbnb/lottie-ios.git
|
|
33
40
|
|
|
34
41
|
### CocoaPods
|
|
35
42
|
Add the pod to your Podfile:
|
|
@@ -41,7 +48,7 @@ And then run:
|
|
|
41
48
|
```ruby
|
|
42
49
|
pod install
|
|
43
50
|
```
|
|
44
|
-
After installing the cocoapod into your project import Lottie with
|
|
51
|
+
After installing the cocoapod into your project import Lottie with
|
|
45
52
|
```swift
|
|
46
53
|
import Lottie
|
|
47
54
|
```
|
|
@@ -57,60 +64,33 @@ carthage update
|
|
|
57
64
|
```
|
|
58
65
|
In your application targets “General” tab under the “Linked Frameworks and Libraries” section, drag and drop lottie-ios.framework from the Carthage/Build/iOS directory that `carthage update` produced.
|
|
59
66
|
|
|
60
|
-
###
|
|
61
|
-
``` swift
|
|
62
|
-
// swift-tools-version:5.1
|
|
63
|
-
|
|
64
|
-
import PackageDescription
|
|
65
|
-
|
|
66
|
-
let package = Package(
|
|
67
|
-
name: "YourTestProject",
|
|
68
|
-
platforms: [
|
|
69
|
-
.iOS(.v12),
|
|
70
|
-
],
|
|
71
|
-
dependencies: [
|
|
72
|
-
.package(url: "https://github.com/airbnb/lottie-ios.git", from: "3.1.2")
|
|
73
|
-
],
|
|
74
|
-
targets: [
|
|
75
|
-
.target(name: "YourTestProject", dependencies: ["Lottie"])
|
|
76
|
-
]
|
|
77
|
-
)
|
|
78
|
-
```
|
|
79
|
-
And then import wherever needed: ```import Lottie```
|
|
80
|
-
|
|
81
|
-
#### Adding it to an existent iOS Project via Swift Package Manager
|
|
82
|
-
|
|
83
|
-
1. Using Xcode 11 go to File > Swift Packages > Add Package Dependency
|
|
84
|
-
2. Paste the project URL: https://github.com/airbnb/lottie-ios
|
|
85
|
-
3. Click on next and select the project target
|
|
86
|
-
4. Don't forget to set `DEAD_CODE_STRIPPING = NO` in your `Build Settings` (https://bugs.swift.org/plugins/servlet/mobile#issue/SR-11564)
|
|
87
|
-
**NOTE: For MacOS you must set the `Branch` field to `lottie/macos-spm`
|
|
88
|
-

|
|
89
|
-
|
|
90
|
-
If you have doubts, please, check the following links:
|
|
91
|
-
|
|
92
|
-
[How to use](https://developer.apple.com/videos/play/wwdc2019/408/)
|
|
93
|
-
|
|
94
|
-
[Creating Swift Packages](https://developer.apple.com/videos/play/wwdc2019/410/)
|
|
95
|
-
|
|
96
|
-
After successfully retrieved the package and added it to your project, just import `Lottie` and you can get the full benefits of it.
|
|
97
|
-
|
|
98
|
-
-----
|
|
99
|
-
|
|
100
|
-
### Objective-C Support
|
|
67
|
+
### Data collection
|
|
101
68
|
|
|
102
|
-
|
|
69
|
+
The Lottie SDK does not collect any data. We provide this notice to help you fill out [App Privacy Details](https://developer.apple.com/app-store/app-privacy-details/).
|
|
103
70
|
|
|
104
|
-
|
|
71
|
+
## Contributing
|
|
105
72
|
|
|
106
|
-
|
|
73
|
+
We always appreciate contributions from the community. To make changes to the project, you can clone the repo and open `Lottie.xcworkspace`. This workspace includes:
|
|
74
|
+
- the Lottie framework (for iOS, macOS, and tvOS)
|
|
75
|
+
- unit tests and snapshot tests (for iOS, must be run on an iPhone 8 simulator)
|
|
76
|
+
- an Example iOS app that lets you browse and test over 100 sample animations included in the repo
|
|
107
77
|
|
|
108
|
-
|
|
78
|
+
All pull requests with new features or bug fixes that affect how animations render should include snapshot test cases that validate the included changes.
|
|
79
|
+
- To add a new sample animation to the snapshot testing suite, you can add the `.json` file to `Tests/Samples`. Re-run the snapshot tests to generate the new snapshot image files.
|
|
80
|
+
- To update existing snapshots after making changes, you can set `isRecording = true` in `SnapshotTests.swift` and then re-run the snapshot tests.
|
|
109
81
|
|
|
110
|
-
|
|
82
|
+
The project also includes several helpful commands defined in our [Rakefile](https://github.com/airbnb/lottie-ios/blob/master/Rakefile). To use these, you need to install [Bundler](https://bundler.io/):
|
|
111
83
|
|
|
112
|
-
|
|
84
|
+
```bash
|
|
85
|
+
$ sudo gem install bundle
|
|
86
|
+
$ bundle install
|
|
87
|
+
```
|
|
113
88
|
|
|
114
|
-
|
|
89
|
+
For example, all Swift code should be formatted according to the [Airbnb Swift Style Guide](https://github.com/airbnb/swift). After making changes, you can reformat the code automatically using [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) and [SwiftLint](https://github.com/realm/SwiftLint) by running `bundle exec rake format:swift`. Other helpful commands include:
|
|
115
90
|
|
|
116
|
-
|
|
91
|
+
```bash
|
|
92
|
+
$ bundle exec rake build:all # builds all targets for all platforms
|
|
93
|
+
$ bundle exec rake build:package:iOS # builds the Lottie package for iOS
|
|
94
|
+
$ bundle exec rake test:package # tests the Lottie package
|
|
95
|
+
$ bundle exec rake format:swift # reformat Swift code based on the Airbnb Swift Style Guide
|
|
96
|
+
```
|
package/Rakefile
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
namespace :build do
|
|
2
|
+
desc 'Builds all packages and executables'
|
|
3
|
+
task all: ['package:all', 'example:all']
|
|
4
|
+
|
|
5
|
+
desc 'Builds the Lottie package for supported platforms'
|
|
6
|
+
namespace :package do
|
|
7
|
+
desc 'Builds the Lottie package for all supported platforms'
|
|
8
|
+
task all: ['iOS', 'macOS', 'tvOS']
|
|
9
|
+
|
|
10
|
+
desc 'Builds the Lottie package for iOS'
|
|
11
|
+
task :iOS do
|
|
12
|
+
xcodebuild('build -scheme "Lottie (iOS)" -destination generic/platform=iOS -workspace Lottie.xcworkspace')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc 'Builds the Lottie package for macOS'
|
|
16
|
+
task :macOS do
|
|
17
|
+
xcodebuild('build -scheme "Lottie (macOS)" -destination generic/platform=macOS -workspace Lottie.xcworkspace')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc 'Builds the Lottie package for tvOS'
|
|
21
|
+
task :tvOS do
|
|
22
|
+
xcodebuild('build -scheme "Lottie (tvOS)" -destination generic/platform=tvOS -workspace Lottie.xcworkspace')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc 'Builds the Lottie example app for supported platforms'
|
|
27
|
+
namespace :example do
|
|
28
|
+
desc 'Builds the Lottie example apps for all supported platforms'
|
|
29
|
+
task all: ['iOS', 'macOS', 'tvOS']
|
|
30
|
+
|
|
31
|
+
desc 'Builds the iOS Lottie Example app'
|
|
32
|
+
task :iOS do
|
|
33
|
+
xcodebuild('build -scheme "Example (iOS)" -destination "platform=iOS Simulator,name=iPhone 8" -workspace Lottie.xcworkspace')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
desc 'Builds the macOS Lottie Example app'
|
|
37
|
+
task :macOS do
|
|
38
|
+
xcodebuild('build -scheme "Example (macOS)" -workspace Lottie.xcworkspace')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
desc 'Builds the tvOS Lottie Example app'
|
|
42
|
+
task :tvOS do
|
|
43
|
+
xcodebuild('build -scheme "Example (tvOS)" -destination "platform=tvOS Simulator,name=Apple TV" -workspace Lottie.xcworkspace')
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
namespace :test do
|
|
49
|
+
desc 'Tests the Lottie package for iOS'
|
|
50
|
+
task :package do
|
|
51
|
+
sh 'rm -rf Tests/Artifacts'
|
|
52
|
+
xcodebuild('test -scheme "Lottie (iOS)" -destination "platform=iOS Simulator,name=iPhone 8" -resultBundlePath Tests/Artifacts/LottieTests.xcresult')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc 'Processes .xcresult artifacts from the most recent test:package execution'
|
|
56
|
+
task :process do
|
|
57
|
+
sh 'mint run ChargePoint/xcparse@2.2.1 xcparse attachments Tests/Artifacts/LottieTests.xcresult Tests/Artifacts/TestAttachments'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc 'Tests Carthage support'
|
|
61
|
+
task :carthage do
|
|
62
|
+
# Copy the repo to `Carthage/Checkouts/Lottie-ios`
|
|
63
|
+
sh 'rm -rf script/test-carthage/Carthage'
|
|
64
|
+
sh 'mkdir script/test-carthage/Carthage script/test-carthage/Carthage/Checkouts script/test-carthage/Carthage/Checkouts/lottie-ios'
|
|
65
|
+
sh 'cp -R [^script]* script/test-carthage/Carthage/Checkouts/lottie-ios'
|
|
66
|
+
|
|
67
|
+
Dir.chdir('script/test-carthage') do
|
|
68
|
+
# Build the LottieCarthage framework scheme
|
|
69
|
+
sh 'carthage build --use-xcframeworks'
|
|
70
|
+
|
|
71
|
+
# Delete Carthage's derived data to verify that the built .xcframework doesn't depend on any
|
|
72
|
+
# side effects from building on this specific machine.
|
|
73
|
+
# https://github.com/airbnb/lottie-ios/issues/1492
|
|
74
|
+
sh 'rm -rf ~/Library/Caches/org.carthage.CarthageKit/DerivedData'
|
|
75
|
+
|
|
76
|
+
# Build a test app that imports and uses the LottieCarthage framework
|
|
77
|
+
xcodebuild('build -scheme CarthageTest -destination "platform=iOS Simulator,name=iPhone 8"')
|
|
78
|
+
xcodebuild('build -scheme CarthageTest-macOS')
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
desc 'Tests Swift Package Manager support'
|
|
83
|
+
task :spm do
|
|
84
|
+
Dir.chdir('script/test-spm') do
|
|
85
|
+
# Build for iOS, macOS, and tvOS using the targets defined in Package.swift
|
|
86
|
+
xcodebuild('build -scheme "Lottie" -destination generic/platform=iOS')
|
|
87
|
+
xcodebuild('build -scheme "Lottie" -destination generic/platform=macOS')
|
|
88
|
+
xcodebuild('build -scheme "Lottie" -destination generic/platform=tvOS')
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
namespace :lint do
|
|
94
|
+
desc 'Lints swift files'
|
|
95
|
+
task :swift do
|
|
96
|
+
sh 'swift package --allow-writing-to-package-directory format --lint'
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
desc 'Lints the CocoaPods podspec'
|
|
100
|
+
task :podspec do
|
|
101
|
+
sh 'pod lib lint lottie-ios.podspec'
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
namespace :format do
|
|
106
|
+
desc 'Formats swift files'
|
|
107
|
+
task :swift do
|
|
108
|
+
sh 'swift package --allow-writing-to-package-directory format'
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def xcodebuild(command)
|
|
113
|
+
# Check if the mint tool is installed -- if so, pipe the xcodebuild output through xcbeautify
|
|
114
|
+
`which mint`
|
|
115
|
+
|
|
116
|
+
if $?.success?
|
|
117
|
+
sh "set -o pipefail && xcodebuild #{command} | mint run thii/xcbeautify@0.10.2"
|
|
118
|
+
else
|
|
119
|
+
sh "xcodebuild #{command}"
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Created by Cal Stephens on 1/6/22.
|
|
2
|
+
// Copyright © 2022 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
import QuartzCore
|
|
5
|
+
|
|
6
|
+
extension CAAnimation {
|
|
7
|
+
/// Creates a `CAAnimation` that wraps this animation,
|
|
8
|
+
/// applying timing-related configuration from the given `LayerAnimationContext`.
|
|
9
|
+
/// - This animation should start at the beginning of the animation and
|
|
10
|
+
/// last the entire duration of the animation. It will be trimmed and retimed
|
|
11
|
+
/// to match the current playback state / looping configuration of the animation view.
|
|
12
|
+
@nonobjc
|
|
13
|
+
func timed(with context: LayerAnimationContext, for layer: CALayer) -> CAAnimation {
|
|
14
|
+
// The base animation always has the duration of the full animation,
|
|
15
|
+
// since that's the time space where keyframing and interpolating happens.
|
|
16
|
+
// So we start with a simple animation timeline from 0% to 100%:
|
|
17
|
+
//
|
|
18
|
+
// ┌──────────────────────────────────┐
|
|
19
|
+
// │ baseAnimation │
|
|
20
|
+
// └──────────────────────────────────┘
|
|
21
|
+
// 0% 100%
|
|
22
|
+
//
|
|
23
|
+
let baseAnimation = self
|
|
24
|
+
baseAnimation.duration = context.animation.duration
|
|
25
|
+
baseAnimation.speed = (context.endFrame < context.startFrame) ? -1 : 1
|
|
26
|
+
|
|
27
|
+
// To select the subrange of the `baseAnimation` that should be played,
|
|
28
|
+
// we create a parent animation with the duration of that subrange
|
|
29
|
+
// to clip the `baseAnimation`. This parent animation can then loop
|
|
30
|
+
// and/or autoreverse over the clipped subrange.
|
|
31
|
+
//
|
|
32
|
+
// ┌────────────────────┬───────►
|
|
33
|
+
// │ clippingParent │ ...
|
|
34
|
+
// └────────────────────┴───────►
|
|
35
|
+
// 25% 75%
|
|
36
|
+
// ┌──────────────────────────────────┐
|
|
37
|
+
// │ baseAnimation │
|
|
38
|
+
// └──────────────────────────────────┘
|
|
39
|
+
// 0% 100%
|
|
40
|
+
//
|
|
41
|
+
let clippingParent = CAAnimationGroup()
|
|
42
|
+
clippingParent.animations = [baseAnimation]
|
|
43
|
+
|
|
44
|
+
clippingParent.duration = Double(abs(context.endFrame - context.startFrame)) / context.animation.framerate
|
|
45
|
+
baseAnimation.timeOffset = context.animation.time(forFrame: context.startFrame)
|
|
46
|
+
|
|
47
|
+
clippingParent.autoreverses = context.timingConfiguration.autoreverses
|
|
48
|
+
clippingParent.repeatCount = context.timingConfiguration.repeatCount
|
|
49
|
+
clippingParent.timeOffset = context.timingConfiguration.timeOffset
|
|
50
|
+
|
|
51
|
+
// Once the animation ends, it should pause on the final frame
|
|
52
|
+
clippingParent.fillMode = .both
|
|
53
|
+
clippingParent.isRemovedOnCompletion = false
|
|
54
|
+
|
|
55
|
+
// We can pause the animation on a specific frame by setting the root layer's
|
|
56
|
+
// `speed` to 0, and then setting the `timeOffset` for the given frame.
|
|
57
|
+
// - For that setup to work properly, we have to set the `beginTime`
|
|
58
|
+
// of this animation to a time slightly before the current time.
|
|
59
|
+
// - It's not really clear why this is necessary, but `timeOffset`
|
|
60
|
+
// is not applied correctly without this configuration.
|
|
61
|
+
// - We can't do this when playing the animation in real time,
|
|
62
|
+
// because it can cause keyframe timings to be incorrect.
|
|
63
|
+
if context.timingConfiguration.speed == 0 {
|
|
64
|
+
let currentTime = layer.convertTime(CACurrentMediaTime(), from: nil)
|
|
65
|
+
clippingParent.beginTime = currentTime - .leastNonzeroMagnitude
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return clippingParent
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
extension CALayer {
|
|
73
|
+
/// Adds the given animation to this layer, timed with the given timing configuration
|
|
74
|
+
/// - The given animation should start at the beginning of the animation and
|
|
75
|
+
/// last the entire duration of the animation. It will be trimmed and retimed
|
|
76
|
+
/// to match the current playback state / looping configuration of the animation view.
|
|
77
|
+
@nonobjc
|
|
78
|
+
func add(_ animation: CAPropertyAnimation, timedWith context: LayerAnimationContext) {
|
|
79
|
+
add(animation.timed(with: context, for: self), forKey: animation.keyPath)
|
|
80
|
+
}
|
|
81
|
+
}
|