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
This commit is contained in:
Valentin Shergin 2018-06-15 11:25:34 -07:00 коммит произвёл Facebook Github Bot
Родитель 55f8cfe693
Коммит dc0ebf7cb0
2 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -110,6 +110,10 @@ using namespace facebook::react;
self.userInteractionEnabled = newViewProps.pointerEvents != PointerEventsMode::None;
}
// `transform`
if (oldViewProps.transform != newViewProps.transform) {
self.layer.transform = RCTCATransform3DFromTransformMatrix(newViewProps.transform);
self.layer.allowsEdgeAntialiasing = newViewProps.transform != Transform::Identity();
}
// TODO: Implement all sutable non-layout <View> props.

Просмотреть файл

@ -35,6 +35,28 @@ inline UIEdgeInsets RCTUIEdgeInsetsFromEdgeInsets(facebook::react::EdgeInsets ed
return {edgeInsets.top, edgeInsets.left, edgeInsets.bottom, edgeInsets.right};
}
inline CATransform3D RCTCATransform3DFromTransformMatrix(facebook::react::Transform transformMatrix) {
return {
(CGFloat)transformMatrix.matrix[0],
(CGFloat)transformMatrix.matrix[1],
(CGFloat)transformMatrix.matrix[2],
(CGFloat)transformMatrix.matrix[3],
(CGFloat)transformMatrix.matrix[4],
(CGFloat)transformMatrix.matrix[5],
(CGFloat)transformMatrix.matrix[6],
(CGFloat)transformMatrix.matrix[7],
(CGFloat)transformMatrix.matrix[8],
(CGFloat)transformMatrix.matrix[9],
(CGFloat)transformMatrix.matrix[10],
(CGFloat)transformMatrix.matrix[11],
(CGFloat)transformMatrix.matrix[12],
(CGFloat)transformMatrix.matrix[13],
(CGFloat)transformMatrix.matrix[14],
(CGFloat)transformMatrix.matrix[15]
};
}
inline facebook::react::Point RCTPointFromCGPoint(CGPoint point) {
return {point.x, point.y};
}