fix(ios): invalidate G / foreignObject on change in native children

This commit is contained in:
Mikael Sand
2020-01-12 02:42:15 +02:00
parent b5b1ececc0
commit 65cee78a33
4 changed files with 6 additions and 41 deletions
-1
View File
@@ -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;
-34
View File
@@ -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];
+5 -5
View File
@@ -72,7 +72,9 @@
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;
@@ -105,11 +107,9 @@
[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
+1 -1
View File
@@ -15,7 +15,7 @@ RCT_EXPORT_MODULE()
- (RNSVGForeignObject *)node
{
return [[RNSVGForeignObject alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
return [RNSVGForeignObject new];
}
RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*)