Skip to content

Commit

Permalink
fix(ios): initial render foreignObject / re-render on mount of sub views
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Jan 11, 2020
1 parent 85e7943 commit d549698
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ios/Elements/RNSVGForeignObject.h
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
26 changes: 26 additions & 0 deletions ios/Elements/RNSVGForeignObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
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 new];
return [[RNSVGForeignObject alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
}

RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*)
Expand Down

0 comments on commit d549698

Please sign in to comment.