Skip to content

Commit

Permalink
fix(ios): invalidate G / foreignObject on change in native children
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Jan 12, 2020
1 parent b5b1ece commit 65cee78
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 41 deletions.
1 change: 0 additions & 1 deletion ios/Elements/RNSVGForeignObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@interface RNSVGForeignObject : RNSVGGroup

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
@property (nonatomic, strong) RNSVGLength *x;
@property (nonatomic, strong) RNSVGLength *y;
@property (nonatomic, strong) RNSVGLength *foreignObjectwidth;
Expand Down
34 changes: 0 additions & 34 deletions ios/Elements/RNSVGForeignObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,19 @@
*/
#import "RNSVGForeignObject.h"
#import "RNSVGNode.h"
#import "RCTUIManager.h"
#import "RCTUIManagerObserverCoordinator.h"

@implementation RNSVGForeignObject
{
RCTEventDispatcher *_eventDispatcher;
bool _ready;
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
return nil;
}

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
{
RCTAssertParam(eventDispatcher);

if ((self = [super init])) {
_eventDispatcher = eventDispatcher;
[_eventDispatcher.bridge.uiManager.observerCoordinator addObserver:self];
}
return self;
}

- (void)parseReference
{
self.dirty = false;
}

- (void)uiManagerDidPerformMounting:(RCTUIManager *)manager
{
[manager addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
if (!self->_ready) {
[self invalidate];
}
}];
}

- (void)renderChildTo:(CGContextRef)context rect:(CGRect)rect node:(UIView*)node
{
node.hidden = false;
self->_ready = [node drawViewHierarchyInRect:rect afterScreenUpdates:true];
[node.layer renderInContext:context];
node.hidden = true;
}

- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
{
[self clip:context];
Expand Down
10 changes: 5 additions & 5 deletions ios/Elements/RNSVGGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ - (void)renderGroupTo:(CGContextRef)context rect:(CGRect)rect
CGContextClipToRect(context, rect);
[svgView drawToContext:context withRect:rect];
} else {
[self renderChildTo:context rect:rect node:node];
node.hidden = false;
[node.layer renderInContext:context];
node.hidden = true;
}

return YES;
Expand Down Expand Up @@ -105,11 +107,9 @@ - (void)renderGroupTo:(CGContextRef)context rect:(CGRect)rect
[self popGlyphContext];
}

- (void)renderChildTo:(CGContextRef)context rect:(CGRect)rect node:(UIView*)node
- (void)drawRect:(CGRect)rect
{
node.hidden = false;
[node.layer renderInContext:context];
node.hidden = true;
[self invalidate];
}

- (void)setupGlyphContext:(CGContextRef)context
Expand Down
2 changes: 1 addition & 1 deletion ios/ViewManagers/RNSVGForeignObjectManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @implementation RNSVGForeignObjectManager

- (RNSVGForeignObject *)node
{
return [[RNSVGForeignObject alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
return [RNSVGForeignObject new];
}

RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*)
Expand Down

0 comments on commit 65cee78

Please sign in to comment.