@octane-xplat/lottie 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -16
- package/dist/native/index.js +10 -9
- package/dist/native/octane-client-build.json +1 -1
- package/dist/web/index.js +39 -25
- package/dist/web/octane-client-build.json +1 -1
- package/package.json +25 -3
- package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
- package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
- package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
- package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
- package/platforms/macos/UPSTREAM.md +13 -0
- package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
- package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
- package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
- package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
- package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
- package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
- package/src/Lottie.macos.tsrx +129 -0
- package/src/Lottie.tsrx +3 -2
- package/src/Lottie.web.tsrx +28 -11
- package/src/index.macos.ts +2 -0
- package/src/props.ts +6 -1
- package/types/generated/props.d.ts +5 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CompositionLayersInitializer.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 1/25/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import CoreGraphics
|
|
9
|
+
import Foundation
|
|
10
|
+
|
|
11
|
+
extension [LayerModel] {
|
|
12
|
+
|
|
13
|
+
func initializeCompositionLayers(
|
|
14
|
+
assetLibrary: AssetLibrary?,
|
|
15
|
+
layerImageProvider: LayerImageProvider,
|
|
16
|
+
layerTextProvider: LayerTextProvider,
|
|
17
|
+
layerFontProvider: LayerFontProvider,
|
|
18
|
+
textProvider: AnimationKeypathTextProvider,
|
|
19
|
+
fontProvider: AnimationFontProvider,
|
|
20
|
+
frameRate: CGFloat,
|
|
21
|
+
rootAnimationLayer: MainThreadAnimationLayer?
|
|
22
|
+
) -> [CompositionLayer] {
|
|
23
|
+
var compositionLayers = [CompositionLayer]()
|
|
24
|
+
var layerMap = [Int: CompositionLayer]()
|
|
25
|
+
|
|
26
|
+
/// Organize the assets into a dictionary of [ID : ImageAsset]
|
|
27
|
+
var childLayers = [LayerModel]()
|
|
28
|
+
|
|
29
|
+
for layer in self {
|
|
30
|
+
if layer.hidden == true {
|
|
31
|
+
let genericLayer = NullCompositionLayer(layer: layer)
|
|
32
|
+
compositionLayers.append(genericLayer)
|
|
33
|
+
layerMap[layer.index] = genericLayer
|
|
34
|
+
} else if let shapeLayer = layer as? ShapeLayerModel {
|
|
35
|
+
let shapeContainer = ShapeCompositionLayer(shapeLayer: shapeLayer)
|
|
36
|
+
compositionLayers.append(shapeContainer)
|
|
37
|
+
layerMap[layer.index] = shapeContainer
|
|
38
|
+
} else if let solidLayer = layer as? SolidLayerModel {
|
|
39
|
+
let solidContainer = SolidCompositionLayer(solid: solidLayer)
|
|
40
|
+
compositionLayers.append(solidContainer)
|
|
41
|
+
layerMap[layer.index] = solidContainer
|
|
42
|
+
} else if
|
|
43
|
+
let precompLayer = layer as? PreCompLayerModel,
|
|
44
|
+
let assetLibrary,
|
|
45
|
+
let precompAsset = assetLibrary.precompAssets[precompLayer.referenceID]
|
|
46
|
+
{
|
|
47
|
+
let precompContainer = PreCompositionLayer(
|
|
48
|
+
precomp: precompLayer,
|
|
49
|
+
asset: precompAsset,
|
|
50
|
+
layerImageProvider: layerImageProvider,
|
|
51
|
+
layerTextProvider: layerTextProvider,
|
|
52
|
+
layerFontProvider: layerFontProvider,
|
|
53
|
+
textProvider: textProvider,
|
|
54
|
+
fontProvider: fontProvider,
|
|
55
|
+
assetLibrary: assetLibrary,
|
|
56
|
+
frameRate: frameRate,
|
|
57
|
+
rootAnimationLayer: rootAnimationLayer
|
|
58
|
+
)
|
|
59
|
+
compositionLayers.append(precompContainer)
|
|
60
|
+
layerMap[layer.index] = precompContainer
|
|
61
|
+
} else if
|
|
62
|
+
let imageLayer = layer as? ImageLayerModel,
|
|
63
|
+
let assetLibrary,
|
|
64
|
+
let imageAsset = assetLibrary.imageAssets[imageLayer.referenceID]
|
|
65
|
+
{
|
|
66
|
+
let imageContainer = ImageCompositionLayer(
|
|
67
|
+
imageLayer: imageLayer,
|
|
68
|
+
size: CGSize(width: imageAsset.width, height: imageAsset.height)
|
|
69
|
+
)
|
|
70
|
+
compositionLayers.append(imageContainer)
|
|
71
|
+
layerMap[layer.index] = imageContainer
|
|
72
|
+
} else if let textLayer = layer as? TextLayerModel {
|
|
73
|
+
let textContainer = TextCompositionLayer(
|
|
74
|
+
textLayer: textLayer,
|
|
75
|
+
textProvider: textProvider,
|
|
76
|
+
fontProvider: fontProvider,
|
|
77
|
+
rootAnimationLayer: rootAnimationLayer
|
|
78
|
+
)
|
|
79
|
+
compositionLayers.append(textContainer)
|
|
80
|
+
layerMap[layer.index] = textContainer
|
|
81
|
+
} else {
|
|
82
|
+
let genericLayer = NullCompositionLayer(layer: layer)
|
|
83
|
+
compositionLayers.append(genericLayer)
|
|
84
|
+
layerMap[layer.index] = genericLayer
|
|
85
|
+
}
|
|
86
|
+
if layer.parent != nil {
|
|
87
|
+
childLayers.append(layer)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// Now link children with their parents
|
|
92
|
+
for layerModel in childLayers {
|
|
93
|
+
if let parentID = layerModel.parent {
|
|
94
|
+
let childLayer = layerMap[layerModel.index]
|
|
95
|
+
let parentLayer = layerMap[parentID]
|
|
96
|
+
childLayer?.transformNode.parentNode = parentLayer?.transformNode
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return compositionLayers
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
}
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
//
|
|
2
|
+
// TextLayer.swift
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 8/3/20.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import CoreGraphics
|
|
9
|
+
import CoreText
|
|
10
|
+
import Foundation
|
|
11
|
+
import QuartzCore
|
|
12
|
+
/// Needed for NSMutableParagraphStyle...
|
|
13
|
+
#if os(OSX)
|
|
14
|
+
import AppKit
|
|
15
|
+
#else
|
|
16
|
+
import UIKit
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
// MARK: - CoreTextRenderLayer
|
|
20
|
+
|
|
21
|
+
/// A CALayer subclass that renders text content using CoreText
|
|
22
|
+
final class CoreTextRenderLayer: CALayer {
|
|
23
|
+
|
|
24
|
+
// MARK: Internal
|
|
25
|
+
|
|
26
|
+
var text: String? {
|
|
27
|
+
didSet {
|
|
28
|
+
needsContentUpdate = true
|
|
29
|
+
setNeedsLayout()
|
|
30
|
+
setNeedsDisplay()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var font: CTFont? {
|
|
35
|
+
didSet {
|
|
36
|
+
needsContentUpdate = true
|
|
37
|
+
setNeedsLayout()
|
|
38
|
+
setNeedsDisplay()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var alignment = NSTextAlignment.left {
|
|
43
|
+
didSet {
|
|
44
|
+
needsContentUpdate = true
|
|
45
|
+
setNeedsLayout()
|
|
46
|
+
setNeedsDisplay()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var lineHeight: CGFloat = 0 {
|
|
51
|
+
didSet {
|
|
52
|
+
needsContentUpdate = true
|
|
53
|
+
setNeedsLayout()
|
|
54
|
+
setNeedsDisplay()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var tracking: CGFloat = 0 {
|
|
59
|
+
didSet {
|
|
60
|
+
needsContentUpdate = true
|
|
61
|
+
setNeedsLayout()
|
|
62
|
+
setNeedsDisplay()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var fillColor: CGColor? {
|
|
67
|
+
didSet {
|
|
68
|
+
needsContentUpdate = true
|
|
69
|
+
setNeedsLayout()
|
|
70
|
+
setNeedsDisplay()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var strokeColor: CGColor? {
|
|
75
|
+
didSet {
|
|
76
|
+
needsContentUpdate = true
|
|
77
|
+
setNeedsLayout()
|
|
78
|
+
setNeedsDisplay()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var strokeWidth: CGFloat = 0 {
|
|
83
|
+
didSet {
|
|
84
|
+
needsContentUpdate = true
|
|
85
|
+
setNeedsLayout()
|
|
86
|
+
setNeedsDisplay()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var strokeOnTop = false {
|
|
91
|
+
didSet {
|
|
92
|
+
setNeedsLayout()
|
|
93
|
+
setNeedsDisplay()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var preferredSize: CGSize? {
|
|
98
|
+
didSet {
|
|
99
|
+
needsContentUpdate = true
|
|
100
|
+
setNeedsLayout()
|
|
101
|
+
setNeedsDisplay()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var start: Int? {
|
|
106
|
+
didSet {
|
|
107
|
+
needsContentUpdate = true
|
|
108
|
+
setNeedsLayout()
|
|
109
|
+
setNeedsDisplay()
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var end: Int? {
|
|
114
|
+
didSet {
|
|
115
|
+
needsContentUpdate = true
|
|
116
|
+
setNeedsLayout()
|
|
117
|
+
setNeedsDisplay()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/// The type of unit to use when computing the `start` / `end` range within the text string
|
|
122
|
+
var textRangeUnit: TextRangeUnit? {
|
|
123
|
+
didSet {
|
|
124
|
+
needsContentUpdate = true
|
|
125
|
+
setNeedsLayout()
|
|
126
|
+
setNeedsDisplay()
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// The opacity to apply to the range between `start` and `end`
|
|
131
|
+
var selectedRangeOpacity: CGFloat? {
|
|
132
|
+
didSet {
|
|
133
|
+
needsContentUpdate = true
|
|
134
|
+
setNeedsLayout()
|
|
135
|
+
setNeedsDisplay()
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
func sizeToFit() {
|
|
140
|
+
updateTextContent()
|
|
141
|
+
bounds = drawingRect
|
|
142
|
+
anchorPoint = drawingAnchor
|
|
143
|
+
setNeedsLayout()
|
|
144
|
+
setNeedsDisplay()
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
override func action(forKey _: String) -> CAAction? {
|
|
148
|
+
nil
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
override func draw(in ctx: CGContext) {
|
|
152
|
+
guard let attributedString else { return }
|
|
153
|
+
updateTextContent()
|
|
154
|
+
guard fillFrameSetter != nil || strokeFrameSetter != nil else { return }
|
|
155
|
+
|
|
156
|
+
ctx.textMatrix = .identity
|
|
157
|
+
ctx.setAllowsAntialiasing(true)
|
|
158
|
+
ctx.setAllowsFontSubpixelPositioning(true)
|
|
159
|
+
ctx.setAllowsFontSubpixelQuantization(true)
|
|
160
|
+
|
|
161
|
+
ctx.setShouldAntialias(true)
|
|
162
|
+
ctx.setShouldSubpixelPositionFonts(true)
|
|
163
|
+
ctx.setShouldSubpixelQuantizeFonts(true)
|
|
164
|
+
|
|
165
|
+
if contentsAreFlipped() {
|
|
166
|
+
ctx.translateBy(x: 0, y: drawingRect.height)
|
|
167
|
+
ctx.scaleBy(x: 1.0, y: -1.0)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let drawingPath = CGPath(rect: drawingRect, transform: nil)
|
|
171
|
+
if preferredSize == nil {
|
|
172
|
+
let horizontalOffset: CGFloat =
|
|
173
|
+
switch alignment {
|
|
174
|
+
case .left:
|
|
175
|
+
compensationPadding
|
|
176
|
+
case .right:
|
|
177
|
+
-compensationPadding
|
|
178
|
+
default:
|
|
179
|
+
0
|
|
180
|
+
}
|
|
181
|
+
ctx.translateBy(x: horizontalOffset, y: 0)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
let fillFrame: CTFrame? =
|
|
185
|
+
if let setter = fillFrameSetter {
|
|
186
|
+
CTFramesetterCreateFrame(setter, CFRangeMake(0, attributedString.length), drawingPath, nil)
|
|
187
|
+
} else {
|
|
188
|
+
nil
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let strokeFrame: CTFrame? =
|
|
192
|
+
if let setter = strokeFrameSetter {
|
|
193
|
+
CTFramesetterCreateFrame(setter, CFRangeMake(0, attributedString.length), drawingPath, nil)
|
|
194
|
+
} else {
|
|
195
|
+
nil
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// This fixes a vertical padding issue that arises when drawing some fonts.
|
|
199
|
+
// For some reason some fonts, such as Helvetica draw with an ascender that is greater than the one reported by CTFontGetAscender.
|
|
200
|
+
// I suspect this is actually an issue with the Attributed string, but cannot reproduce.
|
|
201
|
+
|
|
202
|
+
if let fillFrame {
|
|
203
|
+
ctx.adjustWithLineOrigins(in: fillFrame, with: font)
|
|
204
|
+
} else if let strokeFrame {
|
|
205
|
+
ctx.adjustWithLineOrigins(in: strokeFrame, with: font)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if !strokeOnTop, let strokeFrame {
|
|
209
|
+
CTFrameDraw(strokeFrame, ctx)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if let fillFrame {
|
|
213
|
+
CTFrameDraw(fillFrame, ctx)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if strokeOnTop, let strokeFrame {
|
|
217
|
+
CTFrameDraw(strokeFrame, ctx)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// MARK: Private
|
|
222
|
+
|
|
223
|
+
private var drawingRect = CGRect.zero
|
|
224
|
+
private var drawingAnchor = CGPoint.zero
|
|
225
|
+
private var fillFrameSetter: CTFramesetter?
|
|
226
|
+
private var attributedString: NSAttributedString?
|
|
227
|
+
private var strokeFrameSetter: CTFramesetter?
|
|
228
|
+
private var needsContentUpdate = false
|
|
229
|
+
|
|
230
|
+
/// Horizontal compensation padding for the fonts that report wrong geometry.
|
|
231
|
+
///
|
|
232
|
+
/// Some fonts have symbols that are drawn beyond the suggested frame
|
|
233
|
+
/// that CoreText returns, especially calligraphy fonts. This padding tries to compensate for that.
|
|
234
|
+
/// Because we can't know for sure the real size of the text,
|
|
235
|
+
/// the 20% value was experimentally chosen to account for most such cases.
|
|
236
|
+
private var compensationPadding: CGFloat {
|
|
237
|
+
(font.map(CTFontGetSize) ?? 0) * 0.2
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private func updateTextContent() {
|
|
241
|
+
guard needsContentUpdate else { return }
|
|
242
|
+
needsContentUpdate = false
|
|
243
|
+
guard let font, let text, text.count > 0, fillColor != nil || strokeColor != nil else {
|
|
244
|
+
drawingRect = .zero
|
|
245
|
+
drawingAnchor = .zero
|
|
246
|
+
attributedString = nil
|
|
247
|
+
fillFrameSetter = nil
|
|
248
|
+
strokeFrameSetter = nil
|
|
249
|
+
return
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Get Font properties
|
|
253
|
+
let ascent = CTFontGetAscent(font)
|
|
254
|
+
let descent = CTFontGetDescent(font)
|
|
255
|
+
let capHeight = CTFontGetCapHeight(font)
|
|
256
|
+
let leading = CTFontGetLeading(font)
|
|
257
|
+
let minLineHeight = -(ascent + descent + leading)
|
|
258
|
+
|
|
259
|
+
// Calculate line spacing
|
|
260
|
+
let lineSpacing = max(CGFloat(minLineHeight) + lineHeight, CGFloat(minLineHeight))
|
|
261
|
+
// Build Attributes
|
|
262
|
+
let paragraphStyle = NSMutableParagraphStyle()
|
|
263
|
+
paragraphStyle.lineSpacing = lineSpacing
|
|
264
|
+
paragraphStyle.lineHeightMultiple = 1
|
|
265
|
+
paragraphStyle.maximumLineHeight = ascent + descent + leading
|
|
266
|
+
paragraphStyle.alignment = alignment
|
|
267
|
+
paragraphStyle.lineBreakMode = NSLineBreakMode.byWordWrapping
|
|
268
|
+
var attributes: [NSAttributedString.Key: Any] = [
|
|
269
|
+
NSAttributedString.Key.ligature: 0,
|
|
270
|
+
NSAttributedString.Key.font: font,
|
|
271
|
+
NSAttributedString.Key.kern: tracking,
|
|
272
|
+
NSAttributedString.Key.paragraphStyle: paragraphStyle,
|
|
273
|
+
]
|
|
274
|
+
|
|
275
|
+
if let fillColor {
|
|
276
|
+
attributes[NSAttributedString.Key.foregroundColor] = fillColor
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
let attrString = NSMutableAttributedString(string: text, attributes: attributes)
|
|
280
|
+
|
|
281
|
+
// Apply the text animator within between the `start` and `end` indices
|
|
282
|
+
if let selectedRangeOpacity {
|
|
283
|
+
// The start and end of a text animator refer to the portions of the text
|
|
284
|
+
// where that animator is applies. In the schema these can be represented
|
|
285
|
+
// in absolute index value, or as percentages relative to the dynamic string length.
|
|
286
|
+
var startIndex: Int
|
|
287
|
+
var endIndex: Int
|
|
288
|
+
|
|
289
|
+
switch textRangeUnit ?? .percentage {
|
|
290
|
+
case .index:
|
|
291
|
+
startIndex = start ?? 0
|
|
292
|
+
endIndex = end ?? text.count
|
|
293
|
+
|
|
294
|
+
case .percentage:
|
|
295
|
+
let startPercentage = Double(start ?? 0) / 100
|
|
296
|
+
let endPercentage = Double(end ?? 100) / 100
|
|
297
|
+
|
|
298
|
+
startIndex = Int(round(Double(attrString.length) * startPercentage))
|
|
299
|
+
endIndex = Int(round(Double(attrString.length) * endPercentage))
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Carefully cap the indices, since passing invalid indices
|
|
303
|
+
// to `NSAttributedString` will crash the app.
|
|
304
|
+
startIndex = startIndex.clamp(0, attrString.length)
|
|
305
|
+
endIndex = endIndex.clamp(0, attrString.length)
|
|
306
|
+
|
|
307
|
+
// Make sure the end index actually comes after the start index
|
|
308
|
+
if endIndex < startIndex {
|
|
309
|
+
swap(&startIndex, &endIndex)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Apply the `selectedRangeOpacity` to the current `fillColor` if provided
|
|
313
|
+
let textRangeColor: CGColor
|
|
314
|
+
if let fillColor {
|
|
315
|
+
if let (r, g, b) = fillColor.rgb {
|
|
316
|
+
textRangeColor = .rgba(r, g, b, selectedRangeOpacity)
|
|
317
|
+
} else {
|
|
318
|
+
LottieLogger.shared.warn("Could not convert color \(fillColor) to RGB values.")
|
|
319
|
+
textRangeColor = .rgba(0, 0, 0, selectedRangeOpacity)
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
textRangeColor = .rgba(0, 0, 0, selectedRangeOpacity)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
attrString.addAttribute(
|
|
326
|
+
NSAttributedString.Key.foregroundColor,
|
|
327
|
+
value: textRangeColor,
|
|
328
|
+
range: NSRange(location: startIndex, length: endIndex - startIndex)
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
attributedString = attrString
|
|
333
|
+
|
|
334
|
+
if fillColor != nil {
|
|
335
|
+
let setter = CTFramesetterCreateWithAttributedString(attrString as CFAttributedString)
|
|
336
|
+
fillFrameSetter = setter
|
|
337
|
+
} else {
|
|
338
|
+
fillFrameSetter = nil
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if let strokeColor {
|
|
342
|
+
attributes[NSAttributedString.Key.foregroundColor] = nil
|
|
343
|
+
attributes[NSAttributedString.Key.strokeWidth] = strokeWidth
|
|
344
|
+
attributes[NSAttributedString.Key.strokeColor] = strokeColor
|
|
345
|
+
let strokeAttributedString = NSAttributedString(string: text, attributes: attributes)
|
|
346
|
+
strokeFrameSetter = CTFramesetterCreateWithAttributedString(strokeAttributedString as CFAttributedString)
|
|
347
|
+
} else {
|
|
348
|
+
strokeFrameSetter = nil
|
|
349
|
+
strokeWidth = 0
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
guard let setter = fillFrameSetter ?? strokeFrameSetter else {
|
|
353
|
+
return
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Calculate drawing size and anchor offset
|
|
357
|
+
let textAnchor: CGPoint
|
|
358
|
+
if let preferredSize {
|
|
359
|
+
drawingRect = CGRect(origin: .zero, size: preferredSize)
|
|
360
|
+
drawingRect.size.height += (ascent - capHeight)
|
|
361
|
+
drawingRect.size.height += descent
|
|
362
|
+
textAnchor = CGPoint(x: 0, y: ascent - capHeight)
|
|
363
|
+
} else {
|
|
364
|
+
let size = CTFramesetterSuggestFrameSizeWithConstraints(
|
|
365
|
+
setter,
|
|
366
|
+
CFRange(location: 0, length: attrString.length),
|
|
367
|
+
nil,
|
|
368
|
+
CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude),
|
|
369
|
+
nil
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
// Suggested size + horizontal compensation for fonts with inaccurate geometry.
|
|
373
|
+
let adjustedSize = CGSize(width: size.width + compensationPadding * 2, height: size.height)
|
|
374
|
+
|
|
375
|
+
switch alignment {
|
|
376
|
+
case .left:
|
|
377
|
+
textAnchor = CGPoint(x: compensationPadding, y: ascent)
|
|
378
|
+
case .right:
|
|
379
|
+
textAnchor = CGPoint(x: adjustedSize.width - compensationPadding, y: ascent)
|
|
380
|
+
case .center:
|
|
381
|
+
textAnchor = CGPoint(x: adjustedSize.width * 0.5, y: ascent)
|
|
382
|
+
default:
|
|
383
|
+
textAnchor = .zero
|
|
384
|
+
}
|
|
385
|
+
drawingRect = CGRect(
|
|
386
|
+
x: 0,
|
|
387
|
+
y: 0,
|
|
388
|
+
width: ceil(adjustedSize.width),
|
|
389
|
+
height: ceil(adjustedSize.height)
|
|
390
|
+
)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Now Calculate Anchor
|
|
394
|
+
drawingAnchor = CGPoint(
|
|
395
|
+
x: textAnchor.x.remap(fromLow: 0, fromHigh: drawingRect.size.width, toLow: 0, toHigh: 1),
|
|
396
|
+
y: textAnchor.y.remap(fromLow: 0, fromHigh: drawingRect.size.height, toLow: 0, toHigh: 1)
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
if fillFrameSetter != nil, strokeFrameSetter != nil {
|
|
400
|
+
drawingRect.size.width += strokeWidth
|
|
401
|
+
drawingRect.size.height += strokeWidth
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
extension CGContext {
|
|
408
|
+
|
|
409
|
+
fileprivate func adjustWithLineOrigins(in frame: CTFrame, with font: CTFont?) {
|
|
410
|
+
guard let font else { return }
|
|
411
|
+
|
|
412
|
+
let count = CFArrayGetCount(CTFrameGetLines(frame))
|
|
413
|
+
|
|
414
|
+
guard count > 0 else { return }
|
|
415
|
+
|
|
416
|
+
var o = [CGPoint](repeating: .zero, count: 1)
|
|
417
|
+
CTFrameGetLineOrigins(frame, CFRange(location: count - 1, length: 1), &o)
|
|
418
|
+
|
|
419
|
+
let diff = CTFontGetDescent(font) - o[0].y
|
|
420
|
+
if diff > 0 {
|
|
421
|
+
translateBy(x: 0, y: diff)
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//
|
|
2
|
+
// InvertedMatteLayer.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 1/28/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import QuartzCore
|
|
9
|
+
|
|
10
|
+
/// A layer that inverses the alpha output of its input layer.
|
|
11
|
+
///
|
|
12
|
+
/// WARNING: This is experimental and probably not very performant.
|
|
13
|
+
final class InvertedMatteLayer: CALayer, CompositionLayerDelegate {
|
|
14
|
+
|
|
15
|
+
// MARK: Lifecycle
|
|
16
|
+
|
|
17
|
+
init(inputMatte: CompositionLayer) {
|
|
18
|
+
self.inputMatte = inputMatte
|
|
19
|
+
super.init()
|
|
20
|
+
inputMatte.layerDelegate = self
|
|
21
|
+
anchorPoint = .zero
|
|
22
|
+
bounds = inputMatte.bounds
|
|
23
|
+
setNeedsDisplay()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override init(layer: Any) {
|
|
27
|
+
guard let layer = layer as? InvertedMatteLayer else {
|
|
28
|
+
fatalError("init(layer:) wrong class.")
|
|
29
|
+
}
|
|
30
|
+
inputMatte = nil
|
|
31
|
+
super.init(layer: layer)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
required init?(coder _: NSCoder) {
|
|
35
|
+
fatalError("init(coder:) has not been implemented")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// MARK: Internal
|
|
39
|
+
|
|
40
|
+
let inputMatte: CompositionLayer?
|
|
41
|
+
|
|
42
|
+
func frameUpdated(frame _: CGFloat) {
|
|
43
|
+
setNeedsDisplay()
|
|
44
|
+
displayIfNeeded()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override func draw(in ctx: CGContext) {
|
|
48
|
+
guard let inputMatte else { return }
|
|
49
|
+
ctx.setFillColor(.rgb(0, 0, 0))
|
|
50
|
+
ctx.fill(bounds)
|
|
51
|
+
ctx.setBlendMode(.destinationOut)
|
|
52
|
+
inputMatte.render(in: ctx)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// LayerFontProvider.swift
|
|
3
|
+
// Lottie
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 8/5/20.
|
|
6
|
+
// Copyright © 2020 YurtvilleProds. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
/// Connects a LottieFontProvider to a group of text layers
|
|
10
|
+
final class LayerFontProvider {
|
|
11
|
+
|
|
12
|
+
// MARK: Lifecycle
|
|
13
|
+
|
|
14
|
+
init(fontProvider: AnimationFontProvider) {
|
|
15
|
+
self.fontProvider = fontProvider
|
|
16
|
+
textLayers = []
|
|
17
|
+
reloadTexts()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// MARK: Internal
|
|
21
|
+
|
|
22
|
+
private(set) var textLayers: [TextCompositionLayer]
|
|
23
|
+
|
|
24
|
+
var fontProvider: AnimationFontProvider {
|
|
25
|
+
didSet {
|
|
26
|
+
reloadTexts()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func addTextLayers(_ layers: [TextCompositionLayer]) {
|
|
31
|
+
textLayers += layers
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
func reloadTexts() {
|
|
35
|
+
for textLayer in textLayers {
|
|
36
|
+
textLayer.fontProvider = fontProvider
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// LayerImageProvider.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 1/25/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
/// Connects a LottieImageProvider to a group of image layers
|
|
9
|
+
final class LayerImageProvider {
|
|
10
|
+
|
|
11
|
+
// MARK: Lifecycle
|
|
12
|
+
|
|
13
|
+
init(imageProvider: AnimationImageProvider, assets: [String: ImageAsset]?) {
|
|
14
|
+
self.imageProvider = imageProvider
|
|
15
|
+
imageLayers = [ImageCompositionLayer]()
|
|
16
|
+
if let assets {
|
|
17
|
+
imageAssets = assets
|
|
18
|
+
} else {
|
|
19
|
+
imageAssets = [:]
|
|
20
|
+
}
|
|
21
|
+
reloadImages()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// MARK: Internal
|
|
25
|
+
|
|
26
|
+
private(set) var imageLayers: [ImageCompositionLayer]
|
|
27
|
+
let imageAssets: [String: ImageAsset]
|
|
28
|
+
|
|
29
|
+
var imageProvider: AnimationImageProvider {
|
|
30
|
+
didSet {
|
|
31
|
+
reloadImages()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func addImageLayers(_ layers: [ImageCompositionLayer]) {
|
|
36
|
+
for layer in layers {
|
|
37
|
+
if imageAssets[layer.imageReferenceID] != nil {
|
|
38
|
+
/// Found a linking asset in our asset library. Add layer
|
|
39
|
+
imageLayers.append(layer)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func reloadImages() {
|
|
45
|
+
for imageLayer in imageLayers {
|
|
46
|
+
if let asset = imageAssets[imageLayer.imageReferenceID] {
|
|
47
|
+
imageLayer.image = imageProvider.imageForAsset(asset: asset)
|
|
48
|
+
imageLayer.imageContentsGravity = imageProvider.contentsGravity(for: asset)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// LayerTextProvider.swift
|
|
3
|
+
// lottie-ios-iOS
|
|
4
|
+
//
|
|
5
|
+
// Created by Alexandr Goncharov on 07/06/2019.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
/// Connects a LottieTextProvider to a group of text layers
|
|
9
|
+
final class LayerTextProvider {
|
|
10
|
+
|
|
11
|
+
// MARK: Lifecycle
|
|
12
|
+
|
|
13
|
+
init(textProvider: AnimationKeypathTextProvider) {
|
|
14
|
+
self.textProvider = textProvider
|
|
15
|
+
textLayers = []
|
|
16
|
+
reloadTexts()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// MARK: Internal
|
|
20
|
+
|
|
21
|
+
private(set) var textLayers: [TextCompositionLayer]
|
|
22
|
+
|
|
23
|
+
var textProvider: AnimationKeypathTextProvider {
|
|
24
|
+
didSet {
|
|
25
|
+
reloadTexts()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
func addTextLayers(_ layers: [TextCompositionLayer]) {
|
|
30
|
+
textLayers += layers
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func reloadTexts() {
|
|
34
|
+
for textLayer in textLayers {
|
|
35
|
+
textLayer.textProvider = textProvider
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|