2018-05-09 05:56:21 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-05-09 05:56:21 +00:00
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
2018-07-15 23:46:31 +00:00
|
|
|
#import <fabric/components/view/primitives.h>
|
2018-06-15 18:25:30 +00:00
|
|
|
#import <fabric/graphics/Color.h>
|
2018-05-09 05:56:21 +00:00
|
|
|
#import <fabric/graphics/Geometry.h>
|
2018-06-15 18:25:30 +00:00
|
|
|
|
2018-06-22 18:53:44 +00:00
|
|
|
inline NSString *_Nullable RCTNSStringFromString(const std::string &string, const NSStringEncoding &encoding = NSUTF8StringEncoding) {
|
|
|
|
return [NSString stringWithCString:string.c_str() encoding:encoding];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::string RCTStringFromNSString(NSString *string, const NSStringEncoding &encoding = NSUTF8StringEncoding) {
|
|
|
|
return [string cStringUsingEncoding:encoding];
|
|
|
|
}
|
|
|
|
|
2018-06-15 18:25:30 +00:00
|
|
|
inline UIColor *_Nullable RCTUIColorFromSharedColor(const facebook::react::SharedColor &sharedColor) {
|
|
|
|
return sharedColor ? [UIColor colorWithCGColor:sharedColor.get()] : nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline CGColorRef RCTCGColorRefFromSharedColor(const facebook::react::SharedColor &sharedColor) {
|
|
|
|
return sharedColor ? CGColorCreateCopy(sharedColor.get()) : nil;
|
|
|
|
}
|
2018-05-09 05:56:21 +00:00
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline CGPoint RCTCGPointFromPoint(const facebook::react::Point &point) {
|
2018-05-09 05:56:21 +00:00
|
|
|
return {point.x, point.y};
|
|
|
|
}
|
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline CGSize RCTCGSizeFromSize(const facebook::react::Size &size) {
|
2018-05-09 05:56:21 +00:00
|
|
|
return {size.width, size.height};
|
|
|
|
}
|
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline CGRect RCTCGRectFromRect(const facebook::react::Rect &rect) {
|
2018-05-09 05:56:21 +00:00
|
|
|
return {RCTCGPointFromPoint(rect.origin), RCTCGSizeFromSize(rect.size)};
|
|
|
|
}
|
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline UIEdgeInsets RCTUIEdgeInsetsFromEdgeInsets(const facebook::react::EdgeInsets &edgeInsets) {
|
2018-05-22 22:48:27 +00:00
|
|
|
return {edgeInsets.top, edgeInsets.left, edgeInsets.bottom, edgeInsets.right};
|
|
|
|
}
|
|
|
|
|
2018-06-15 18:25:34 +00:00
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline CATransform3D RCTCATransform3DFromTransformMatrix(const facebook::react::Transform &transformMatrix) {
|
2018-06-15 18:25:34 +00:00
|
|
|
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]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline facebook::react::Point RCTPointFromCGPoint(const CGPoint &point) {
|
2018-05-09 05:56:21 +00:00
|
|
|
return {point.x, point.y};
|
|
|
|
}
|
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline facebook::react::Size RCTSizeFromCGSize(const CGSize &size) {
|
2018-05-09 05:56:21 +00:00
|
|
|
return {size.width, size.height};
|
|
|
|
}
|
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline facebook::react::Rect RCTRectFromCGRect(const CGRect &rect) {
|
2018-05-09 05:56:21 +00:00
|
|
|
return {RCTPointFromCGPoint(rect.origin), RCTSizeFromCGSize(rect.size)};
|
|
|
|
}
|
2018-05-22 22:48:27 +00:00
|
|
|
|
2018-08-04 16:30:11 +00:00
|
|
|
inline facebook::react::EdgeInsets RCTEdgeInsetsFromUIEdgeInsets(const UIEdgeInsets &edgeInsets) {
|
2018-05-22 22:48:27 +00:00
|
|
|
return {edgeInsets.top, edgeInsets.left, edgeInsets.bottom, edgeInsets.right};
|
|
|
|
}
|