feat: invalidate on color change (#2470)

# Summary

Invalidate element when `color` prop changes.
This commit is contained in:
Jakub Grzywacz
2024-10-02 15:48:29 +02:00
committed by GitHub
parent b4dc9756df
commit f1d33a4e1e
3 changed files with 12 additions and 1 deletions

View File

@@ -35,6 +35,8 @@
@property (nonatomic, assign) CGPathRef hitArea;
@property (nonatomic, strong) NSString *filter;
- (void)setColor:(RNSVGColor *)color;
- (void)setHitArea:(CGPathRef)path;
- (NSArray<NSString *> *)getAttributeList;

View File

@@ -59,6 +59,15 @@ static RNSVGRenderable *_contextElement;
self.dirty = true;
}
- (void)setColor:(RNSVGColor *)color
{
if (color == self.tintColor) {
return;
}
[self invalidate];
self.tintColor = color;
}
- (void)setFill:(RNSVGBrush *)fill
{
if (fill == _fill) {

View File

@@ -141,7 +141,7 @@ void setCommonRenderableProps(const T &renderableProps, RNSVGRenderable *rendera
{
setCommonNodeProps(renderableProps, renderableNode);
if (RCTUIColorFromSharedColor(renderableProps.color)) {
renderableNode.tintColor = RCTUIColorFromSharedColor(renderableProps.color);
[renderableNode setColor:RCTUIColorFromSharedColor(renderableProps.color)];
}
renderableNode.fill = brushFromColorStruct(renderableProps.fill);
renderableNode.fillOpacity = renderableProps.fillOpacity;