You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for PlatformColor type of toValue and interpolation outputRange (facebook#54450)
Summary:
## Changelog:
[Android] [Added] Add support for PlatformColor type of toValue and interpolation outputRange
Making this change in order to support animation from and to PlatformColor type, in use cases like below
Example 1:
```
const animatedColor = useRef(
new Animated.Color(PlatformColor('android:color/white')),
);
...
Animated.timing(animatedColor.current, {
toValue: PlatformColor('android:color/darker_gray'),
duration: 500,
useNativeDriver: true,
}).start();
```
Example 2:
```
const animatedValue = useRef(new Animated.Value(0));
...
backgroundColor: animatedValue.current.interpolate({
inputRange: [0, 1],
outputRange: [
PlatformColor('android:color/white'),
PlatformColor('android:color/darker_gray'),
],
}),
```
A nuance here: in the framework js code, usually `AnimatedColor` class will resolve color for each channel (RGBA) and create multiple `AnimatedValue` instances. However for platform color, instead of directly resolving the PlatformColor by calling native module, we could pass down the color string + channel name to native, and defer to AnimatedNode/Driver on the native side to resolve the actual color value when it's necessary.
But this strategy means PlatformColor toValue/outputRange won't work if `useNativeDriver` is turned off.
Note that `fromValue` is already supported (in ColorAnimatedNode.kt)
Differential Revision: D86351284
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.kt
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -112,7 +112,8 @@ public class NativeAnimatedNodesManager(
0 commit comments