Skip to content

Commit 255698f

Browse files
sherginmacdoum1
authored andcommitted
Fabric: Implementation of <View transform={...}/> property
Summary: After moving all matrix math to C++, the actual client native code is quite trivial. Reviewed By: fkgozali Differential Revision: D8344059 fbshipit-source-id: 6910c6af5de64d5f901e82075d30edbde177af40
1 parent 01501de commit 255698f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ - (void)updateProps:(SharedProps)props
110110
self.userInteractionEnabled = newViewProps.pointerEvents != PointerEventsMode::None;
111111
}
112112

113+
// `transform`
114+
if (oldViewProps.transform != newViewProps.transform) {
115+
self.layer.transform = RCTCATransform3DFromTransformMatrix(newViewProps.transform);
116+
self.layer.allowsEdgeAntialiasing = newViewProps.transform != Transform::Identity();
113117
}
114118

115119
// TODO: Implement all sutable non-layout <View> props.

React/Fabric/RCTConversions.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,28 @@ inline UIEdgeInsets RCTUIEdgeInsetsFromEdgeInsets(facebook::react::EdgeInsets ed
3535
return {edgeInsets.top, edgeInsets.left, edgeInsets.bottom, edgeInsets.right};
3636
}
3737

38+
39+
inline CATransform3D RCTCATransform3DFromTransformMatrix(facebook::react::Transform transformMatrix) {
40+
return {
41+
(CGFloat)transformMatrix.matrix[0],
42+
(CGFloat)transformMatrix.matrix[1],
43+
(CGFloat)transformMatrix.matrix[2],
44+
(CGFloat)transformMatrix.matrix[3],
45+
(CGFloat)transformMatrix.matrix[4],
46+
(CGFloat)transformMatrix.matrix[5],
47+
(CGFloat)transformMatrix.matrix[6],
48+
(CGFloat)transformMatrix.matrix[7],
49+
(CGFloat)transformMatrix.matrix[8],
50+
(CGFloat)transformMatrix.matrix[9],
51+
(CGFloat)transformMatrix.matrix[10],
52+
(CGFloat)transformMatrix.matrix[11],
53+
(CGFloat)transformMatrix.matrix[12],
54+
(CGFloat)transformMatrix.matrix[13],
55+
(CGFloat)transformMatrix.matrix[14],
56+
(CGFloat)transformMatrix.matrix[15]
57+
};
58+
}
59+
3860
inline facebook::react::Point RCTPointFromCGPoint(CGPoint point) {
3961
return {point.x, point.y};
4062
}

0 commit comments

Comments
 (0)