feat: strokeDasharray with Animated (#2089)

PR adding the proper handling of strokeDasharray prop for when used with Animated and Reanimated. Code based on #1464 by @bardliu, but with the newest state of the repository.
This commit is contained in:
Wojciech Lewicki
2023-07-07 11:21:04 +02:00
committed by GitHub
parent 24dba65b7a
commit 78aaffad10
40 changed files with 219 additions and 23 deletions
+14 -2
View File
@@ -128,8 +128,20 @@ RCT_ENUM_CONVERTER(
return lengths;
} else if ([json isKindOfClass:[NSString class]]) {
NSString *stringValue = (NSString *)json;
RNSVGLength *length = [RNSVGLength lengthWithString:stringValue];
return [NSArray arrayWithObject:length];
stringValue = [stringValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
stringValue = [stringValue stringByReplacingOccurrencesOfString:@","
withString:@" "
options:NSRegularExpressionSearch
range:NSMakeRange(0, stringValue.length)];
NSArray<NSString *> *array = [stringValue componentsSeparatedByString:@" "];
NSMutableArray<RNSVGLength *> *svgLengthArray = [NSMutableArray array];
for (NSString *string in array) {
RNSVGLength *length = [RNSVGLength lengthWithString:string];
[svgLengthArray addObject:length];
}
return svgLengthArray;
} else {
return nil;
}