Skip to content

Commit

Permalink
iOS: fix up RNTesterPods
Browse files Browse the repository at this point in the history
Summary:
A few fixes:
* missing include: folly/Optional.h
* switch folly::Optional's `has_value()` to `hasValue()` for now until folly is upgraded to newer version
* fix up import for RCTTextAttributes.h
* fix up includes for "conversions.h" to use namespaced includes

Reviewed By: mmmulani

Differential Revision: D8021149

fbshipit-source-id: d3955986d3ab6b1d9b61ac1e385767893ce57e5e
  • Loading branch information
fkgozali authored and facebook-github-bot committed May 16, 2018
1 parent 8c74864 commit 128c934
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 29 deletions.
3 changes: 2 additions & 1 deletion Libraries/Text/RCTConvert+Text.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

#import <React/RCTConvert.h>
#import <RCTText/RCTTextTransform.h>

#import "RCTTextTransform.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
3 changes: 2 additions & 1 deletion Libraries/Text/RCTTextAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#import <UIKit/UIKit.h>

#import <React/RCTTextDecorationLineType.h>
#import <RCTText/RCTTextTransform.h>

#import "RCTTextTransform.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
6 changes: 3 additions & 3 deletions RNTester/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ DEPENDENCIES:
- yoga (from `../ReactCommon/yoga`)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
https://github.com/cocoapods/specs.git:
- boost-for-react-native

EXTERNAL SOURCES:
Expand All @@ -135,9 +135,9 @@ SPEC CHECKSUMS:
DoubleConversion: e22e0762848812a87afd67ffda3998d9ef29170c
Folly: 9a8eea4725a0b6ba3256ebf206c21e352c23abf8
glog: 1de0bb937dccdc981596d3b5825ebfb765017ded
React: 512b17e881b5d04d703cd292caa6f4fe12984688
React: 3d56cdd885ecc0f2f3534b2f54a11cf9707229fb
yoga: bdd268c5812f00bdb52cc2b58f129797e97935eb

PODFILE CHECKSUM: 1a96172007b66aa74825c234f17139dd9c3d3cd7

COCOAPODS: 1.5.0
COCOAPODS: 1.5.2
2 changes: 1 addition & 1 deletion React.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Pod::Spec.new do |s|
ss.subspec "textlayoutmanager" do |sss|
sss.dependency "Folly", folly_version
sss.compiler_flags = folly_compiler_flags
sss.source_files = "ReactCommon/fabric/textlayoutmanager/**/*.{cpp,h}"
sss.source_files = "ReactCommon/fabric/textlayoutmanager/**/*.{cpp,h,mm}"
sss.exclude_files = "**/tests/*"
sss.header_dir = "fabric/textlayoutmanager"
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" }
Expand Down
24 changes: 12 additions & 12 deletions ReactCommon/fabric/attributedstring/TextAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ void TextAttributes::apply(TextAttributes textAttributes) {
fontFamily = !textAttributes.fontFamily.empty() ? textAttributes.fontFamily : fontFamily;
fontSize = !isnan(textAttributes.fontSize) ? textAttributes.fontSize : fontSize;
fontSizeMultiplier = !isnan(textAttributes.fontSizeMultiplier) ? textAttributes.fontSizeMultiplier : fontSizeMultiplier;
fontWeight = textAttributes.fontWeight.has_value() ? textAttributes.fontWeight : fontWeight;
fontStyle = textAttributes.fontStyle.has_value() ? textAttributes.fontStyle : fontStyle;
fontVariant = textAttributes.fontVariant.has_value() ? textAttributes.fontVariant : fontVariant;
allowFontScaling = textAttributes.allowFontScaling.has_value() ? textAttributes.allowFontScaling : allowFontScaling;
fontWeight = textAttributes.fontWeight.hasValue() ? textAttributes.fontWeight : fontWeight;
fontStyle = textAttributes.fontStyle.hasValue() ? textAttributes.fontStyle : fontStyle;
fontVariant = textAttributes.fontVariant.hasValue() ? textAttributes.fontVariant : fontVariant;
allowFontScaling = textAttributes.allowFontScaling.hasValue() ? textAttributes.allowFontScaling : allowFontScaling;
letterSpacing = !isnan(textAttributes.letterSpacing) ? textAttributes.letterSpacing : letterSpacing;

// Paragraph Styles
lineHeight = !isnan(textAttributes.lineHeight) ? textAttributes.lineHeight : lineHeight;
alignment = textAttributes.alignment.has_value() ? textAttributes.alignment : alignment;
baseWritingDirection = textAttributes.baseWritingDirection.has_value() ? textAttributes.baseWritingDirection : baseWritingDirection;
alignment = textAttributes.alignment.hasValue() ? textAttributes.alignment : alignment;
baseWritingDirection = textAttributes.baseWritingDirection.hasValue() ? textAttributes.baseWritingDirection : baseWritingDirection;

// Decoration
textDecorationColor = textAttributes.textDecorationColor ? textAttributes.textDecorationColor : textDecorationColor;
textDecorationLineType = textAttributes.textDecorationLineType.has_value() ? textAttributes.textDecorationLineType : textDecorationLineType;
textDecorationLineStyle = textAttributes.textDecorationLineStyle.has_value() ? textAttributes.textDecorationLineStyle : textDecorationLineStyle;
textDecorationLinePattern = textAttributes.textDecorationLinePattern.has_value() ? textAttributes.textDecorationLinePattern : textDecorationLinePattern;
textDecorationLineType = textAttributes.textDecorationLineType.hasValue() ? textAttributes.textDecorationLineType : textDecorationLineType;
textDecorationLineStyle = textAttributes.textDecorationLineStyle.hasValue() ? textAttributes.textDecorationLineStyle : textDecorationLineStyle;
textDecorationLinePattern = textAttributes.textDecorationLinePattern.hasValue() ? textAttributes.textDecorationLinePattern : textDecorationLinePattern;

// Shadow
textShadowOffset = textAttributes.textShadowOffset.has_value() ? textAttributes.textShadowOffset.value() : textShadowOffset;
textShadowOffset = textAttributes.textShadowOffset.hasValue() ? textAttributes.textShadowOffset.value() : textShadowOffset;
textShadowRadius = !isnan(textAttributes.textShadowRadius) ? textAttributes.textShadowRadius : textShadowRadius;
textShadowColor = textAttributes.textShadowColor ? textAttributes.textShadowColor : textShadowColor;

// Special
isHighlighted = textAttributes.isHighlighted.has_value() ? textAttributes.isHighlighted : isHighlighted;
layoutDirection = textAttributes.layoutDirection.has_value() ? textAttributes.layoutDirection : layoutDirection;
isHighlighted = textAttributes.isHighlighted.hasValue() ? textAttributes.isHighlighted : isHighlighted;
layoutDirection = textAttributes.layoutDirection.hasValue() ? textAttributes.layoutDirection : layoutDirection;
}

#pragma mark - DebugStringConvertible
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/fabric/core/propsConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once

#include <folly/Optional.h>
#include <folly/dynamic.h>
#include <fabric/graphics/Color.h>
#include <fabric/graphics/Geometry.h>
Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/fabric/debug/debugStringConvertibleUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <fabric/debug/DebugStringConvertible.h>
#include <fabric/debug/DebugStringConvertibleItem.h>
#include <folly/Conv.h>
#include <folly/Optional.h>

namespace facebook {
namespace react {
Expand All @@ -36,7 +37,7 @@ inline SharedDebugStringConvertible debugStringConvertibleItem(std::string name,

template <typename T>
inline SharedDebugStringConvertible debugStringConvertibleItem(std::string name, folly::Optional<T> value, T defaultValue = {}) {
if (!value.has_value()) {
if (!value.hasValue()) {
return nullptr;
}

Expand Down
12 changes: 6 additions & 6 deletions ReactCommon/fabric/textlayoutmanager/RCTAttributedTextUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
RCTFontProperties fontProperties;
fontProperties.family = fontFamily;
fontProperties.size = textAttributes.fontSize;
fontProperties.style = textAttributes.fontStyle.has_value() ? RCTFontStyleFromFontStyle(textAttributes.fontStyle.value()) : RCTFontStyleUndefined;
fontProperties.variant = textAttributes.fontVariant.has_value() ? RCTFontVariantFromFontVariant(textAttributes.fontVariant.value()) : RCTFontVariantDefault;
fontProperties.weight = textAttributes.fontWeight.has_value() ? CGFloat(textAttributes.fontWeight.value()) : NAN;
fontProperties.style = textAttributes.fontStyle.hasValue() ? RCTFontStyleFromFontStyle(textAttributes.fontStyle.value()) : RCTFontStyleUndefined;
fontProperties.variant = textAttributes.fontVariant.hasValue() ? RCTFontVariantFromFontVariant(textAttributes.fontVariant.value()) : RCTFontVariantDefault;
fontProperties.weight = textAttributes.fontWeight.hasValue() ? CGFloat(textAttributes.fontWeight.value()) : NAN;
fontProperties.sizeMultiplier = textAttributes.fontSizeMultiplier;

return RCTFontWithFontProperties(fontProperties);
Expand Down Expand Up @@ -82,7 +82,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
// Paragraph Style
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
BOOL isParagraphStyleUsed = NO;
if (textAttributes.alignment.has_value()) {
if (textAttributes.alignment.hasValue()) {
TextAlignment textAlignment = textAttributes.alignment.value_or(TextAlignment::Natural);
if (textAttributes.layoutDirection.value_or(LayoutDirection::LeftToRight) == LayoutDirection::RightToLeft) {
if (textAlignment == TextAlignment::Right) {
Expand All @@ -97,7 +97,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
isParagraphStyleUsed = YES;
}

if (textAttributes.baseWritingDirection.has_value()) {
if (textAttributes.baseWritingDirection.hasValue()) {
paragraphStyle.baseWritingDirection =
RCTNSWritingDirectionFromWritingDirection(textAttributes.baseWritingDirection.value());
isParagraphStyleUsed = YES;
Expand Down Expand Up @@ -151,7 +151,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
}

// Shadow
if (textAttributes.textShadowOffset.has_value()) {
if (textAttributes.textShadowOffset.hasValue()) {
auto textShadowOffset = textAttributes.textShadowOffset.value();
NSShadow *shadow = [NSShadow new];
shadow.shadowOffset = CGSize {textShadowOffset.x, textShadowOffset.y};
Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/fabric/view/root/RootProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

#include "RootProps.h"

#include <fabric/view/conversions.h>

#include "YogaLayoutableShadowNode.h"
#include "conversions.h"

namespace facebook {
namespace react {
Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/fabric/view/root/RootShadowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

#include "RootShadowNode.h"
#include "conversions.h"

#include <fabric/view/conversions.h>

namespace facebook {
namespace react {
Expand Down
3 changes: 1 addition & 2 deletions ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
#include <fabric/core/LayoutContext.h>
#include <fabric/core/LayoutConstraints.h>
#include <fabric/debug/DebugStringConvertibleItem.h>
#include <fabric/view/conversions.h>
#include <yoga/Yoga.h>

#include "conversions.h"

namespace facebook {
namespace react {

Expand Down

0 comments on commit 128c934

Please sign in to comment.