Skip to content

Commit

Permalink
Use InteropLayer for ReactART
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

Use InteropLayer to bridge ReactART into Fabric.

Reviewed By: shergin

Differential Revision: D21302151

fbshipit-source-id: 46deb381389c6fa87ecad296f616fbaccb29fe30
  • Loading branch information
sammy-SC authored and facebook-github-bot committed May 1, 2020
1 parent 65d52a5 commit 2047041
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 175 deletions.
12 changes: 9 additions & 3 deletions Libraries/ART/ARTGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ @implementation ARTGroup

- (void)renderLayerTo:(CGContextRef)context
{

if (!CGRectIsEmpty(self.clipping)) {
CGContextClipToRect(context, self.clipping);
}

for (ARTNode *node in self.subviews) {
[node renderTo:context];
for (UIView *subview in self.subviews) {
if ([subview respondsToSelector:@selector(renderTo:)]) {
[(ARTNode *)subview renderTo:context];
} else {
// This is needed for legacy interop layer. Legacy interop layer
// is superview of the view that it is bridging, that's why we need
// to grab its first subview.
[(ARTNode *)subview.subviews.firstObject renderTo:context];
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions Libraries/ART/ARTNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ - (void)setTransform:(CGAffineTransform)transform

- (void)invalidate
{
id<ARTContainer> container = (id<ARTContainer>)self.superview;
[container invalidate];
if ([self.superview respondsToSelector:@selector(invalidate)]) {
id<ARTContainer> container = (id<ARTContainer>)self.superview;
[container invalidate];
}
}

- (void)renderTo:(CGContextRef)context
Expand Down
11 changes: 9 additions & 2 deletions Libraries/ART/ARTSurfaceView.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ - (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
for (ARTNode *node in self.subviews) {
[node renderTo:context];
for (UIView *subview in self.subviews) {
if ([subview respondsToSelector:@selector(renderTo:)]) {
[(ARTNode *)subview renderTo:context];
} else {
// This is needed for legacy interop layer. Legacy interop layer
// is superview of the view that it is bridging, that's why we need
// to grab its first subview.
[(ARTNode *)subview.subviews.firstObject renderTo:context];
}
}
}

Expand Down

This file was deleted.

27 changes: 0 additions & 27 deletions React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.h

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@ - (instancetype)initWithFrame:(CGRect)frame

+ (NSMutableSet<NSString *> *)supportedViewManagers
{
static NSMutableSet<NSString *> *supported =
[NSMutableSet setWithObjects:@"Picker", @"DatePicker", @"ProgressView", @"SegmentedControl", @"MaskedView", nil];
static NSMutableSet<NSString *> *supported = [NSMutableSet setWithObjects:@"Picker",
@"DatePicker",
@"ProgressView",
@"SegmentedControl",
@"MaskedView",
@"ARTSurfaceView",
@"ARTText",
@"ARTShape",
@"ARTGroup",
nil];
return supported;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Class<RCTComponentViewProtocol> RCTSliderCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTSwitchCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTUnimplementedNativeViewCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTModalHostViewCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTARTSurfaceViewCls(void) __attribute__((used));
Class<RCTComponentViewProtocol> RCTImageCls(void) __attribute__((used));

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
{"Switch", RCTSwitchCls},
{"UnimplementedNativeView", RCTUnimplementedNativeViewCls},
{"ModalHostView", RCTModalHostViewCls},
{"ARTSurfaceView", RCTARTSurfaceViewCls},
{"Image", RCTImageCls},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
// If `moduleName` has "FB" prefix.
return componentName + "Manager";
}

std::string artPrefix("ART");
if (std::mismatch(artPrefix.begin(), artPrefix.end(), componentName.begin()).first == artPrefix.end()) {
return componentName + "Manager";
}

return "RCT" + componentName + "Manager";
}

Expand Down

0 comments on commit 2047041

Please sign in to comment.