Skip to content

Commit

Permalink
fix radius not applying on initial render
Browse files Browse the repository at this point in the history
  • Loading branch information
gokul1099 committed Jan 23, 2024
1 parent c65f31e commit c627777
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,10 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
}

// `border`
if (oldViewProps.borderStyles != newViewProps.borderStyles ||
if (oldViewProps.borderStyles != newViewProps.borderStyles || oldViewProps.borderRadii != newViewProps.borderRadii ||
oldViewProps.borderColors != newViewProps.borderColors) {
needsInvalidateLayer = YES;
}
// 'borderRadii'
if (oldViewProps.borderRadii != newViewProps.borderRadii) {
needsInvalidateLayer = YES;
}
#if TARGET_OS_VISION
if (oldViewProps.visionos_hoverEffect != newViewProps.visionos_hoverEffect) {
needsInvalidateLayer = YES;
Expand Down Expand Up @@ -690,14 +686,7 @@ - (void)invalidateLayer
_borderLayer.contentsCenter = CGRect{CGPoint{0.0, 0.0}, CGSize{1.0, 1.0}};
}
}
// HoverEffect borderRadius for visionos
if(TARGET_OS_VISION){
const RCTCornerInsets cornerInsets =
RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero);
CGPathRef cornerRadiusPath = RCTPathCreateWithRoundedRect(self.bounds, cornerInsets, nil);
const char *vision_hoverstyle = _props->visionos_hoverEffect.c_str();
[self updateHoverEffect:[NSString stringWithUTF8String:vision_hoverstyle] withPathRef:cornerRadiusPath];
}


// Stage 2.5. Custom Clipping Mask
CAShapeLayer *maskLayer = nil;
Expand All @@ -722,6 +711,14 @@ - (void)invalidateLayer
layer.cornerRadius = cornerRadius;
layer.mask = maskLayer;
}
// Creating path for HoverEffect for visionos using cornerinsets
if(TARGET_OS_VISION){
const RCTCornerInsets cornerInsets =
RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero);
CGPathRef cornerRadiusPath = RCTPathCreateWithRoundedRect(self.bounds, cornerInsets, nil);
const char *vision_hoverstyle = _props->visionos_hoverEffect.c_str();
[self updateHoverEffect:[NSString stringWithUTF8String:vision_hoverstyle] withPathRef:cornerRadiusPath];
}
}

#pragma mark - Accessibility
Expand Down

0 comments on commit c627777

Please sign in to comment.