Skip to content

Commit

Permalink
feat: invalidate on color change (#2470)
Browse files Browse the repository at this point in the history
# Summary

Invalidate element when `color` prop changes.
  • Loading branch information
jakex7 authored Oct 2, 2024
1 parent b4dc975 commit f1d33a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apple/RNSVGRenderable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions apple/RNSVGRenderable.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ - (void)invalidate
self.dirty = true;
}

- (void)setColor:(RNSVGColor *)color
{
if (color == self.tintColor) {
return;
}
[self invalidate];
self.tintColor = color;
}

- (void)setFill:(RNSVGBrush *)fill
{
if (fill == _fill) {
Expand Down
2 changes: 1 addition & 1 deletion apple/Utils/RNSVGFabricConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f1d33a4

Please sign in to comment.