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

View File

@@ -1,9 +1,11 @@
#import "RNSVGGroup.h"
#import "RNSVGLength.h"
#import "RCTEventDispatcher.h"
@interface RNSVGForeignObject : RNSVGGroup
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
@property (nonatomic, strong) RNSVGLength *x;
@property (nonatomic, strong) RNSVGLength *y;
@property (nonatomic, strong) RNSVGLength *foreignObjectwidth;

View File

@@ -7,19 +7,45 @@
*/
#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.dirty) {
[self invalidate];
}
}];
}
- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
{
[self clip:context];

View File

@@ -15,7 +15,7 @@ RCT_EXPORT_MODULE()
- (RNSVGForeignObject *)node
{
return [RNSVGForeignObject new];
return [[RNSVGForeignObject alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
}
RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*)