Permalink
Browse files

Adopting Yoga's YGConfig in RCTShadowView

Reviewed By: javache

Differential Revision: D4932540

fbshipit-source-id: 4a5ff3b34fc635b3291dff9a7c1a603179c90fa7
  • Loading branch information...
shergin authored and facebook-github-bot committed Apr 27, 2017
1 parent c6614f1 commit ca07a5fd5fbf819d870e8fc93e51407cc226b9ba
Showing with 21 additions and 2 deletions.
  1. +7 −0 React/Views/RCTShadowView.h
  2. +14 −2 React/Views/RCTShadowView.m
@@ -35,6 +35,13 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
*/
@interface RCTShadowView : NSObject <RCTComponent>
/**
* Yoga Config which will be used to create `yogaNode` property.
* Override in subclass to enable special Yoga features.
* Defaults to suitable to current device configuration.
*/
+ (YGConfigRef)yogaConfig;
/**
* RCTComponent interface.
*/
@@ -46,6 +46,18 @@ @implementation RCTShadowView
YGValue _borderMetaProps[META_PROP_COUNT];
}
+ (YGConfigRef)yogaConfig
{
static YGConfigRef yogaConfig;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
yogaConfig = YGConfigNew();
// Turnig off pixel rounding.
YGConfigSetPointScaleFactor(yogaConfig, 0.0);
});
return yogaConfig;
}
@synthesize reactTag = _reactTag;
// YogaNode API
@@ -318,7 +330,6 @@ - (BOOL)viewIsDescendantOf:(RCTShadowView *)ancestor
- (instancetype)init
{
if ((self = [super init])) {
_frame = CGRectMake(0, 0, YGUndefined, YGUndefined);
for (unsigned int ii = 0; ii < META_PROP_COUNT; ii++) {
@@ -335,7 +346,8 @@ - (instancetype)init
_reactSubviews = [NSMutableArray array];
_yogaNode = YGNodeNew();
_yogaNode = YGNodeNewWithConfig([[self class] yogaConfig]);
YGNodeSetContext(_yogaNode, (__bridge void *)self);
YGNodeSetPrintFunc(_yogaNode, RCTPrint);
}

0 comments on commit ca07a5f

Please sign in to comment.