Skip to content

Commit 4e60f12

Browse files
authored
fix: update addPath method so it will also work on newarch interop (#86)
1 parent 68f41a8 commit 4e60f12

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ios/RNSketchCanvas/RNSketchCanvas/RNSketchCanvasManager.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,19 @@ - (UIView *)view
7474

7575
RCT_EXPORT_METHOD(addPath:(nonnull NSNumber *)reactTag pathId: (int) pathId strokeColor: (UIColor*) strokeColor strokeWidth: (int) strokeWidth points: (NSArray*) points)
7676
{
77-
NSMutableArray *cgPoints = [[NSMutableArray alloc] initWithCapacity: points.count];
77+
NSMutableArray *cgPoints = [[NSMutableArray alloc] initWithCapacity:points.count];
78+
7879
for (NSString *coor in points) {
7980
@autoreleasepool {
80-
NSArray *coorInNumber = [coor componentsSeparatedByString: @","];
81-
[cgPoints addObject: [NSValue valueWithCGPoint: CGPointMake([coorInNumber[0] floatValue], [coorInNumber[1] floatValue])]];
82-
[self runCanvas:reactTag block:^(RNSketchCanvas *canvas) {
83-
[canvas addPath: pathId strokeColor: strokeColor strokeWidth: strokeWidth points: cgPoints];
84-
}];
81+
NSArray *coorInNumber = [coor componentsSeparatedByString:@","];
82+
CGPoint point = CGPointMake([coorInNumber[0] floatValue], [coorInNumber[1] floatValue]);
83+
[cgPoints addObject:[NSValue valueWithCGPoint:point]];
8584
}
8685
}
86+
87+
[self runCanvas:reactTag block:^(RNSketchCanvas *canvas) {
88+
[canvas addPath:pathId strokeColor:strokeColor strokeWidth:strokeWidth points:cgPoints];
89+
}];
8790
}
8891

8992
RCT_EXPORT_METHOD(newPath:(nonnull NSNumber *)reactTag pathId: (int) pathId strokeColor: (UIColor*) strokeColor strokeWidth: (int) strokeWidth)

0 commit comments

Comments
 (0)