Skip to content

Commit

Permalink
fix: use color filter to set color on android
Browse files Browse the repository at this point in the history
  • Loading branch information
edusperoni committed Mar 10, 2023
1 parent b57a64b commit af275e4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/lottie.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
} from './lottie.common';
import { clamp } from './utils';

let LottieProperty;
let LottieKeyPath;
let LottieValueCallback;
let LottieProperty: typeof com.airbnb.lottie.LottieProperty;
let LottieKeyPath: typeof com.airbnb.lottie.model.KeyPath;
let LottieValueCallback: typeof com.airbnb.lottie.value.LottieValueCallback;

const cache = new Map();
function loadLottieJSON(iconSrc) {
Expand Down Expand Up @@ -190,10 +190,12 @@ export class LottieView extends LottieViewBase {
if (!LottieKeyPath) {
LottieKeyPath = com.airbnb.lottie.model.KeyPath;
}
// by using color filter we change all colors (STROKE_COLOR and COLOR)
const colorFilter = new com.airbnb.lottie.SimpleColorFilter(value.android);
this.nativeViewProtected.addValueCallback(
new LottieKeyPath(nativeKeyPath),
LottieProperty.COLOR,
new LottieValueCallback(new java.lang.Integer(value.android))
new LottieKeyPath(nativeKeyPath as any),
LottieProperty.COLOR_FILTER,
new LottieValueCallback(colorFilter)
);
}
}
Expand Down Expand Up @@ -222,7 +224,7 @@ export class LottieView extends LottieViewBase {
LottieKeyPath = com.airbnb.lottie.model.KeyPath;
}
this.nativeViewProtected.addValueCallback(
new LottieKeyPath(nativeKeyPath),
new LottieKeyPath(nativeKeyPath as any),
LottieProperty.OPACITY,
new LottieValueCallback(new java.lang.Integer(value * 100))
);
Expand Down

0 comments on commit af275e4

Please sign in to comment.