mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
bb435a2b11
Summary: In order to support AnimatedColor.setValue for platform colors, we need to pass the platform color object to the native animated node which will then resolve and apply the color. Thus, the approach is: - Add a new API updateAnimatedNodeConfig to NativeAnimatedModule - [JS] On AnimatedColor.setValue, if the value is a platform color, then we call updateAnimatedNodeConfig - [Android] We introduce AnimatedNodeWithUpdateableConfig interface with a method updateConfig. On ColorAnimatedNode.java, we use updateConfig to resolve and apply the color Changelog: [Internal][Fixed] - Use context from view when resolving platform color Reviewed By: javache, mdvacca Differential Revision: D34025193 fbshipit-source-id: 8b368f6b7cb2cf7cebe8b66461cd4185cbadd44c
72 lines
2.5 KiB
JavaScript
72 lines
2.5 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
import type {TurboModule} from '../TurboModule/RCTExport';
|
|
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
|
|
|
|
type EndResult = {finished: boolean, ...};
|
|
type EndCallback = (result: EndResult) => void;
|
|
type SaveValueCallback = (value: number) => void;
|
|
|
|
export type EventMapping = {|
|
|
nativeEventPath: Array<string>,
|
|
animatedValueTag: ?number,
|
|
|};
|
|
|
|
// The config has different keys depending on the type of the Node
|
|
// TODO(T54896888): Make these types strict
|
|
export type AnimatedNodeConfig = Object;
|
|
export type AnimatingNodeConfig = Object;
|
|
|
|
export interface Spec extends TurboModule {
|
|
+startOperationBatch: () => void;
|
|
+finishOperationBatch: () => void;
|
|
+createAnimatedNode: (tag: number, config: AnimatedNodeConfig) => void;
|
|
+updateAnimatedNodeConfig?: (tag: number, config: AnimatedNodeConfig) => void;
|
|
+getValue: (tag: number, saveValueCallback: SaveValueCallback) => void;
|
|
+startListeningToAnimatedNodeValue: (tag: number) => void;
|
|
+stopListeningToAnimatedNodeValue: (tag: number) => void;
|
|
+connectAnimatedNodes: (parentTag: number, childTag: number) => void;
|
|
+disconnectAnimatedNodes: (parentTag: number, childTag: number) => void;
|
|
+startAnimatingNode: (
|
|
animationId: number,
|
|
nodeTag: number,
|
|
config: AnimatingNodeConfig,
|
|
endCallback: EndCallback,
|
|
) => void;
|
|
+stopAnimation: (animationId: number) => void;
|
|
+setAnimatedNodeValue: (nodeTag: number, value: number) => void;
|
|
+setAnimatedNodeOffset: (nodeTag: number, offset: number) => void;
|
|
+flattenAnimatedNodeOffset: (nodeTag: number) => void;
|
|
+extractAnimatedNodeOffset: (nodeTag: number) => void;
|
|
+connectAnimatedNodeToView: (nodeTag: number, viewTag: number) => void;
|
|
+disconnectAnimatedNodeFromView: (nodeTag: number, viewTag: number) => void;
|
|
+restoreDefaultValues: (nodeTag: number) => void;
|
|
+dropAnimatedNode: (tag: number) => void;
|
|
+addAnimatedEventToView: (
|
|
viewTag: number,
|
|
eventName: string,
|
|
eventMapping: EventMapping,
|
|
) => void;
|
|
+removeAnimatedEventFromView: (
|
|
viewTag: number,
|
|
eventName: string,
|
|
animatedNodeTag: number,
|
|
) => void;
|
|
|
|
// Events
|
|
+addListener: (eventName: string) => void;
|
|
+removeListeners: (count: number) => void;
|
|
}
|
|
|
|
export default (TurboModuleRegistry.get<Spec>(
|
|
'NativeAnimatedTurboModule',
|
|
): ?Spec);
|