mirror of
https://github.com/zhigang1992/react-native-reanimated.git
synced 2026-06-15 10:28:20 +08:00
30 lines
726 B
Objective-C
30 lines
726 B
Objective-C
#import "REACondNode.h"
|
|
#import "REANodesManager.h"
|
|
|
|
@implementation REACondNode {
|
|
NSNumber *_condNodeID;
|
|
NSNumber *_ifBlockID;
|
|
NSNumber *_elseBlockID;
|
|
}
|
|
|
|
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
{
|
|
if ((self = [super initWithID:nodeID config:config])) {
|
|
_condNodeID = config[@"cond"];
|
|
_ifBlockID = config[@"ifBlock"];
|
|
_elseBlockID = config[@"elseBlock"];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (id)evaluate
|
|
{
|
|
id cond = [[self.nodesManager findNodeByID:_condNodeID] value];
|
|
if ([cond doubleValue]) {
|
|
return [[self.nodesManager findNodeByID:_ifBlockID] value];
|
|
}
|
|
return _elseBlockID != nil ? [[self.nodesManager findNodeByID:_elseBlockID] value] : @(0);
|
|
}
|
|
|
|
@end
|