@amazon-devices/lottie-react-native 2.0.1758683737
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/LICENSE +7 -0
- package/SystemBundles/90296ccfe5ff2db2f9fe68a18eca092f8b7c17d1125cfafc612d18788fe9bce6.bundle +10322 -0
- package/SystemBundles/90296ccfe5ff2db2f9fe68a18eca092f8b7c17d1125cfafc612d18788fe9bce6.map +1 -0
- package/SystemModules/amzn__lottie-react-native-2.modules.txt +13 -0
- package/SystemModules/amzn__lottie-react-native-2.private.modules.txt +92 -0
- package/SystemModules/keplerscript-system-bundle-config.json +7 -0
- package/THIRD_PARTY_NOTICES.txt +640 -0
- package/android/build.gradle +120 -0
- package/android/gradle.properties +27 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewManagerImpl.kt +260 -0
- package/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewPropertyManager.kt +156 -0
- package/android/src/main/java/com/airbnb/android/react/lottie/LottiePackage.kt +18 -0
- package/android/src/newarch/com/airbnb/android/react/lottie/LottieAnimationViewManager.kt +219 -0
- package/android/src/oldarch/com/airbnb/android/react/lottie/LottieAnimationViewManager.kt +187 -0
- package/ios/Fabric/LottieAnimationViewComponentView.h +28 -0
- package/ios/Fabric/LottieAnimationViewComponentView.mm +140 -0
- package/ios/Fabric/LottieContainerView.h +33 -0
- package/ios/Fabric/RNLottieFabricConversions.h +29 -0
- package/ios/LottieReactNative/AnimationViewManagerModule.swift +88 -0
- package/ios/LottieReactNative/Bridging.h +4 -0
- package/ios/LottieReactNative/ContainerView.swift +281 -0
- package/ios/LottieReactNative/LRNAnimationViewManagerObjC.m +25 -0
- package/ios/LottieReactNative/PlatformColor.swift +31 -0
- package/ios/LottieReactNative/RCTConvert+Lottie.h +7 -0
- package/ios/LottieReactNative/RCTConvert+Lottie.m +24 -0
- package/ios/LottieReactNative.xcodeproj/project.pbxproj +449 -0
- package/ios/LottieReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/LottieReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/kepler-compatibility.json +8 -0
- package/kepler-transformed-package-info.json +3 -0
- package/lib/commonjs/LottieView.js +207 -0
- package/lib/commonjs/LottieView.js.map +1 -0
- package/lib/commonjs/LottieView.types.js +6 -0
- package/lib/commonjs/LottieView.types.js.map +1 -0
- package/lib/commonjs/index.js +9 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/specs/LottieAnimationViewNativeComponent.js +97 -0
- package/lib/commonjs/specs/LottieAnimationViewNativeComponent.js.map +1 -0
- package/lib/module/LottieView.js +201 -0
- package/lib/module/LottieView.js.map +1 -0
- package/lib/module/LottieView.types.js +2 -0
- package/lib/module/LottieView.types.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/LottieAnimationViewNativeComponent.js +91 -0
- package/lib/module/specs/LottieAnimationViewNativeComponent.js.map +1 -0
- package/lib/typescript/LottieView.d.ts +27 -0
- package/lib/typescript/LottieView.types.d.ts +206 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/specs/LottieAnimationViewNativeComponent.d.ts +61 -0
- package/lottie-react-native.podspec +44 -0
- package/package.json +1 -0
- package/react-native.config.js +32 -0
- package/src/LottieView.tsx +257 -0
- package/src/LottieView.types.ts +275 -0
- package/src/__tests__/__snapshots__/validate-public-api.test.js.snap +248 -0
- package/src/__tests__/validate-public-api.test.js +33 -0
- package/src/index.tsx +2 -0
- package/src/specs/LottieAnimationViewNativeComponent.ts +170 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
package com.airbnb.android.react.lottie
|
|
2
|
+
|
|
3
|
+
import android.animation.Animator
|
|
4
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setColorFilters
|
|
5
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setEnableMergePaths
|
|
6
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setHardwareAcceleration
|
|
7
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setImageAssetsFolder
|
|
8
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setLoop
|
|
9
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setProgress
|
|
10
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setRenderMode
|
|
11
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setResizeMode
|
|
12
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSourceJson
|
|
13
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSourceName
|
|
14
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSourceURL
|
|
15
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSpeed
|
|
16
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setTextFilters
|
|
17
|
+
import com.airbnb.lottie.LottieAnimationView
|
|
18
|
+
import com.facebook.react.bridge.Arguments
|
|
19
|
+
import com.facebook.react.bridge.ReadableArray
|
|
20
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
22
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
23
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
24
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
25
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
26
|
+
import com.facebook.react.uimanager.events.RCTModernEventEmitter
|
|
27
|
+
import com.facebook.react.viewmanagers.LottieAnimationViewManagerDelegate
|
|
28
|
+
import com.facebook.react.viewmanagers.LottieAnimationViewManagerInterface
|
|
29
|
+
import java.util.*
|
|
30
|
+
|
|
31
|
+
@ReactModule(name = LottieAnimationViewManagerImpl.REACT_CLASS)
|
|
32
|
+
class LottieAnimationViewManager : SimpleViewManager<LottieAnimationView>(),
|
|
33
|
+
LottieAnimationViewManagerInterface<LottieAnimationView> {
|
|
34
|
+
private val propManagersMap =
|
|
35
|
+
WeakHashMap<LottieAnimationView, LottieAnimationViewPropertyManager>()
|
|
36
|
+
private val delegate: ViewManagerDelegate<LottieAnimationView>
|
|
37
|
+
|
|
38
|
+
init {
|
|
39
|
+
delegate = LottieAnimationViewManagerDelegate(this)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private fun getOrCreatePropertyManager(view: LottieAnimationView): LottieAnimationViewPropertyManager {
|
|
43
|
+
var result = propManagersMap[view]
|
|
44
|
+
if (result == null) {
|
|
45
|
+
result = LottieAnimationViewPropertyManager(view)
|
|
46
|
+
propManagersMap[view] = result
|
|
47
|
+
}
|
|
48
|
+
return result
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private fun sendOnAnimationFinishEvent(view: LottieAnimationView, isCancelled: Boolean) {
|
|
52
|
+
val event = Arguments.createMap()
|
|
53
|
+
event.putBoolean("isCancelled", isCancelled)
|
|
54
|
+
|
|
55
|
+
val screenContext = view.context
|
|
56
|
+
if (screenContext is ThemedReactContext) {
|
|
57
|
+
screenContext.getJSModule(RCTModernEventEmitter::class.java)
|
|
58
|
+
?.receiveEvent(
|
|
59
|
+
screenContext.surfaceId,
|
|
60
|
+
view.id,
|
|
61
|
+
"animationFinish",
|
|
62
|
+
event
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
override fun getDelegate(): ViewManagerDelegate<LottieAnimationView> {
|
|
68
|
+
return delegate
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
override fun getExportedViewConstants(): Map<String, Any> {
|
|
72
|
+
return LottieAnimationViewManagerImpl.exportedViewConstants
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun getName(): String {
|
|
76
|
+
return LottieAnimationViewManagerImpl.REACT_CLASS
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public override fun createViewInstance(context: ThemedReactContext): LottieAnimationView {
|
|
80
|
+
val view = LottieAnimationViewManagerImpl.createViewInstance(context)
|
|
81
|
+
view.addAnimatorListener(object : Animator.AnimatorListener {
|
|
82
|
+
override fun onAnimationStart(animation: Animator) {
|
|
83
|
+
//do nothing
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
override fun onAnimationEnd(animation: Animator) {
|
|
87
|
+
sendOnAnimationFinishEvent(view, false)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
override fun onAnimationCancel(animation: Animator) {
|
|
91
|
+
sendOnAnimationFinishEvent(view, true)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
override fun onAnimationRepeat(animation: Animator) {
|
|
95
|
+
//do nothing
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
return view
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
|
102
|
+
return LottieAnimationViewManagerImpl.getExportedCustomBubblingEventTypeConstants()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
override fun onAfterUpdateTransaction(view: LottieAnimationView) {
|
|
106
|
+
super.onAfterUpdateTransaction(view)
|
|
107
|
+
getOrCreatePropertyManager(view).commitChanges()
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
override fun receiveCommand(
|
|
111
|
+
root: LottieAnimationView,
|
|
112
|
+
commandId: String,
|
|
113
|
+
args: ReadableArray?
|
|
114
|
+
) {
|
|
115
|
+
delegate.receiveCommand(root, commandId, args)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
override fun play(view: LottieAnimationView, startFrame: Int, endFrame: Int) {
|
|
119
|
+
LottieAnimationViewManagerImpl.play(view, startFrame, endFrame)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
override fun reset(view: LottieAnimationView) {
|
|
123
|
+
LottieAnimationViewManagerImpl.reset(view)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
override fun pause(view: LottieAnimationView) {
|
|
127
|
+
LottieAnimationViewManagerImpl.pause(view)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
override fun resume(view: LottieAnimationView) {
|
|
131
|
+
LottieAnimationViewManagerImpl.resume(view)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@ReactProp(name = "sourceName")
|
|
135
|
+
override fun setSourceName(view: LottieAnimationView, name: String?) {
|
|
136
|
+
setSourceName(name, getOrCreatePropertyManager(view))
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@ReactProp(name = "sourceJson")
|
|
140
|
+
override fun setSourceJson(view: LottieAnimationView, json: String?) {
|
|
141
|
+
setSourceJson(json, getOrCreatePropertyManager(view))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@ReactProp(name = "sourceURL")
|
|
145
|
+
override fun setSourceURL(view: LottieAnimationView, urlString: String?) {
|
|
146
|
+
setSourceURL(urlString, getOrCreatePropertyManager(view))
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@ReactProp(name = "cacheComposition")
|
|
150
|
+
override fun setCacheComposition(view: LottieAnimationView, cacheComposition: Boolean) {
|
|
151
|
+
LottieAnimationViewManagerImpl.setCacheComposition(view, cacheComposition)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@ReactProp(name = "resizeMode")
|
|
155
|
+
override fun setResizeMode(view: LottieAnimationView, resizeMode: String?) {
|
|
156
|
+
setResizeMode(resizeMode, getOrCreatePropertyManager(view))
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@ReactProp(name = "renderMode")
|
|
160
|
+
override fun setRenderMode(view: LottieAnimationView, renderMode: String?) {
|
|
161
|
+
setRenderMode(renderMode, getOrCreatePropertyManager(view))
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@ReactProp(name = "progress")
|
|
165
|
+
override fun setProgress(view: LottieAnimationView, progress: Float) {
|
|
166
|
+
setProgress(progress, getOrCreatePropertyManager(view))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@ReactProp(name = "speed")
|
|
170
|
+
override fun setSpeed(view: LottieAnimationView, speed: Double) {
|
|
171
|
+
setSpeed(speed, getOrCreatePropertyManager(view))
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@ReactProp(name = "loop")
|
|
175
|
+
override fun setLoop(view: LottieAnimationView, loop: Boolean) {
|
|
176
|
+
setLoop(loop, getOrCreatePropertyManager(view))
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
@ReactProp(name = "imageAssetsFolder")
|
|
180
|
+
override fun setImageAssetsFolder(view: LottieAnimationView, imageAssetsFolder: String?) {
|
|
181
|
+
setImageAssetsFolder(imageAssetsFolder, getOrCreatePropertyManager(view))
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@ReactProp(name = "enableMergePathsAndroidForKitKatAndAbove")
|
|
185
|
+
override fun setEnableMergePathsAndroidForKitKatAndAbove(
|
|
186
|
+
view: LottieAnimationView,
|
|
187
|
+
enableMergePaths: Boolean
|
|
188
|
+
) {
|
|
189
|
+
setEnableMergePaths(enableMergePaths, getOrCreatePropertyManager(view))
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@ReactProp(name = "hardwareAccelerationAndroid")
|
|
193
|
+
override fun setHardwareAccelerationAndroid(
|
|
194
|
+
view: LottieAnimationView,
|
|
195
|
+
hardwareAccelerationAndroid: Boolean
|
|
196
|
+
) {
|
|
197
|
+
setHardwareAcceleration(hardwareAccelerationAndroid, getOrCreatePropertyManager(view))
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@ReactProp(name = "colorFilters")
|
|
201
|
+
override fun setColorFilters(view: LottieAnimationView, colorFilters: ReadableArray?) {
|
|
202
|
+
setColorFilters(colorFilters, getOrCreatePropertyManager(view))
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
@ReactProp(name = "textFiltersAndroid")
|
|
206
|
+
override fun setTextFiltersAndroid(view: LottieAnimationView, textFilters: ReadableArray?) {
|
|
207
|
+
setTextFilters(textFilters, getOrCreatePropertyManager(view))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// this props is not available on Android, however we must override the setter
|
|
211
|
+
override fun setTextFiltersIOS(view: LottieAnimationView?, value: ReadableArray?) {
|
|
212
|
+
//ignore - do nothing here
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Only here to solve an iOS issue with codegen. Check dummy prop in LottieAnimationViewNativeComponent.ts
|
|
216
|
+
override fun setDummy(view: LottieAnimationView, value: ReadableMap?) {
|
|
217
|
+
//ignore - do nothing here
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
@file:Suppress("unused", "DEPRECATION")
|
|
2
|
+
|
|
3
|
+
package com.airbnb.android.react.lottie
|
|
4
|
+
|
|
5
|
+
import android.animation.Animator
|
|
6
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.pause
|
|
7
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.play
|
|
8
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.reset
|
|
9
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.resume
|
|
10
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setColorFilters
|
|
11
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setEnableMergePaths
|
|
12
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setHardwareAcceleration
|
|
13
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setImageAssetsFolder
|
|
14
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setLoop
|
|
15
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setProgress
|
|
16
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setRenderMode
|
|
17
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setResizeMode
|
|
18
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSourceJson
|
|
19
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSourceName
|
|
20
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSourceURL
|
|
21
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSpeed
|
|
22
|
+
import com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setTextFilters
|
|
23
|
+
import com.airbnb.lottie.LottieAnimationView
|
|
24
|
+
import com.facebook.react.bridge.Arguments
|
|
25
|
+
import com.facebook.react.bridge.ReadableArray
|
|
26
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
27
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
28
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
29
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
30
|
+
import java.util.*
|
|
31
|
+
|
|
32
|
+
class LottieAnimationViewManager : SimpleViewManager<LottieAnimationView>() {
|
|
33
|
+
private val propManagersMap =
|
|
34
|
+
WeakHashMap<LottieAnimationView, LottieAnimationViewPropertyManager>()
|
|
35
|
+
|
|
36
|
+
private fun getOrCreatePropertyManager(view: LottieAnimationView): LottieAnimationViewPropertyManager {
|
|
37
|
+
var result = propManagersMap[view]
|
|
38
|
+
if (result == null) {
|
|
39
|
+
result = LottieAnimationViewPropertyManager(view)
|
|
40
|
+
propManagersMap[view] = result
|
|
41
|
+
}
|
|
42
|
+
return result
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private fun sendOnAnimationFinishEvent(view: LottieAnimationView, isCancelled: Boolean) {
|
|
46
|
+
val event = Arguments.createMap()
|
|
47
|
+
event.putBoolean("isCancelled", isCancelled)
|
|
48
|
+
|
|
49
|
+
val screenContext = view.context
|
|
50
|
+
if (screenContext is ThemedReactContext) {
|
|
51
|
+
screenContext.getJSModule(RCTEventEmitter::class.java)
|
|
52
|
+
?.receiveEvent(
|
|
53
|
+
view.id,
|
|
54
|
+
"animationFinish",
|
|
55
|
+
event
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override fun getExportedViewConstants(): Map<String, Any> {
|
|
61
|
+
return LottieAnimationViewManagerImpl.exportedViewConstants
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
override fun getName(): String {
|
|
65
|
+
return LottieAnimationViewManagerImpl.REACT_CLASS
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public override fun createViewInstance(context: ThemedReactContext): LottieAnimationView {
|
|
69
|
+
val view = LottieAnimationViewManagerImpl.createViewInstance(context)
|
|
70
|
+
view.addAnimatorListener(object : Animator.AnimatorListener {
|
|
71
|
+
override fun onAnimationStart(animation: Animator) {
|
|
72
|
+
//do nothing
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun onAnimationEnd(animation: Animator) {
|
|
76
|
+
sendOnAnimationFinishEvent(view, false)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override fun onAnimationCancel(animation: Animator) {
|
|
80
|
+
sendOnAnimationFinishEvent(view, true)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
override fun onAnimationRepeat(animation: Animator) {
|
|
84
|
+
//do nothing
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
return view
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
|
91
|
+
return LottieAnimationViewManagerImpl.getExportedCustomBubblingEventTypeConstants()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
override fun receiveCommand(
|
|
95
|
+
view: LottieAnimationView,
|
|
96
|
+
commandName: String,
|
|
97
|
+
args: ReadableArray?
|
|
98
|
+
) {
|
|
99
|
+
when (commandName) {
|
|
100
|
+
"play" -> play(view, args?.getInt(0) ?: -1, args?.getInt(1) ?: -1)
|
|
101
|
+
"reset" -> reset(view)
|
|
102
|
+
"pause" -> pause(view)
|
|
103
|
+
"resume" -> resume(view)
|
|
104
|
+
else -> {
|
|
105
|
+
//do nothing
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@ReactProp(name = "sourceName")
|
|
111
|
+
fun setSourceName(view: LottieAnimationView, name: String?) {
|
|
112
|
+
setSourceName(name, getOrCreatePropertyManager(view))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@ReactProp(name = "sourceJson")
|
|
116
|
+
fun setSourceJson(view: LottieAnimationView, json: String?) {
|
|
117
|
+
setSourceJson(json, getOrCreatePropertyManager(view))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@ReactProp(name = "sourceURL")
|
|
121
|
+
fun setSourceURL(view: LottieAnimationView, urlString: String?) {
|
|
122
|
+
setSourceURL(urlString, getOrCreatePropertyManager(view))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@ReactProp(name = "cacheComposition")
|
|
126
|
+
fun setCacheComposition(view: LottieAnimationView?, cacheComposition: Boolean) {
|
|
127
|
+
LottieAnimationViewManagerImpl.setCacheComposition(view!!, cacheComposition)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@ReactProp(name = "resizeMode")
|
|
131
|
+
fun setResizeMode(view: LottieAnimationView, resizeMode: String?) {
|
|
132
|
+
setResizeMode(resizeMode, getOrCreatePropertyManager(view))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@ReactProp(name = "renderMode")
|
|
136
|
+
fun setRenderMode(view: LottieAnimationView, renderMode: String?) {
|
|
137
|
+
setRenderMode(renderMode, getOrCreatePropertyManager(view))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@ReactProp(name = "hardwareAccelerationAndroid")
|
|
141
|
+
fun setHardwareAccelerationAndroid(
|
|
142
|
+
view: LottieAnimationView,
|
|
143
|
+
hardwareAccelerationAndroid: Boolean?
|
|
144
|
+
) {
|
|
145
|
+
setHardwareAcceleration(hardwareAccelerationAndroid!!, getOrCreatePropertyManager(view))
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@ReactProp(name = "progress")
|
|
149
|
+
fun setProgress(view: LottieAnimationView, progress: Float) {
|
|
150
|
+
setProgress(progress, getOrCreatePropertyManager(view))
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@ReactProp(name = "speed")
|
|
154
|
+
fun setSpeed(view: LottieAnimationView, speed: Double) {
|
|
155
|
+
setSpeed(speed, getOrCreatePropertyManager(view))
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@ReactProp(name = "loop")
|
|
159
|
+
fun setLoop(view: LottieAnimationView, loop: Boolean) {
|
|
160
|
+
setLoop(loop, getOrCreatePropertyManager(view))
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@ReactProp(name = "imageAssetsFolder")
|
|
164
|
+
fun setImageAssetsFolder(view: LottieAnimationView, imageAssetsFolder: String?) {
|
|
165
|
+
setImageAssetsFolder(imageAssetsFolder, getOrCreatePropertyManager(view))
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@ReactProp(name = "enableMergePathsAndroidForKitKatAndAbove")
|
|
169
|
+
fun setEnableMergePaths(view: LottieAnimationView, enableMergePaths: Boolean) {
|
|
170
|
+
setEnableMergePaths(enableMergePaths, getOrCreatePropertyManager(view))
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@ReactProp(name = "colorFilters")
|
|
174
|
+
fun setColorFilters(view: LottieAnimationView, colorFilters: ReadableArray?) {
|
|
175
|
+
setColorFilters(colorFilters, getOrCreatePropertyManager(view))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@ReactProp(name = "textFiltersAndroid")
|
|
179
|
+
fun setTextFilters(view: LottieAnimationView, textFilters: ReadableArray?) {
|
|
180
|
+
setTextFilters(textFilters, getOrCreatePropertyManager(view))
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
override fun onAfterUpdateTransaction(view: LottieAnimationView) {
|
|
184
|
+
super.onAfterUpdateTransaction(view)
|
|
185
|
+
getOrCreatePropertyManager(view).commitChanges()
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#ifdef __cplusplus
|
|
2
|
+
#import <React/RCTViewComponentView.h>
|
|
3
|
+
#import <react/renderer/components/lottiereactnative/Props.h>
|
|
4
|
+
#import "LottieContainerView.h"
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
@interface LottieAnimationViewComponentView : RCTViewComponentView <LottieContainerViewDelegate>
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
namespace facebook {
|
|
12
|
+
namespace react {
|
|
13
|
+
// In order to compare these structs we need to add the == operator for each
|
|
14
|
+
// TODO: https://github.com/reactwg/react-native-new-architecture/discussions/91#discussioncomment-4426469
|
|
15
|
+
bool operator==(const LottieAnimationViewColorFiltersStruct& a, const LottieAnimationViewColorFiltersStruct& b)
|
|
16
|
+
{
|
|
17
|
+
return b.keypath == a.keypath && b.color == a.color;
|
|
18
|
+
}
|
|
19
|
+
bool operator==(const LottieAnimationViewTextFiltersIOSStruct& a, const LottieAnimationViewTextFiltersIOSStruct& b)
|
|
20
|
+
{
|
|
21
|
+
return b.keypath == a.keypath && b.text == a.text;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
NS_ASSUME_NONNULL_END
|
|
27
|
+
|
|
28
|
+
#endif
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#import "LottieAnimationViewComponentView.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/lottiereactnative/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/lottiereactnative/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/lottiereactnative/Props.h>
|
|
6
|
+
#import <react/renderer/components/lottiereactnative/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
9
|
+
#import <React/RCTView.h>
|
|
10
|
+
#import "LottieContainerView.h"
|
|
11
|
+
#import "RNLottieFabricConversions.h"
|
|
12
|
+
|
|
13
|
+
using namespace facebook::react;
|
|
14
|
+
|
|
15
|
+
@interface LottieAnimationViewComponentView () <RCTLottieAnimationViewViewProtocol>
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation LottieAnimationViewComponentView {
|
|
19
|
+
LottieContainerView *_view;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
- (instancetype) initWithFrame:(CGRect)frame
|
|
23
|
+
{
|
|
24
|
+
if (self = [super initWithFrame:frame]) {
|
|
25
|
+
static const auto defaultProps = std::make_shared<const LottieAnimationViewProps>();
|
|
26
|
+
_props = defaultProps;
|
|
27
|
+
|
|
28
|
+
_view = [LottieContainerView new];
|
|
29
|
+
_view.delegate = self;
|
|
30
|
+
|
|
31
|
+
self.contentView = _view;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return self;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#pragma mark - RCTComponentViewProtocol
|
|
38
|
+
|
|
39
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
40
|
+
{
|
|
41
|
+
return concreteComponentDescriptorProvider<LottieAnimationViewComponentDescriptor>();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
|
|
45
|
+
const auto &oldLottieProps = *std::static_pointer_cast<const LottieAnimationViewProps>(_props);
|
|
46
|
+
const auto &newLottieProps = *std::static_pointer_cast<const LottieAnimationViewProps>(props);
|
|
47
|
+
|
|
48
|
+
if(oldLottieProps.resizeMode != newLottieProps.resizeMode) {
|
|
49
|
+
[_view setResizeMode:RCTNSStringFromString(newLottieProps.resizeMode)];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if(oldLottieProps.sourceJson != newLottieProps.sourceJson) {
|
|
53
|
+
[_view setSourceJson:RCTNSStringFromString(newLottieProps.sourceJson)];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if(oldLottieProps.sourceName != newLottieProps.sourceName) {
|
|
57
|
+
[_view setSourceName:RCTNSStringFromString(newLottieProps.sourceName)];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if(oldLottieProps.sourceURL != newLottieProps.sourceURL) {
|
|
61
|
+
[_view setSourceURL:RCTNSStringFromString(newLottieProps.sourceURL)];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if(oldLottieProps.progress != newLottieProps.progress) {
|
|
65
|
+
[_view setProgress:newLottieProps.progress];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if(oldLottieProps.loop != newLottieProps.loop) {
|
|
69
|
+
[_view setLoop:newLottieProps.loop];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if(oldLottieProps.speed != newLottieProps.speed) {
|
|
73
|
+
[_view setSpeed:newLottieProps.speed];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if(oldLottieProps.colorFilters != newLottieProps.colorFilters) {
|
|
77
|
+
[_view setColorFilters:convertColorFilters(newLottieProps.colorFilters)];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if(oldLottieProps.textFiltersIOS != newLottieProps.textFiltersIOS) {
|
|
81
|
+
[_view setTextFiltersIOS:convertTextFilters(newLottieProps.textFiltersIOS)];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if(oldLottieProps.renderMode != newLottieProps.renderMode) {
|
|
85
|
+
[_view setRenderMode:RCTNSStringFromString(newLottieProps.renderMode)];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[super updateProps:props oldProps:oldProps];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#pragma mark - Native Commands
|
|
92
|
+
|
|
93
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
94
|
+
{
|
|
95
|
+
RCTLottieAnimationViewHandleCommand(self, commandName, args);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
- (void) play:(NSInteger)startFrame endFrame:(NSInteger)endFrame
|
|
99
|
+
{
|
|
100
|
+
if (startFrame != -1 && endFrame != -1) {
|
|
101
|
+
[_view playFromFrame:@(startFrame) toFrame:endFrame];
|
|
102
|
+
} else {
|
|
103
|
+
[_view play];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
- (void) reset
|
|
108
|
+
{
|
|
109
|
+
[_view reset];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
- (void) pause
|
|
113
|
+
{
|
|
114
|
+
[_view pause];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
- (void) resume
|
|
118
|
+
{
|
|
119
|
+
[_view resume];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
- (void)onAnimationFinishWithIsCancelled:(bool)isCancelled
|
|
123
|
+
{
|
|
124
|
+
if(!_eventEmitter) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
LottieAnimationViewEventEmitter::OnAnimationFinish event = {
|
|
129
|
+
.isCancelled = isCancelled
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
std::dynamic_pointer_cast<const LottieAnimationViewEventEmitter>(_eventEmitter)->onAnimationFinish(event);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@end
|
|
136
|
+
|
|
137
|
+
Class<RCTComponentViewProtocol> LottieAnimationViewCls(void)
|
|
138
|
+
{
|
|
139
|
+
return LottieAnimationViewComponentView.class;
|
|
140
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@class UITraitCollection;
|
|
2
|
+
@class NSDictionary;
|
|
3
|
+
@class NSString;
|
|
4
|
+
@class NSCoder;
|
|
5
|
+
|
|
6
|
+
#import <React/RCTView.h>
|
|
7
|
+
|
|
8
|
+
@protocol LottieContainerViewDelegate
|
|
9
|
+
- (void)onAnimationFinishWithIsCancelled:(BOOL)isCancelled;
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@interface LottieContainerView : RCTView
|
|
13
|
+
@property (nonatomic, weak) id <LottieContainerViewDelegate> _Nullable delegate;
|
|
14
|
+
- (void)traitCollectionDidChange:(UITraitCollection * _Nullable)previousTraitCollection;
|
|
15
|
+
- (void)setSpeed:(CGFloat)newSpeed;
|
|
16
|
+
- (void)setProgress:(CGFloat)newProgress;
|
|
17
|
+
- (void)reactSetFrame:(CGRect)frame;
|
|
18
|
+
- (void)setLoop:(BOOL)isLooping;
|
|
19
|
+
- (void)setTextFiltersIOS:(NSArray<NSDictionary *> * _Nonnull)newTextFilters;
|
|
20
|
+
- (void)setRenderMode:(NSString * _Nonnull)newRenderMode;
|
|
21
|
+
- (void)setSourceURL:(NSString * _Nonnull)newSourceURLString;
|
|
22
|
+
- (void)setSourceJson:(NSString * _Nonnull)newSourceJson;
|
|
23
|
+
- (void)setSourceName:(NSString * _Nonnull)newSourceName;
|
|
24
|
+
- (void)setResizeMode:(NSString * _Nonnull)resizeMode;
|
|
25
|
+
- (void)setColorFilters:(NSArray<NSDictionary *> * _Nonnull)newColorFilters;
|
|
26
|
+
- (void)play;
|
|
27
|
+
- (void)playFromFrame:(NSNumber * _Nullable)fromFrame toFrame:(CGFloat)toFrame;
|
|
28
|
+
- (void)reset;
|
|
29
|
+
- (void)pause;
|
|
30
|
+
- (void)resume;
|
|
31
|
+
- (nonnull instancetype)initWithFrame:(CGRect)frame;
|
|
32
|
+
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder;
|
|
33
|
+
@end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#ifdef __cplusplus
|
|
2
|
+
#import <React/RCTConversions.h>
|
|
3
|
+
|
|
4
|
+
inline NSArray<NSDictionary *> *convertColorFilters(std::vector<facebook::react::LottieAnimationViewColorFiltersStruct> colorFilterStructArr)
|
|
5
|
+
{
|
|
6
|
+
NSMutableArray *filters = [NSMutableArray arrayWithCapacity:colorFilterStructArr.size()];
|
|
7
|
+
|
|
8
|
+
for (auto colorFilter : colorFilterStructArr) {
|
|
9
|
+
[filters addObject:@{
|
|
10
|
+
@"color": RCTUIColorFromSharedColor(colorFilter.color),
|
|
11
|
+
@"keypath": RCTNSStringFromString(colorFilter.keypath),
|
|
12
|
+
}];
|
|
13
|
+
}
|
|
14
|
+
return filters;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
inline NSArray<NSDictionary *> *convertTextFilters(std::vector<facebook::react::LottieAnimationViewTextFiltersIOSStruct> textFilterStructArr)
|
|
18
|
+
{
|
|
19
|
+
NSMutableArray *filters = [NSMutableArray arrayWithCapacity:textFilterStructArr.size()];
|
|
20
|
+
|
|
21
|
+
for (auto textFilter : textFilterStructArr) {
|
|
22
|
+
[filters addObject:@{
|
|
23
|
+
@"text": RCTNSStringFromString(textFilter.text),
|
|
24
|
+
@"keypath": RCTNSStringFromString(textFilter.keypath),
|
|
25
|
+
}];
|
|
26
|
+
}
|
|
27
|
+
return filters;
|
|
28
|
+
}
|
|
29
|
+
#endif
|