fix(ios): initial render foreignObject / re-render on mount of sub views

This commit is contained in:
Mikael Sand
2020-01-12 01:08:32 +02:00
parent 85e7943448
commit d54969846d
3 changed files with 29 additions and 1 deletions
+2
View File
@@ -1,9 +1,11 @@
#import "RNSVGGroup.h" #import "RNSVGGroup.h"
#import "RNSVGLength.h" #import "RNSVGLength.h"
#import "RCTEventDispatcher.h"
@interface RNSVGForeignObject : RNSVGGroup @interface RNSVGForeignObject : RNSVGGroup
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
@property (nonatomic, strong) RNSVGLength *x; @property (nonatomic, strong) RNSVGLength *x;
@property (nonatomic, strong) RNSVGLength *y; @property (nonatomic, strong) RNSVGLength *y;
@property (nonatomic, strong) RNSVGLength *foreignObjectwidth; @property (nonatomic, strong) RNSVGLength *foreignObjectwidth;
+26
View File
@@ -7,19 +7,45 @@
*/ */
#import "RNSVGForeignObject.h" #import "RNSVGForeignObject.h"
#import "RNSVGNode.h" #import "RNSVGNode.h"
#import "RCTUIManager.h"
#import "RCTUIManagerObserverCoordinator.h"
@implementation RNSVGForeignObject @implementation RNSVGForeignObject
{
RCTEventDispatcher *_eventDispatcher;
bool _ready;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{ {
return nil; return nil;
} }
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
{
RCTAssertParam(eventDispatcher);
if ((self = [super init])) {
_eventDispatcher = eventDispatcher;
[_eventDispatcher.bridge.uiManager.observerCoordinator addObserver:self];
}
return self;
}
- (void)parseReference - (void)parseReference
{ {
self.dirty = false; self.dirty = false;
} }
- (void)uiManagerDidPerformMounting:(RCTUIManager *)manager
{
[manager addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
if (!self->_ready && !self.dirty) {
[self invalidate];
}
}];
}
- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect - (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
{ {
[self clip:context]; [self clip:context];
+1 -1
View File
@@ -15,7 +15,7 @@ RCT_EXPORT_MODULE()
- (RNSVGForeignObject *)node - (RNSVGForeignObject *)node
{ {
return [RNSVGForeignObject new]; return [[RNSVGForeignObject alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
} }
RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*) RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*)