Skip to content

Conversation

@zeyap
Copy link
Contributor

@zeyap zeyap commented Nov 7, 2025

Summary:

Changelog:

[General] [Added] (js part) Support PlatformColor type of toValue and interpolation outputRange

Differential Revision: D86255713

zeyap added 2 commits November 7, 2025 13:07
…tRange (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
…putRange

Summary:
## Changelog:

[General] [Added] (js part) Support PlatformColor type of toValue and interpolation outputRange

Differential Revision: D86255713
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 7, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 7, 2025

@zeyap has exported this pull request. If you are a Meta employee, you can view the originating Diff in D86255713.

zeyap added a commit to zeyap/react-native that referenced this pull request Nov 7, 2025
…putRange (facebook#54457)

Summary:

## Changelog:

[General] [Added] (js part) Support PlatformColor type of toValue and interpolation outputRange

Differential Revision: D86255713
@react-native-bot
Copy link
Collaborator


Warnings
⚠️ ❗ JavaScript API change detected - This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. Please include a clear changelog message. This change will be subject to extra review.

This change was flagged as: BREAKING

Generated by 🚫 dangerJS against efb3b4c

zeyap added a commit to zeyap/react-native that referenced this pull request Nov 7, 2025
…putRange (facebook#54457)

Summary:

## Changelog:

[General] [Added] (js part) Support PlatformColor type of toValue and interpolation outputRange

Differential Revision: D86255713
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants