Skip to content

Commit 1adb671

Browse files
committed
Moar native nodes
1 parent d756ebf commit 1adb671

File tree

15 files changed

+128
-67
lines changed

15 files changed

+128
-67
lines changed

Example/Reanimated/core/AnimatedBlock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class AnimatedBlock extends AnimatedNode {
55
_array;
66

77
constructor(array) {
8-
super({ type: 'block' }, array);
8+
super({ type: 'block', block: array.map(n => n.__nodeID) }, array);
99
this._array = array;
1010
}
1111

Example/Reanimated/core/AnimatedCond.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ export default class AnimatedCond extends AnimatedNode {
77
_elseBlock;
88

99
constructor(condition, ifBlock, elseBlock) {
10-
super({ type: 'cond' }, [condition, ifBlock, elseBlock]);
10+
super(
11+
{
12+
type: 'cond',
13+
cond: condition.__nodeID,
14+
ifBlock: ifBlock.__nodeID,
15+
elseBlock: elseBlock.__nodeID,
16+
},
17+
[condition, ifBlock, elseBlock]
18+
);
1119
this._condition = condition;
1220
this._ifBlock = ifBlock;
1321
this._elseBlock = elseBlock;

Example/Reanimated/core/AnimatedProps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class AnimatedProps extends AnimatedNode {
3232
for (const key in this._props) {
3333
const value = this._props[key];
3434
if (value instanceof AnimatedNode) {
35-
if (!value.__isNative || value instanceof AnimatedStyle) {
35+
if (value instanceof AnimatedStyle) {
3636
// We cannot use value of natively driven nodes this way as the value we have access from
3737
// JS may not be up to date.
3838
props[key] = value.__getProps();

Example/Reanimated/core/AnimatedStyle.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ export default class AnimatedStyle extends AnimatedNode {
3434
for (const key in style) {
3535
const value = style[key];
3636
if (value instanceof AnimatedNode) {
37-
if (!value.__isNative) {
38-
// We cannot use value of natively driven nodes this way as the value we have access from
39-
// JS may not be up to date.
40-
updatedStyle[key] = value.__getProps();
41-
}
37+
// do nothing
4238
} else if (value && !Array.isArray(value) && typeof value === 'object') {
4339
// Support animating nested values (for example: shadowOffset.height)
4440
updatedStyle[key] = this._walkStyleAndGetValues(value);

Example/ios/GestureHandler.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
447781C320763EB000B4D8C9 /* REATransformNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 447781C220763EB000B4D8C9 /* REATransformNode.m */; };
3333
447781C520763FEA00B4D8C9 /* REAValueNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 447781C420763FEA00B4D8C9 /* REAValueNode.m */; };
3434
447781C8207693D100B4D8C9 /* REAPropsNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 447781C7207693D100B4D8C9 /* REAPropsNode.m */; };
35+
447781CB207B5C8400B4D8C9 /* REABlockNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 447781CA207B5C8400B4D8C9 /* REABlockNode.m */; };
36+
447781CE207B60F300B4D8C9 /* REACondNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 447781CD207B60F300B4D8C9 /* REACondNode.m */; };
3537
4486EC712076263F008A0135 /* REANodesManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4486EC5F2076263F008A0135 /* REANodesManager.m */; };
3638
4486EC722076263F008A0135 /* REAModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 4486EC602076263F008A0135 /* REAModule.m */; };
3739
4486EC762076340F008A0135 /* REAStyleNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 4486EC752076340F008A0135 /* REAStyleNode.m */; };
@@ -335,6 +337,10 @@
335337
447781C420763FEA00B4D8C9 /* REAValueNode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = REAValueNode.m; sourceTree = "<group>"; };
336338
447781C6207693C300B4D8C9 /* REAPropsNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = REAPropsNode.h; sourceTree = "<group>"; };
337339
447781C7207693D100B4D8C9 /* REAPropsNode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = REAPropsNode.m; sourceTree = "<group>"; };
340+
447781C9207B5C7900B4D8C9 /* REABlockNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = REABlockNode.h; sourceTree = "<group>"; };
341+
447781CA207B5C8400B4D8C9 /* REABlockNode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = REABlockNode.m; sourceTree = "<group>"; };
342+
447781CC207B60E800B4D8C9 /* REACondNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = REACondNode.h; sourceTree = "<group>"; };
343+
447781CD207B60F300B4D8C9 /* REACondNode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = REACondNode.m; sourceTree = "<group>"; };
338344
4486EC442076263F008A0135 /* RCTReanimatedNodesManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTReanimatedNodesManager.h; sourceTree = "<group>"; };
339345
4486EC452076263F008A0135 /* RCTAnimationUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAnimationUtils.h; sourceTree = "<group>"; };
340346
4486EC472076263F008A0135 /* REAValueNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REAValueNode.h; sourceTree = "<group>"; };
@@ -559,6 +565,10 @@
559565
447781C220763EB000B4D8C9 /* REATransformNode.m */,
560566
447781C6207693C300B4D8C9 /* REAPropsNode.h */,
561567
447781C7207693D100B4D8C9 /* REAPropsNode.m */,
568+
447781C9207B5C7900B4D8C9 /* REABlockNode.h */,
569+
447781CA207B5C8400B4D8C9 /* REABlockNode.m */,
570+
447781CC207B60E800B4D8C9 /* REACondNode.h */,
571+
447781CD207B60F300B4D8C9 /* REACondNode.m */,
562572
);
563573
path = Nodes;
564574
sourceTree = "<group>";
@@ -1047,10 +1057,12 @@
10471057
files = (
10481058
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
10491059
13B07FC11A68108700A75B9A /* main.m in Sources */,
1060+
447781CE207B60F300B4D8C9 /* REACondNode.m in Sources */,
10501061
4486EC712076263F008A0135 /* REANodesManager.m in Sources */,
10511062
447781C520763FEA00B4D8C9 /* REAValueNode.m in Sources */,
10521063
444DA3621F223F3F00AA9BCA /* MBFingerTipWindow.m in Sources */,
10531064
4486EC762076340F008A0135 /* REAStyleNode.m in Sources */,
1065+
447781CB207B5C8400B4D8C9 /* REABlockNode.m in Sources */,
10541066
4486EC722076263F008A0135 /* REAModule.m in Sources */,
10551067
447781C8207693D100B4D8C9 /* REAPropsNode.m in Sources */,
10561068
4477819B20763D8000B4D8C9 /* REANode.m in Sources */,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#import "REANode.h"
2+
3+
@interface REABlockNode : REANode
4+
5+
@end
6+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#import "REABlockNode.h"
2+
#import "REANodesManager.h"
3+
4+
@implementation REABlockNode {
5+
NSArray<NSNumber *> *_block;
6+
}
7+
8+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
9+
{
10+
if ((self = [super initWithID:nodeID config:config])) {
11+
_block = config[@"block"];
12+
}
13+
return self;
14+
}
15+
16+
- (id)evaluate
17+
{
18+
id result;
19+
for (NSNumber *inputID in _block) {
20+
result = [[self.nodesManager findNodeByID:inputID] value];
21+
}
22+
return result;
23+
}
24+
25+
@end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#import "REANode.h"
2+
3+
@interface REACondNode : REANode
4+
5+
@end
6+
7+
8+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#import "REACondNode.h"
2+
#import "REANodesManager.h"
3+
4+
@implementation REACondNode {
5+
NSNumber *_condNodeID;
6+
NSNumber *_ifBlockID;
7+
NSNumber *_elseBlockID;
8+
}
9+
10+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
11+
{
12+
if ((self = [super initWithID:nodeID config:config])) {
13+
_condNodeID = config[@"cond"];
14+
_ifBlockID = config[@"ifBlock"];
15+
_elseBlockID = config[@"elseBlock"];
16+
}
17+
return self;
18+
}
19+
20+
- (id)evaluate
21+
{
22+
id cond = [[self.nodesManager findNodeByID:_condNodeID] value];
23+
if ([cond floatValue]) {
24+
return [[self.nodesManager findNodeByID:_ifBlockID] value];
25+
}
26+
return [[self.nodesManager findNodeByID:_elseBlockID] value];
27+
}
28+
29+
@end

Example/ios/GestureHandler/NativeAnimation/Nodes/REANode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef NSNumber* REANodeID;
2323

2424
- (_Nullable id)evaluate;
2525
- (_Nullable id)value;
26+
- (void)markUpdated;
2627

2728
- (void)addChild:(REANode *)child NS_REQUIRES_SUPER;
2829
- (void)removeChild:(REANode *)child NS_REQUIRES_SUPER;

0 commit comments

Comments
 (0)