Skip to content

Commit

Permalink
fix: new arch
Browse files Browse the repository at this point in the history
  • Loading branch information
jakex7 committed Oct 15, 2024
1 parent 95964d2 commit f53cdb5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions apple/Filters/RNSVGFeFlood.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ + (void)load
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
static const auto defaultProps = std::make_shared<const RNSVGFeColorMatrixProps>();
static const auto defaultProps = std::make_shared<const RNSVGFeFloodProps>();
_props = defaultProps;
}
return self;
Expand All @@ -33,22 +33,28 @@ - (instancetype)initWithFrame:(CGRect)frame

+ (ComponentDescriptorProvider)componentDescriptorProvider
{
return concreteComponentDescriptorProvider<RNSVGFeColorMatrixComponentDescriptor>();
return concreteComponentDescriptorProvider<RNSVGFeFloodComponentDescriptor>();
}

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = static_cast<const RNSVGFeColorMatrixProps &>(*props);
const auto &newProps = static_cast<const RNSVGFeFloodProps &>(*props);

id floodColor = RNSVGConvertFollyDynamicToId(newProps.floodColor);
if (floodColor != nil) {
self.floodColor = [RCTConvert RNSVGBrush:floodColor];
}
self.floodOpacity = newProps.floodOpacity;

setCommonFilterProps(newProps, self);
_props = std::static_pointer_cast<RNSVGFeColorMatrixProps const>(props);
_props = std::static_pointer_cast<RNSVGFeFloodProps const>(props);
}

- (void)prepareForRecycle
{
[super prepareForRecycle];
_floodColor = nil;
_floodOpacity = nil;
_floodOpacity = 1;
}
#endif // RCT_NEW_ARCH_ENABLED

Expand All @@ -57,25 +63,22 @@ - (void)setFloodColor:(RNSVGBrush *)floodColor
if (floodColor == _floodColor) {
return;
}
[self invalidate];
_floodColor = floodColor;
[self invalidate];
}

- (void)setFloodOpacity:(CGFloat)floodOpacity
{
if (floodOpacity == _floodOpacity) {
return;
}
[self invalidate];
_floodOpacity = floodOpacity;
[self invalidate];
}

- (CIImage *)applyFilter:(NSMutableDictionary<NSString *, CIImage *> *)results previousFilterResult:(CIImage *)previous
{
// [CIImage imageWithColor:[self.floodColor ]];
CIImage *res =
[CIImage imageWithColor:[CIColor colorWithCGColor:[self.floodColor getColorWithOpacity:self.floodOpacity]]];
return res;
return [CIImage imageWithColor:[CIColor colorWithCGColor:[self.floodColor getColorWithOpacity:self.floodOpacity]]];
}

#ifdef RCT_NEW_ARCH_ENABLED
Expand Down

0 comments on commit f53cdb5

Please sign in to comment.