Skip to content

Commit

Permalink
fix: update addPath method so it will also work on newarch interop
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-wd committed Dec 10, 2024
1 parent 68f41a8 commit f8dd626
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ios/RNSketchCanvas/RNSketchCanvas/RNSketchCanvasManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,19 @@ - (UIView *)view

RCT_EXPORT_METHOD(addPath:(nonnull NSNumber *)reactTag pathId: (int) pathId strokeColor: (UIColor*) strokeColor strokeWidth: (int) strokeWidth points: (NSArray*) points)
{
NSMutableArray *cgPoints = [[NSMutableArray alloc] initWithCapacity: points.count];
NSMutableArray *cgPoints = [[NSMutableArray alloc] initWithCapacity:points.count];

for (NSString *coor in points) {
@autoreleasepool {
NSArray *coorInNumber = [coor componentsSeparatedByString: @","];
[cgPoints addObject: [NSValue valueWithCGPoint: CGPointMake([coorInNumber[0] floatValue], [coorInNumber[1] floatValue])]];
[self runCanvas:reactTag block:^(RNSketchCanvas *canvas) {
[canvas addPath: pathId strokeColor: strokeColor strokeWidth: strokeWidth points: cgPoints];
}];
NSArray *coorInNumber = [coor componentsSeparatedByString:@","];
CGPoint point = CGPointMake([coorInNumber[0] floatValue], [coorInNumber[1] floatValue]);
[cgPoints addObject:[NSValue valueWithCGPoint:point]];
}
}

[self runCanvas:reactTag block:^(RNSketchCanvas *canvas) {
[canvas addPath:pathId strokeColor:strokeColor strokeWidth:strokeWidth points:cgPoints];
}];
}

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

0 comments on commit f8dd626

Please sign in to comment.