Files
react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h
T
Genki Kondo bb435a2b11 Support AnimatedColor.setValue for platform colors
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
2022-02-08 16:31:14 -08:00

102 lines
3.0 KiB
Objective-C

/*
* 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.
*/
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTUIManager.h>
#import <React/RCTSurfacePresenterStub.h>
#import <React/RCTEventDispatcherProtocol.h>
@protocol RCTValueAnimatedNodeObserver;
NS_ASSUME_NONNULL_BEGIN
@interface RCTNativeAnimatedNodesManager : NSObject
- (nonnull instancetype)initWithBridge:(nullable RCTBridge *)bridge
surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter;
- (void)updateAnimations;
- (void)stepAnimations:(CADisplayLink *)displaylink;
- (BOOL)isNodeManagedByFabric:(NSNumber *)tag;
- (void)getValue:(NSNumber *)nodeTag
saveCallback:(RCTResponseSenderBlock)saveCallback;
// graph
- (void)createAnimatedNode:(NSNumber *)tag
config:(NSDictionary<NSString *, id> *)config;
- (void)connectAnimatedNodes:(NSNumber *)parentTag
childTag:(NSNumber *)childTag;
- (void)disconnectAnimatedNodes:(NSNumber *)parentTag
childTag:(NSNumber *)childTag;
- (void)connectAnimatedNodeToView:(NSNumber *)nodeTag
viewTag:(NSNumber *)viewTag
viewName:(nullable NSString *)viewName;
- (void)restoreDefaultValues:(NSNumber *)nodeTag;
- (void)disconnectAnimatedNodeFromView:(NSNumber *)nodeTag
viewTag:(NSNumber *)viewTag;
- (void)dropAnimatedNode:(NSNumber *)tag;
// mutations
- (void)setAnimatedNodeValue:(NSNumber *)nodeTag
value:(NSNumber *)value;
- (void)setAnimatedNodeOffset:(NSNumber *)nodeTag
offset:(NSNumber *)offset;
- (void)flattenAnimatedNodeOffset:(NSNumber *)nodeTag;
- (void)extractAnimatedNodeOffset:(NSNumber *)nodeTag;
- (void)updateAnimatedNodeConfig:(NSNumber *)tag
config:(NSDictionary<NSString *, id> *)config;
// drivers
- (void)startAnimatingNode:(NSNumber *)animationId
nodeTag:(NSNumber *)nodeTag
config:(NSDictionary<NSString *, id> *)config
endCallback:(nullable RCTResponseSenderBlock)callBack;
- (void)stopAnimation:(NSNumber *)animationId;
- (void)stopAnimationLoop;
// events
- (void)addAnimatedEventToView:(NSNumber *)viewTag
eventName:(NSString *)eventName
eventMapping:(NSDictionary<NSString *, id> *)eventMapping;
- (void)removeAnimatedEventFromView:(NSNumber *)viewTag
eventName:(NSString *)eventName
animatedNodeTag:(NSNumber *)animatedNodeTag;
- (void)handleAnimatedEvent:(id<RCTEvent>)event;
// listeners
- (void)startListeningToAnimatedNodeValue:(NSNumber *)tag
valueObserver:(id<RCTValueAnimatedNodeObserver>)valueObserver;
- (void)stopListeningToAnimatedNodeValue:(NSNumber *)tag;
@end
NS_ASSUME_NONNULL_END