fix: compatibility with reanimated color, fixes #1241

This commit is contained in:
Mikael Sand
2020-01-18 02:32:00 +02:00
parent 61bc9bd2cb
commit 498376678e
6 changed files with 20 additions and 5 deletions
@@ -116,7 +116,9 @@ abstract public class RenderableView extends VirtualView {
return;
}
ReadableType type = fill.getType();
if (type.equals(ReadableType.Array)) {
if (type.equals(ReadableType.Number)) {
this.fill = JavaOnlyArray.of(0, fill.asInt());
} else if (type.equals(ReadableType.Array)) {
this.fill = fill.asArray();
} else {
JavaOnlyArray arr = new JavaOnlyArray();
@@ -162,7 +164,9 @@ abstract public class RenderableView extends VirtualView {
return;
}
ReadableType type = strokeColors.getType();
if (type.equals(ReadableType.Array)) {
if (type.equals(ReadableType.Number)) {
stroke = JavaOnlyArray.of(0, strokeColors.asInt());
} else if (type.equals(ReadableType.Array)) {
stroke = strokeColors.asArray();
} else {
JavaOnlyArray arr = new JavaOnlyArray();
+1 -1
View File
@@ -15,7 +15,7 @@
@property (nonatomic, strong) NSString* brushRef;
/* @abstract */
- (instancetype)initWithArray:(NSArray *)data NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithArray:(NSArray *)data;
/**
* @abstract
-2
View File
@@ -16,8 +16,6 @@
return [super init];
}
RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (void)paint:(CGContextRef)context opacity:(CGFloat)opacity painter:(RNSVGPainter *)painter bounds:(CGRect)bounds
{
+2
View File
@@ -10,4 +10,6 @@
@interface RNSVGSolidColorBrush : RNSVGBrush
- (instancetype)initWithNumber:(NSNumber *)number;
@end
+8
View File
@@ -24,6 +24,14 @@
return self;
}
- (instancetype)initWithNumber:(NSNumber *)number
{
if ((self = [super init])) {
_color = CGColorRetain([RCTConvert CGColor:number]);
}
return self;
}
- (void)dealloc
{
CGColorRelease(_color);
+3
View File
@@ -36,6 +36,9 @@ RCT_ENUM_CONVERTER(RNSVGUnits, (@{
+ (RNSVGBrush *)RNSVGBrush:(id)json
{
if ([json isKindOfClass:[NSNumber class]]) {
return [[RNSVGSolidColorBrush alloc] initWithNumber:json];
}
if ([json isKindOfClass:[NSString class]]) {
NSString *value = [self NSString:json];
if (!RNSVGDigitRegEx) {