@@ -9,6 +9,7 @@ import { Color, File, Utils } from '@nativescript/core';
99import {
1010 LottieViewBase ,
1111 autoPlayProperty ,
12+ keyPathColorsProperty ,
1213 loopProperty ,
1314 progressProperty ,
1415 renderModeProperty ,
@@ -108,12 +109,14 @@ export class LottieView extends LottieViewBase {
108109 if ( ! this . loadedListener ) {
109110 this . loadedListener = new com . airbnb . lottie . LottieOnCompositionLoadedListener ( {
110111 onCompositionLoaded : ( composition ) => {
111- this . notify ( { eventName : 'compositionLoaded' , composition } ) ;
112+ // delay just a bit so that it get received in sync load
113+ setTimeout ( ( ) => {
114+ this . notify ( { eventName : 'compositionLoaded' , composition } ) ;
115+ } , 0 ) ;
112116 }
113117 } ) ;
114118 }
115119 this . nativeViewProtected . addLottieOnCompositionLoadedListener ( this . loadedListener ) ;
116-
117120 }
118121
119122 public disposeNativeView ( ) : void {
@@ -186,11 +189,12 @@ export class LottieView extends LottieViewBase {
186189 // view.setComposition(null);
187190 } else {
188191 view . setComposition ( result . getValue ( ) ) ;
192+
189193 //in sync loading we need to fire it ourselves
190194 // if we dont differ it from now it wont be received
191- setTimeout ( ( ) => {
192- this . notify ( { eventName : 'compositionLoaded' , composition : result . getValue ( ) } ) ;
193- } , 0 ) ;
195+ // setTimeout(() => {
196+ // this.notify({ eventName: 'compositionLoaded', composition: result.getValue() });
197+ // }, 0);
194198 }
195199 }
196200 if ( this . autoPlay ) {
@@ -207,6 +211,9 @@ export class LottieView extends LottieViewBase {
207211 [ renderModeProperty . setNative ] ( renderMode ) {
208212 this . nativeViewProtected . setRenderMode ( renderMode ) ;
209213 }
214+ [ keyPathColorsProperty . setNative ] ( value ) {
215+ Object . keys ( value ) . forEach ( ( k ) => this . setColor ( value [ k ] , k . split ( '|' ) ) ) ;
216+ }
210217
211218 [ autoPlayProperty . setNative ] ( autoPlay : boolean ) {
212219 if ( autoPlay ) {
@@ -224,7 +231,7 @@ export class LottieView extends LottieViewBase {
224231 }
225232 }
226233
227- public setColor ( value : Color , keyPath : string [ ] ) : void {
234+ public setColor ( value : Color | string , keyPath : string [ ] ) : void {
228235 const nativeView = this . nativeViewProtected ;
229236 if ( nativeView && value && keyPath && keyPath . length ) {
230237 if ( keyPath [ keyPath . length - 1 ] . toLowerCase ( ) === 'color' ) {
@@ -249,8 +256,9 @@ export class LottieView extends LottieViewBase {
249256 LottieKeyPath = com . airbnb . lottie . model . KeyPath ;
250257 }
251258 // by using color filter we change all colors (STROKE_COLOR and COLOR)
259+ const color = value instanceof Color ? value : new Color ( value ) ;
252260 // const colorFilter = new android.graphics.PorterDuffColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_ATOP) ;
253- const colorFilter = new com . airbnb . lottie . SimpleColorFilter ( value . android ) ;
261+ const colorFilter = new com . airbnb . lottie . SimpleColorFilter ( color . android ) ;
254262 nativeView . addValueCallback (
255263 new LottieKeyPath ( nativeKeyPath as any ) ,
256264 LottieProperty . COLOR_FILTER ,
0 commit comments