mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3093010ea5
Summary: This diff moves fabric C++ code from ReactCommon/fabric to ReactCommon/react/renderer As part of this diff I also refactored components, codegen and callsites on CatalystApp, FB4A and venice Script: P137350694 changelog: [internal] internal refactor Reviewed By: fkgozali Differential Revision: D22852139 fbshipit-source-id: f85310ba858b6afd81abfd9cbe6d70b28eca7415
103 lines
3.0 KiB
Objective-C
103 lines
3.0 KiB
Objective-C
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* 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>
|
|
|
|
#include <react/renderer/textlayoutmanager/RCTFontProperties.h>
|
|
#include <react/renderer/textlayoutmanager/RCTFontUtils.h>
|
|
|
|
using namespace facebook::react;
|
|
|
|
inline static NSTextAlignment RCTNSTextAlignmentFromTextAlignment(TextAlignment textAlignment)
|
|
{
|
|
switch (textAlignment) {
|
|
case TextAlignment::Natural:
|
|
return NSTextAlignmentNatural;
|
|
case TextAlignment::Left:
|
|
return NSTextAlignmentLeft;
|
|
case TextAlignment::Right:
|
|
return NSTextAlignmentRight;
|
|
case TextAlignment::Center:
|
|
return NSTextAlignmentCenter;
|
|
case TextAlignment::Justified:
|
|
return NSTextAlignmentJustified;
|
|
}
|
|
}
|
|
|
|
inline static NSWritingDirection RCTNSWritingDirectionFromWritingDirection(WritingDirection writingDirection)
|
|
{
|
|
switch (writingDirection) {
|
|
case WritingDirection::Natural:
|
|
return NSWritingDirectionNatural;
|
|
case WritingDirection::LeftToRight:
|
|
return NSWritingDirectionLeftToRight;
|
|
case WritingDirection::RightToLeft:
|
|
return NSWritingDirectionRightToLeft;
|
|
}
|
|
}
|
|
|
|
inline static RCTFontStyle RCTFontStyleFromFontStyle(FontStyle fontStyle)
|
|
{
|
|
switch (fontStyle) {
|
|
case FontStyle::Normal:
|
|
return RCTFontStyleNormal;
|
|
case FontStyle::Italic:
|
|
return RCTFontStyleItalic;
|
|
case FontStyle::Oblique:
|
|
return RCTFontStyleOblique;
|
|
}
|
|
}
|
|
|
|
inline static RCTFontVariant RCTFontVariantFromFontVariant(FontVariant fontVariant)
|
|
{
|
|
return (RCTFontVariant)fontVariant;
|
|
}
|
|
|
|
inline static NSUnderlineStyle RCTNSUnderlineStyleFromStyleAndPattern(
|
|
TextDecorationLineStyle textDecorationLineStyle,
|
|
TextDecorationLinePattern textDecorationLinePattern)
|
|
{
|
|
NSUnderlineStyle style = NSUnderlineStyleNone;
|
|
|
|
switch (textDecorationLineStyle) {
|
|
case TextDecorationLineStyle::Single:
|
|
style = NSUnderlineStyle(style | NSUnderlineStyleSingle);
|
|
break;
|
|
case TextDecorationLineStyle::Thick:
|
|
style = NSUnderlineStyle(style | NSUnderlineStyleThick);
|
|
break;
|
|
case TextDecorationLineStyle::Double:
|
|
style = NSUnderlineStyle(style | NSUnderlineStyleDouble);
|
|
break;
|
|
}
|
|
|
|
switch (textDecorationLinePattern) {
|
|
case TextDecorationLinePattern::Solid:
|
|
style = NSUnderlineStyle(style | NSUnderlinePatternSolid);
|
|
break;
|
|
case TextDecorationLinePattern::Dash:
|
|
style = NSUnderlineStyle(style | NSUnderlinePatternDash);
|
|
break;
|
|
case TextDecorationLinePattern::Dot:
|
|
style = NSUnderlineStyle(style | NSUnderlinePatternDot);
|
|
break;
|
|
case TextDecorationLinePattern::DashDot:
|
|
style = NSUnderlineStyle(style | NSUnderlinePatternDashDot);
|
|
break;
|
|
case TextDecorationLinePattern::DashDotDot:
|
|
style = NSUnderlineStyle(style | NSUnderlinePatternDashDotDot);
|
|
break;
|
|
}
|
|
|
|
return style;
|
|
}
|
|
|
|
inline static UIColor *RCTUIColorFromSharedColor(const SharedColor &color)
|
|
{
|
|
return color ? [UIColor colorWithCGColor:color.get()] : nil;
|
|
}
|