GT2/Ejectable/node_modules/react-native-reanimated/ios/Nodes/REATransformNode.m

39 lines
959 B
Mathematica
Raw Normal View History

2021-08-16 00:14:59 +00:00
#import "REATransformNode.h"
#import <React/RCTConvert.h>
#import "REANodesManager.h"
@implementation REATransformNode
{
NSArray<id> *_transformConfigs;
}
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
{
if ((self = [super initWithID:nodeID config:config])) {
_transformConfigs = config[@"transform"];
}
return self;
}
- (id)evaluate
{
NSMutableArray<NSDictionary *> *transform = [NSMutableArray arrayWithCapacity:_transformConfigs.count];
for (NSDictionary *transformConfig in _transformConfigs) {
NSString *property = transformConfig[@"property"];
REANodeID nodeID = [RCTConvert NSNumber:transformConfig[@"nodeID"]];
NSNumber *value;
if (nodeID) {
REANode *node = [self.nodesManager findNodeByID:nodeID];
value = [node value];
} else {
value = transformConfig[@"value"];
}
[transform addObject:@{property: value}];
}
return transform;
}
@end