Skip to content

Commit

Permalink
[0.73-stable] Fix transform prop on View component (#2103)
Browse files Browse the repository at this point in the history
* Fix transform prop

* Add macOS tag

* Move transform updating logic on Mac to RCTView

* Address PR comments

---------

Co-authored-by: Adam Gleitman <adgleitm@microsoft.com>
  • Loading branch information
amgleitman and Adam Gleitman authored Mar 25, 2024
1 parent 57fa6c1 commit 6f12730
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/react-native/React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,14 @@ - (void)displayLayer:(CALayer *)layer
[self updateClippingForLayer:layer];
}

#if TARGET_OS_OSX // [macOS
- (void)updateReactTransformInternal:(CATransform3D)transform
{
[self setTransform3D:transform];
[self setNeedsDisplay];
}
#endif // macOS]

static BOOL RCTLayerHasShadow(CALayer *layer)
{
return layer.shadowOpacity * CGColorGetAlpha(layer.shadowColor) > 0;
Expand Down
8 changes: 8 additions & 0 deletions packages/react-native/React/Views/UIView+React.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@
*/
- (void)reactSetFrame:(CGRect)frame;


#if TARGET_OS_OSX // [macOS
/**
* Used by macOS to propagate transform changes internally.
*/
- (void)updateReactTransformInternal:(CATransform3D)transform;
#endif // macOS]

/**
* This method finds and returns the containing view controller for the view.
*/
Expand Down
11 changes: 11 additions & 0 deletions packages/react-native/React/Views/UIView+React.m
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,21 @@ static void updateTransform(RCTPlatformView *view) // [macOS]
transform = view.reactTransform;
}

#if !TARGET_OS_OSX // [macOS]
view.layer.transform = transform;
// Enable edge antialiasing in rotation, skew, or perspective transforms
view.layer.allowsEdgeAntialiasing = transform.m12 != 0.0f || transform.m21 != 0.0f || transform.m34 != 0.0f;
#else // [macOS
[view updateReactTransformInternal:transform];
#endif // macOS]
}

#if TARGET_OS_OSX // [macOS
- (void)updateReactTransformInternal:(CATransform3D)transform
{
// Do nothing, this will get overridden by RCTView and other subclasses as needed.
}
#endif // macOS]

- (UIViewController *)reactViewController
{
Expand Down

0 comments on commit 6f12730

Please sign in to comment.