@octane-xplat/lottie 0.0.1 → 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 +56 -2
- package/dist/native/cx.mobile.js +11 -0
- package/dist/native/escape-props.js +39 -0
- package/dist/native/index.js +183 -0
- package/dist/native/layout-child.js +38 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/native/vendor/ui-lottie/index.android.js +286 -0
- package/dist/native/vendor/ui-lottie/index.ios.js +214 -0
- package/dist/native/vendor/ui-lottie/src/lottie/index.common.js +50 -0
- package/dist/native/vendor/ui-lottie/src/lottie/utils.js +6 -0
- package/dist/web/escape-props.web.js +17 -0
- package/dist/web/index.js +346 -0
- package/dist/web/layout-child.web.js +47 -0
- package/dist/web/octane-client-build.json +8 -0
- package/package.json +104 -11
- package/platforms/android/include.gradle +7 -0
- package/platforms/android/java/com/nativescript/lottie/LottieAnimationView.java +92 -0
- package/platforms/android/lottie.aar +0 -0
- package/platforms/android/native-api-usage.json +16 -0
- package/platforms/ios/Podfile +5 -0
- 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 +162 -0
- package/src/Lottie.web.tsrx +152 -0
- package/src/cx.mobile.ts +8 -0
- package/src/escape-props.ts +65 -0
- package/src/escape-props.web.ts +25 -0
- package/src/index.macos.ts +2 -0
- package/src/index.ts +2 -0
- package/src/index.web.ts +2 -0
- package/src/layout-child.ts +57 -0
- package/src/layout-child.web.ts +108 -0
- package/src/native-elements.d.ts +8 -0
- package/src/props.ts +133 -0
- package/src/references.d.ts +3 -0
- package/src/vendor/ui-lottie/LICENSE.md +21 -0
- package/src/vendor/ui-lottie/src/lottie/index.android.ts +447 -0
- package/src/vendor/ui-lottie/src/lottie/index.common.ts +84 -0
- package/src/vendor/ui-lottie/src/lottie/index.d.ts +133 -0
- package/src/vendor/ui-lottie/src/lottie/index.ios.ts +345 -0
- package/src/vendor/ui-lottie/src/lottie/typings/android.d.ts +4149 -0
- package/src/vendor/ui-lottie/src/lottie/typings/android.nativescript.d.ts +12 -0
- package/src/vendor/ui-lottie/src/lottie/typings/dotlottie.ios.d.ts +14 -0
- package/src/vendor/ui-lottie/src/lottie/typings/ios.d.ts +384 -0
- package/src/vendor/ui-lottie/src/lottie/utils.ts +9 -0
- package/types/generated/.tsrx-typegen-manifest.json +18 -0
- package/types/generated/Lottie.d.ts +7 -0
- package/types/generated/Lottie.web.d.ts +7 -0
- package/types/generated/cx.mobile.d.ts +6 -0
- package/types/generated/escape-props.d.ts +15 -0
- package/types/generated/escape-props.web.d.ts +5 -0
- package/types/generated/index.d.ts +2 -0
- package/types/generated/index.web.d.ts +2 -0
- package/types/generated/layout-child.d.ts +6 -0
- package/types/generated/layout-child.web.d.ts +15 -0
- package/types/generated/props.d.ts +110 -0
- package/types/generated/vendor/ui-lottie/src/lottie/index.common.d.ts +30 -0
- package/types/generated/vendor/ui-lottie/src/lottie/index.ios.d.ts +35 -0
- package/types/generated/vendor/ui-lottie/src/lottie/utils.d.ts +1 -0
- package/index.d.ts +0 -1
- package/index.js +0 -2
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MathKit.swift
|
|
3
|
+
// UIToolBox
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 10/10/18.
|
|
6
|
+
//
|
|
7
|
+
// From https://github.com/buba447/UIToolBox
|
|
8
|
+
|
|
9
|
+
import CoreGraphics
|
|
10
|
+
import Foundation
|
|
11
|
+
|
|
12
|
+
extension Int {
|
|
13
|
+
var cgFloat: CGFloat {
|
|
14
|
+
CGFloat(self)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
extension Double {
|
|
19
|
+
var cgFloat: CGFloat {
|
|
20
|
+
CGFloat(self)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// MARK: - CGFloat + Interpolatable
|
|
25
|
+
|
|
26
|
+
extension CGFloat {
|
|
27
|
+
|
|
28
|
+
func remap(fromLow: CGFloat, fromHigh: CGFloat, toLow: CGFloat, toHigh: CGFloat) -> CGFloat {
|
|
29
|
+
guard (fromHigh - fromLow) != 0 else {
|
|
30
|
+
// Would produce NAN
|
|
31
|
+
return 0
|
|
32
|
+
}
|
|
33
|
+
return toLow + (self - fromLow) * (toHigh - toLow) / (fromHigh - fromLow)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// Returns the difference between the receiver and the given number.
|
|
37
|
+
/// - Parameter absolute: If *true* (Default) the returned value will always be positive.
|
|
38
|
+
func diff(_ a: CGFloat, absolute: Bool = true) -> CGFloat {
|
|
39
|
+
absolute ? abs(a - self) : a - self
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func toRadians() -> CGFloat {
|
|
43
|
+
self * .pi / 180
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func toDegrees() -> CGFloat {
|
|
47
|
+
self * 180 / .pi
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// MARK: - Double
|
|
53
|
+
|
|
54
|
+
extension Double {
|
|
55
|
+
func remap(fromLow: Double, fromHigh: Double, toLow: Double, toHigh: Double) -> Double {
|
|
56
|
+
toLow + (self - fromLow) * (toHigh - toLow) / (fromHigh - fromLow)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
extension Numeric where Self: Comparable {
|
|
61
|
+
/// Returns a value that is clamped between the two numbers
|
|
62
|
+
///
|
|
63
|
+
/// 1. The order of arguments does not matter.
|
|
64
|
+
func clamp(_ a: Self, _ b: Self) -> Self {
|
|
65
|
+
let minValue = a <= b ? a : b
|
|
66
|
+
let maxValue = a <= b ? b : a
|
|
67
|
+
return max(min(self, maxValue), minValue)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
extension CGRect {
|
|
72
|
+
|
|
73
|
+
// MARK: Lifecycle
|
|
74
|
+
|
|
75
|
+
/// Initializes a new CGRect with a center point and size.
|
|
76
|
+
init(center: CGPoint, size: CGSize) {
|
|
77
|
+
self.init(
|
|
78
|
+
x: center.x - (size.width * 0.5),
|
|
79
|
+
y: center.y - (size.height * 0.5),
|
|
80
|
+
width: size.width,
|
|
81
|
+
height: size.height
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// MARK: Internal
|
|
86
|
+
|
|
87
|
+
/// Returns the total area of the rect.
|
|
88
|
+
var area: CGFloat {
|
|
89
|
+
width * height
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// The center point of the rect. Settable.
|
|
93
|
+
var center: CGPoint {
|
|
94
|
+
get {
|
|
95
|
+
CGPoint(x: midX, y: midY)
|
|
96
|
+
}
|
|
97
|
+
set {
|
|
98
|
+
origin = CGPoint(
|
|
99
|
+
x: newValue.x - (size.width * 0.5),
|
|
100
|
+
y: newValue.y - (size.height * 0.5)
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// The top left point of the rect. Settable.
|
|
106
|
+
var topLeft: CGPoint {
|
|
107
|
+
get {
|
|
108
|
+
CGPoint(x: minX, y: minY)
|
|
109
|
+
}
|
|
110
|
+
set {
|
|
111
|
+
origin = CGPoint(
|
|
112
|
+
x: newValue.x,
|
|
113
|
+
y: newValue.y
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// The bottom left point of the rect. Settable.
|
|
119
|
+
var bottomLeft: CGPoint {
|
|
120
|
+
get {
|
|
121
|
+
CGPoint(x: minX, y: maxY)
|
|
122
|
+
}
|
|
123
|
+
set {
|
|
124
|
+
origin = CGPoint(
|
|
125
|
+
x: newValue.x,
|
|
126
|
+
y: newValue.y - size.height
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// The top right point of the rect. Settable.
|
|
132
|
+
var topRight: CGPoint {
|
|
133
|
+
get {
|
|
134
|
+
CGPoint(x: maxX, y: minY)
|
|
135
|
+
}
|
|
136
|
+
set {
|
|
137
|
+
origin = CGPoint(
|
|
138
|
+
x: newValue.x - size.width,
|
|
139
|
+
y: newValue.y
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/// The bottom right point of the rect. Settable.
|
|
145
|
+
var bottomRight: CGPoint {
|
|
146
|
+
get {
|
|
147
|
+
CGPoint(x: maxX, y: maxY)
|
|
148
|
+
}
|
|
149
|
+
set {
|
|
150
|
+
origin = CGPoint(
|
|
151
|
+
x: newValue.x - size.width,
|
|
152
|
+
y: newValue.y - size.height
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
extension CGSize {
|
|
160
|
+
|
|
161
|
+
/// Operator convenience to add sizes with +
|
|
162
|
+
static func +(left: CGSize, right: CGSize) -> CGSize {
|
|
163
|
+
left.add(right)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/// Operator convenience to subtract sizes with -
|
|
167
|
+
static func -(left: CGSize, right: CGSize) -> CGSize {
|
|
168
|
+
left.subtract(right)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/// Operator convenience to multiply sizes with *
|
|
172
|
+
static func *(left: CGSize, right: CGFloat) -> CGSize {
|
|
173
|
+
CGSize(width: left.width * right, height: left.height * right)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/// Returns the scale float that will fit the receive inside of the given size.
|
|
177
|
+
func scaleThatFits(_ size: CGSize) -> CGFloat {
|
|
178
|
+
CGFloat.minimum(width / size.width, height / size.height)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/// Adds receiver size to give size.
|
|
182
|
+
func add(_ size: CGSize) -> CGSize {
|
|
183
|
+
CGSize(width: width + size.width, height: height + size.height)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/// Subtracts given size from receiver size.
|
|
187
|
+
func subtract(_ size: CGSize) -> CGSize {
|
|
188
|
+
CGSize(width: width - size.width, height: height - size.height)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/// Multiplies receiver size by the given size.
|
|
192
|
+
func multiply(_ size: CGSize) -> CGSize {
|
|
193
|
+
CGSize(width: width * size.width, height: height * size.height)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// MARK: - CGLine
|
|
198
|
+
|
|
199
|
+
/// A struct that defines a line segment with two CGPoints
|
|
200
|
+
struct CGLine {
|
|
201
|
+
|
|
202
|
+
// MARK: Lifecycle
|
|
203
|
+
|
|
204
|
+
/// Initializes a line segment with start and end points
|
|
205
|
+
init(start: CGPoint, end: CGPoint) {
|
|
206
|
+
self.start = start
|
|
207
|
+
self.end = end
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// MARK: Internal
|
|
211
|
+
|
|
212
|
+
/// The Start of the line segment.
|
|
213
|
+
var start: CGPoint
|
|
214
|
+
/// The End of the line segment.
|
|
215
|
+
var end: CGPoint
|
|
216
|
+
|
|
217
|
+
/// The length of the line segment.
|
|
218
|
+
var length: CGFloat {
|
|
219
|
+
end.distanceTo(start)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/// Returns a line segment that is normalized to a length of 1
|
|
223
|
+
func normalize() -> CGLine {
|
|
224
|
+
let len = length
|
|
225
|
+
guard len > 0 else {
|
|
226
|
+
return self
|
|
227
|
+
}
|
|
228
|
+
let relativeEnd = end - start
|
|
229
|
+
let relativeVector = CGPoint(x: relativeEnd.x / len, y: relativeEnd.y / len)
|
|
230
|
+
let absoluteVector = relativeVector + start
|
|
231
|
+
return CGLine(start: start, end: absoluteVector)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/// Trims a line segment to the given length
|
|
235
|
+
func trimmedToLength(_ toLength: CGFloat) -> CGLine {
|
|
236
|
+
let len = length
|
|
237
|
+
guard len > 0 else {
|
|
238
|
+
return self
|
|
239
|
+
}
|
|
240
|
+
let relativeEnd = end - start
|
|
241
|
+
let relativeVector = CGPoint(x: relativeEnd.x / len, y: relativeEnd.y / len)
|
|
242
|
+
let sizedVector = CGPoint(x: relativeVector.x * toLength, y: relativeVector.y * toLength)
|
|
243
|
+
let absoluteVector = sizedVector + start
|
|
244
|
+
return CGLine(start: start, end: absoluteVector)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/// Flips a line vertically and horizontally from the start point.
|
|
248
|
+
func flipped() -> CGLine {
|
|
249
|
+
let relativeEnd = end - start
|
|
250
|
+
let flippedEnd = CGPoint(x: relativeEnd.x * -1, y: relativeEnd.y * -1)
|
|
251
|
+
return CGLine(start: start, end: flippedEnd + start)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/// Move the line to the new start point.
|
|
255
|
+
func transpose(_ toPoint: CGPoint) -> CGLine {
|
|
256
|
+
let diff = toPoint - start
|
|
257
|
+
let newEnd = end + diff
|
|
258
|
+
return CGLine(start: toPoint, end: newEnd)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
infix operator +|
|
|
264
|
+
infix operator +-
|
|
265
|
+
|
|
266
|
+
extension CGPoint {
|
|
267
|
+
|
|
268
|
+
/// Returns the length between the receiver and *CGPoint.zero*
|
|
269
|
+
var vectorLength: CGFloat {
|
|
270
|
+
distanceTo(.zero)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
var isZero: Bool {
|
|
274
|
+
x == 0 && y == 0
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/// Operator convenience to divide points with /
|
|
278
|
+
static func /(lhs: CGPoint, rhs: CGFloat) -> CGPoint {
|
|
279
|
+
CGPoint(x: lhs.x / rhs, y: lhs.y / rhs)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/// Operator convenience to multiply points with *
|
|
283
|
+
static func *(lhs: CGPoint, rhs: CGFloat) -> CGPoint {
|
|
284
|
+
CGPoint(x: lhs.x * rhs, y: lhs.y * rhs)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/// Operator convenience to add points with +
|
|
288
|
+
static func +(left: CGPoint, right: CGPoint) -> CGPoint {
|
|
289
|
+
left.add(right)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/// Operator convenience to subtract points with -
|
|
293
|
+
static func -(left: CGPoint, right: CGPoint) -> CGPoint {
|
|
294
|
+
left.subtract(right)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
static func +|(left: CGPoint, right: CGFloat) -> CGPoint {
|
|
298
|
+
CGPoint(x: left.x, y: left.y + right)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
static func +-(left: CGPoint, right: CGFloat) -> CGPoint {
|
|
302
|
+
CGPoint(x: left.x + right, y: left.y)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/// Returns the distance between the receiver and the given point.
|
|
306
|
+
func distanceTo(_ a: CGPoint) -> CGFloat {
|
|
307
|
+
let xDist = a.x - x
|
|
308
|
+
let yDist = a.y - y
|
|
309
|
+
return CGFloat(sqrt((xDist * xDist) + (yDist * yDist)))
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
func rounded(decimal: CGFloat) -> CGPoint {
|
|
313
|
+
CGPoint(x: round(decimal * x) / decimal, y: round(decimal * y) / decimal)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
func interpolate(
|
|
317
|
+
_ to: CGPoint,
|
|
318
|
+
outTangent: CGPoint,
|
|
319
|
+
inTangent: CGPoint,
|
|
320
|
+
amount: CGFloat,
|
|
321
|
+
maxIterations: Int = 3,
|
|
322
|
+
samples: Int = 20,
|
|
323
|
+
accuracy: CGFloat = 1
|
|
324
|
+
) -> CGPoint {
|
|
325
|
+
if amount == 0 {
|
|
326
|
+
return self
|
|
327
|
+
}
|
|
328
|
+
if amount == 1 {
|
|
329
|
+
return to
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if
|
|
333
|
+
colinear(outTangent, inTangent) == true,
|
|
334
|
+
outTangent.colinear(inTangent, to) == true
|
|
335
|
+
{
|
|
336
|
+
return interpolate(to: to, amount: amount)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
let step = 1 / CGFloat(samples)
|
|
340
|
+
|
|
341
|
+
var points: [(point: CGPoint, distance: CGFloat)] = [(point: self, distance: 0)]
|
|
342
|
+
var totalLength: CGFloat = 0
|
|
343
|
+
|
|
344
|
+
var previousPoint = self
|
|
345
|
+
var previousAmount = CGFloat(0)
|
|
346
|
+
|
|
347
|
+
var closestPoint = 0
|
|
348
|
+
|
|
349
|
+
while previousAmount < 1 {
|
|
350
|
+
previousAmount = previousAmount + step
|
|
351
|
+
|
|
352
|
+
if previousAmount < amount {
|
|
353
|
+
closestPoint = closestPoint + 1
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
let newPoint = pointOnPath(to, outTangent: outTangent, inTangent: inTangent, amount: previousAmount)
|
|
357
|
+
let distance = previousPoint.distanceTo(newPoint)
|
|
358
|
+
totalLength = totalLength + distance
|
|
359
|
+
points.append((point: newPoint, distance: totalLength))
|
|
360
|
+
previousPoint = newPoint
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
let accurateDistance = amount * totalLength
|
|
364
|
+
var point = points[closestPoint]
|
|
365
|
+
|
|
366
|
+
var foundPoint = false
|
|
367
|
+
|
|
368
|
+
var pointAmount = CGFloat(closestPoint) * step
|
|
369
|
+
var nextPointAmount: CGFloat = pointAmount + step
|
|
370
|
+
|
|
371
|
+
var refineIterations = 0
|
|
372
|
+
while foundPoint == false {
|
|
373
|
+
refineIterations = refineIterations + 1
|
|
374
|
+
/// First see if the next point is still less than the projected length.
|
|
375
|
+
let nextPoint = points[min(closestPoint + 1, points.indices.last!)]
|
|
376
|
+
if nextPoint.distance < accurateDistance {
|
|
377
|
+
point = nextPoint
|
|
378
|
+
closestPoint = closestPoint + 1
|
|
379
|
+
pointAmount = CGFloat(closestPoint) * step
|
|
380
|
+
nextPointAmount = pointAmount + step
|
|
381
|
+
if closestPoint == points.count {
|
|
382
|
+
foundPoint = true
|
|
383
|
+
}
|
|
384
|
+
continue
|
|
385
|
+
}
|
|
386
|
+
if accurateDistance < point.distance {
|
|
387
|
+
closestPoint = closestPoint - 1
|
|
388
|
+
if closestPoint < 0 {
|
|
389
|
+
foundPoint = true
|
|
390
|
+
continue
|
|
391
|
+
}
|
|
392
|
+
point = points[closestPoint]
|
|
393
|
+
pointAmount = CGFloat(closestPoint) * step
|
|
394
|
+
nextPointAmount = pointAmount + step
|
|
395
|
+
continue
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/// Now we are certain the point is the closest point under the distance
|
|
399
|
+
let pointDiff = nextPoint.distance - point.distance
|
|
400
|
+
let proposedPointAmount = ((accurateDistance - point.distance) / pointDiff)
|
|
401
|
+
.remap(fromLow: 0, fromHigh: 1, toLow: pointAmount, toHigh: nextPointAmount)
|
|
402
|
+
|
|
403
|
+
let newPoint = pointOnPath(to, outTangent: outTangent, inTangent: inTangent, amount: proposedPointAmount)
|
|
404
|
+
let newDistance = point.distance + point.point.distanceTo(newPoint)
|
|
405
|
+
pointAmount = proposedPointAmount
|
|
406
|
+
point = (point: newPoint, distance: newDistance)
|
|
407
|
+
if
|
|
408
|
+
accurateDistance - newDistance <= accuracy ||
|
|
409
|
+
newDistance - accurateDistance <= accuracy
|
|
410
|
+
{
|
|
411
|
+
foundPoint = true
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if refineIterations == maxIterations {
|
|
415
|
+
foundPoint = true
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return point.point
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
func pointOnPath(_ to: CGPoint, outTangent: CGPoint, inTangent: CGPoint, amount: CGFloat) -> CGPoint {
|
|
422
|
+
let a = interpolate(to: outTangent, amount: amount)
|
|
423
|
+
let b = outTangent.interpolate(to: inTangent, amount: amount)
|
|
424
|
+
let c = inTangent.interpolate(to: to, amount: amount)
|
|
425
|
+
let d = a.interpolate(to: b, amount: amount)
|
|
426
|
+
let e = b.interpolate(to: c, amount: amount)
|
|
427
|
+
return d.interpolate(to: e, amount: amount)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
func colinear(_ a: CGPoint, _ b: CGPoint) -> Bool {
|
|
431
|
+
let area = x * (a.y - b.y) + a.x * (b.y - y) + b.x * (y - a.y)
|
|
432
|
+
let accuracy: CGFloat = 0.05
|
|
433
|
+
if area < accuracy, area > -accuracy {
|
|
434
|
+
return true
|
|
435
|
+
}
|
|
436
|
+
return false
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/// Subtracts the given point from the receiving point.
|
|
440
|
+
func subtract(_ point: CGPoint) -> CGPoint {
|
|
441
|
+
CGPoint(
|
|
442
|
+
x: x - point.x,
|
|
443
|
+
y: y - point.y
|
|
444
|
+
)
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/// Adds the given point from the receiving point.
|
|
448
|
+
func add(_ point: CGPoint) -> CGPoint {
|
|
449
|
+
CGPoint(
|
|
450
|
+
x: x + point.x,
|
|
451
|
+
y: y + point.y
|
|
452
|
+
)
|
|
453
|
+
}
|
|
454
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// StringExtensions.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 String {
|
|
12
|
+
|
|
13
|
+
var cgColor: CGColor {
|
|
14
|
+
let (red, green, blue) = hexColorComponents()
|
|
15
|
+
return .rgb(red, green, blue)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var lottieColor: LottieColor {
|
|
19
|
+
let (red, green, blue) = hexColorComponents()
|
|
20
|
+
return .init(r: red, g: green, b: blue, a: 1.0)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func hexColorComponents() -> (red: CGFloat, green: CGFloat, blue: CGFloat) {
|
|
24
|
+
var cString: String = trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
|
|
25
|
+
|
|
26
|
+
if cString.hasPrefix("#") {
|
|
27
|
+
cString.remove(at: cString.startIndex)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (cString.count) != 6 {
|
|
31
|
+
return (red: 0, green: 0, blue: 0)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var rgbValue: UInt64 = 0
|
|
35
|
+
Scanner(string: cString).scanHexInt64(&rgbValue)
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
|
|
39
|
+
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
|
|
40
|
+
blue: CGFloat(rgbValue & 0x0000FF) / 255.0
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AnimationContext.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 2/1/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import QuartzCore
|
|
10
|
+
|
|
11
|
+
/// A completion block for animations.
|
|
12
|
+
/// - `true` is passed in if the animation completed playing.
|
|
13
|
+
/// - `false` is passed in if the animation was interrupted and did not complete playing.
|
|
14
|
+
public typealias LottieCompletionBlock = (_ completed: Bool) -> Void
|
|
15
|
+
|
|
16
|
+
// MARK: - AnimationContext
|
|
17
|
+
|
|
18
|
+
struct AnimationContext {
|
|
19
|
+
|
|
20
|
+
init(
|
|
21
|
+
playFrom: AnimationFrameTime,
|
|
22
|
+
playTo: AnimationFrameTime,
|
|
23
|
+
framerate: Double,
|
|
24
|
+
closure: LottieCompletionBlock?
|
|
25
|
+
) {
|
|
26
|
+
self.playTo = playTo
|
|
27
|
+
self.playFrom = playFrom
|
|
28
|
+
self.framerate = framerate
|
|
29
|
+
self.closure = AnimationCompletionDelegate(completionBlock: closure)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var playFrom: AnimationFrameTime
|
|
33
|
+
var playTo: AnimationFrameTime
|
|
34
|
+
var framerate: Double
|
|
35
|
+
var closure: AnimationCompletionDelegate
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// MARK: Equatable
|
|
40
|
+
|
|
41
|
+
extension AnimationContext: Equatable {
|
|
42
|
+
/// Whether or not the two given `AnimationContext`s are functionally equivalent
|
|
43
|
+
/// - This checks whether or not a completion handler was provided,
|
|
44
|
+
/// but does not check whether or not the two completion handlers are equivalent.
|
|
45
|
+
static func ==(_ lhs: AnimationContext, _ rhs: AnimationContext) -> Bool {
|
|
46
|
+
lhs.playTo == rhs.playTo
|
|
47
|
+
&& lhs.playFrom == rhs.playFrom
|
|
48
|
+
&& lhs.framerate == rhs.framerate
|
|
49
|
+
&& (lhs.closure.completionBlock == nil) == (rhs.closure.completionBlock == nil)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// MARK: - AnimationContextState
|
|
54
|
+
|
|
55
|
+
enum AnimationContextState {
|
|
56
|
+
case playing
|
|
57
|
+
case cancelled
|
|
58
|
+
case complete
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// MARK: - AnimationCompletionDelegate
|
|
62
|
+
|
|
63
|
+
final class AnimationCompletionDelegate: NSObject, CAAnimationDelegate {
|
|
64
|
+
|
|
65
|
+
// MARK: Lifecycle
|
|
66
|
+
|
|
67
|
+
init(completionBlock: LottieCompletionBlock?) {
|
|
68
|
+
self.completionBlock = completionBlock
|
|
69
|
+
super.init()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// MARK: Internal
|
|
73
|
+
|
|
74
|
+
var animationLayer: RootAnimationLayer?
|
|
75
|
+
var animationKey: String?
|
|
76
|
+
var ignoreDelegate = false
|
|
77
|
+
var animationState = AnimationContextState.playing
|
|
78
|
+
|
|
79
|
+
let completionBlock: LottieCompletionBlock?
|
|
80
|
+
|
|
81
|
+
func animationDidStop(_ anim: CAAnimation, finished flag: Bool) {
|
|
82
|
+
guard ignoreDelegate == false else { return }
|
|
83
|
+
animationState = flag ? .complete : .cancelled
|
|
84
|
+
if let animationLayer, let key = animationKey {
|
|
85
|
+
animationLayer.removeAnimation(forKey: key)
|
|
86
|
+
if flag {
|
|
87
|
+
animationLayer.currentFrame = (anim as! CABasicAnimation).toValue as! CGFloat
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if let completionBlock {
|
|
91
|
+
completionBlock(flag)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Created by miguel_jimenez on 8/2/23.
|
|
2
|
+
// Copyright © 2023 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
// MARK: - AnyEquatable
|
|
5
|
+
|
|
6
|
+
struct AnyEquatable {
|
|
7
|
+
init<T: Equatable>(_ value: T) {
|
|
8
|
+
self.value = value
|
|
9
|
+
equals = { $0 as? T == value }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private let value: Any
|
|
13
|
+
private let equals: (Any) -> Bool
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// MARK: Equatable
|
|
18
|
+
|
|
19
|
+
extension AnyEquatable: Equatable {
|
|
20
|
+
static func ==(lhs: AnyEquatable, rhs: AnyEquatable) -> Bool {
|
|
21
|
+
lhs.equals(rhs.value)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Created by miguel_jimenez on 7/27/23.
|
|
2
|
+
// Copyright © 2023 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
#if canImport(SwiftUI)
|
|
5
|
+
import SwiftUI
|
|
6
|
+
|
|
7
|
+
extension Binding {
|
|
8
|
+
|
|
9
|
+
/// Helper to transform a `Binding` from one `Value` type to another.
|
|
10
|
+
func map<Transformed>(transform: @escaping (Value) -> Transformed) -> Binding<Transformed> {
|
|
11
|
+
.init {
|
|
12
|
+
transform(wrappedValue)
|
|
13
|
+
} set: { newValue in
|
|
14
|
+
guard let newValue = newValue as? Value else { return }
|
|
15
|
+
self.wrappedValue = newValue
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
#endif
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Created by miguel_jimenez on 7/26/23.
|
|
2
|
+
// Copyright © 2023 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
#if canImport(Combine) && canImport(SwiftUI)
|
|
5
|
+
import Combine
|
|
6
|
+
import SwiftUI
|
|
7
|
+
|
|
8
|
+
extension View {
|
|
9
|
+
/// A backwards compatible wrapper for iOS 14 `onChange`
|
|
10
|
+
@ViewBuilder
|
|
11
|
+
func valueChanged<T: Equatable>(value: T, onChange: @escaping (T) -> Void) -> some View {
|
|
12
|
+
#if compiler(>=5.9)
|
|
13
|
+
if #available(iOS 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, *) {
|
|
14
|
+
self.onChange(of: value) { _, newValue in
|
|
15
|
+
onChange(newValue)
|
|
16
|
+
}
|
|
17
|
+
} else if #available(iOS 14.0, macOS 11.0, tvOS 14.0, *) {
|
|
18
|
+
self.onChange(of: value, perform: onChange)
|
|
19
|
+
} else {
|
|
20
|
+
onReceive(Just(value)) { value in
|
|
21
|
+
onChange(value)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
#else
|
|
25
|
+
if #available(iOS 14.0, macOS 11.0, tvOS 14.0, *) {
|
|
26
|
+
self.onChange(of: value, perform: onChange)
|
|
27
|
+
} else {
|
|
28
|
+
onReceive(Just(value)) { value in
|
|
29
|
+
onChange(value)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
#endif
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
#endif
|