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
|
@@ -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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
40
|
-
let
|
|
41
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
package/{lottie-swift/src → Sources}/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift
RENAMED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
111
|
+
get { animationView.currentFrame }
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
@objc
|
|
109
115
|
public var realtimeAnimationFrame: CGFloat {
|
|
110
|
-
|
|
116
|
+
animationView.realtimeAnimationFrame
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
@objc
|
|
114
120
|
public var realtimeAnimationProgress: CGFloat {
|
|
115
|
-
|
|
121
|
+
animationView.realtimeAnimationProgress
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
@objc
|
|
119
125
|
public var animationSpeed: CGFloat {
|
|
120
126
|
set { animationView.animationSpeed = newValue }
|
|
121
|
-
get {
|
|
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 {
|
|
133
|
+
get { animationView.respectAnimationFrameRate }
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
@objc
|
|
131
137
|
public var isAnimationPlaying: Bool {
|
|
132
|
-
|
|
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)
|
|
212
|
+
atFrame: CGFloat)
|
|
213
|
+
-> Any?
|
|
207
214
|
{
|
|
208
|
-
|
|
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
|
-
|
|
253
|
+
return nil;
|
|
249
254
|
}
|
|
250
255
|
|
|
251
|
-
return UIColor(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
297
|
+
animationView.progressTime(forMarker: named) ?? 0
|
|
289
298
|
}
|
|
290
299
|
|
|
291
300
|
@objc
|
|
292
301
|
public func frameTime(forMarker named: String) -> CGFloat {
|
|
293
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
+
layer
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
}
|
|
20
19
|
#endif
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
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
|
-
|
|
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
|
-
///
|
|
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
|
-
|
|
35
|
+
true
|
|
67
36
|
}
|
|
68
|
-
|
|
37
|
+
|
|
69
38
|
public override var isFlipped: Bool {
|
|
70
|
-
|
|
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
|
-
|
|
57
|
+
layoutAnimation()
|
|
84
58
|
CATransaction.commit()
|
|
85
59
|
}
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
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.
|
|
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
|