first step in replacing the prefix in objc from YG to YK to allow redefining enums without the Count item
This commit is contained in:
@@ -1,72 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import <yoga/Yoga.h>
|
|
||||||
|
|
||||||
@interface UIView (Yoga)
|
|
||||||
|
|
||||||
/**
|
|
||||||
The property that decides if we should include this view when calculating layout. Defaults to YES.
|
|
||||||
*/
|
|
||||||
@property (nonatomic, readwrite, assign, setter=yg_setIncludeInLayout:) BOOL yg_includeInLayout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The property that decides during layout/sizing whether or not yg_* properties should be applied. Defaults to NO.
|
|
||||||
*/
|
|
||||||
@property (nonatomic, readwrite, assign, setter=yg_setUsesYoga:) BOOL yg_usesYoga;
|
|
||||||
|
|
||||||
- (void)yg_setDirection:(YGDirection)direction;
|
|
||||||
- (void)yg_setFlexDirection:(YGFlexDirection)flexDirection;
|
|
||||||
- (void)yg_setJustifyContent:(YGJustify)justifyContent;
|
|
||||||
- (void)yg_setAlignContent:(YGAlign)alignContent;
|
|
||||||
- (void)yg_setAlignItems:(YGAlign)alignItems;
|
|
||||||
- (void)yg_setAlignSelf:(YGAlign)alignSelf;
|
|
||||||
- (void)yg_setPositionType:(YGPositionType)positionType;
|
|
||||||
- (void)yg_setFlexWrap:(YGWrap)flexWrap;
|
|
||||||
|
|
||||||
- (void)yg_setFlexGrow:(CGFloat)flexGrow;
|
|
||||||
- (void)yg_setFlexShrink:(CGFloat)flexShrink;
|
|
||||||
- (void)yg_setFlexBasis:(CGFloat)flexBasis;
|
|
||||||
|
|
||||||
- (void)yg_setPosition:(CGFloat)position forEdge:(YGEdge)edge;
|
|
||||||
- (void)yg_setMargin:(CGFloat)margin forEdge:(YGEdge)edge;
|
|
||||||
- (void)yg_setPadding:(CGFloat)padding forEdge:(YGEdge)edge;
|
|
||||||
|
|
||||||
- (void)yg_setWidth:(CGFloat)width;
|
|
||||||
- (void)yg_setHeight:(CGFloat)height;
|
|
||||||
- (void)yg_setMinWidth:(CGFloat)minWidth;
|
|
||||||
- (void)yg_setMinHeight:(CGFloat)minHeight;
|
|
||||||
- (void)yg_setMaxWidth:(CGFloat)maxWidth;
|
|
||||||
- (void)yg_setMaxHeight:(CGFloat)maxHeight;
|
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
|
||||||
- (void)yg_setAspectRatio:(CGFloat)aspectRatio;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the resolved direction of this node. This won't be YGDirectionInherit
|
|
||||||
*/
|
|
||||||
- (YGDirection)yg_resolvedDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Perform a layout calculation and update the frames of the views in the hierarchy with the results
|
|
||||||
*/
|
|
||||||
- (void)yg_applyLayout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
|
||||||
*/
|
|
||||||
- (CGSize)yg_intrinsicSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the number of children that are using Flexbox.
|
|
||||||
*/
|
|
||||||
- (NSUInteger)yg_numberOfChildren;
|
|
||||||
|
|
||||||
@end
|
|
72
YogaKit/UIView+YogaKit.h
Normal file
72
YogaKit/UIView+YogaKit.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "YKEnums.h"
|
||||||
|
|
||||||
|
@interface UIView (YogaKit)
|
||||||
|
|
||||||
|
/**
|
||||||
|
The property that decides if we should include this view when calculating layout. Defaults to YES.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readwrite, assign, setter=yk_setIncludeInLayout:) BOOL yk_includeInLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The property that decides during layout/sizing whether or not yk_* properties should be applied. Defaults to NO.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readwrite, assign, setter=yk_setUsesYoga:) BOOL yk_usesYoga;
|
||||||
|
|
||||||
|
- (void)yk_setDirection:(YKDirection)direction;
|
||||||
|
- (void)yk_setFlexDirection:(YKFlexDirection)flexDirection;
|
||||||
|
- (void)yk_setJustifyContent:(YKJustify)justifyContent;
|
||||||
|
- (void)yk_setAlignContent:(YKAlign)alignContent;
|
||||||
|
- (void)yk_setAlignItems:(YKAlign)alignItems;
|
||||||
|
- (void)yk_setAlignSelf:(YKAlign)alignSelf;
|
||||||
|
- (void)yk_setPositionType:(YKPositionType)positionType;
|
||||||
|
- (void)yk_setFlexWrap:(YKWrap)flexWrap;
|
||||||
|
|
||||||
|
- (void)yk_setFlexGrow:(CGFloat)flexGrow;
|
||||||
|
- (void)yk_setFlexShrink:(CGFloat)flexShrink;
|
||||||
|
- (void)yk_setFlexBasis:(CGFloat)flexBasis;
|
||||||
|
|
||||||
|
- (void)yk_setPosition:(CGFloat)position forEdge:(YKEdge)edge;
|
||||||
|
- (void)yk_setMargin:(CGFloat)margin forEdge:(YKEdge)edge;
|
||||||
|
- (void)yk_setPadding:(CGFloat)padding forEdge:(YKEdge)edge;
|
||||||
|
|
||||||
|
- (void)yk_setWidth:(CGFloat)width;
|
||||||
|
- (void)yk_setHeight:(CGFloat)height;
|
||||||
|
- (void)yk_setMinWidth:(CGFloat)minWidth;
|
||||||
|
- (void)yk_setMinHeight:(CGFloat)minHeight;
|
||||||
|
- (void)yk_setMaxWidth:(CGFloat)maxWidth;
|
||||||
|
- (void)yk_setMaxHeight:(CGFloat)maxHeight;
|
||||||
|
|
||||||
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
|
- (void)yk_setAspectRatio:(CGFloat)aspectRatio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the resolved direction of this node. This won't be YGDirectionInherit
|
||||||
|
*/
|
||||||
|
- (YKDirection)yk_resolvedDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform a layout calculation and update the frames of the views in the hierarchy with the results
|
||||||
|
*/
|
||||||
|
- (void)yk_applyLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||||
|
*/
|
||||||
|
- (CGSize)yk_intrinsicSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the number of children that are using Flexbox.
|
||||||
|
*/
|
||||||
|
- (NSUInteger)yk_numberOfChildren;
|
||||||
|
|
||||||
|
@end
|
@@ -7,8 +7,8 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "UIView+Yoga.h"
|
#import <YogaKit/UIView+Yoga.h>
|
||||||
|
#import <YogaKit/yoga.h>
|
||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
@interface YGNodeBridge : NSObject
|
@interface YGNodeBridge : NSObject
|
||||||
@@ -37,164 +37,164 @@
|
|||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation UIView (Yoga)
|
@implementation UIView (YogaKit)
|
||||||
|
|
||||||
- (BOOL)yg_usesYoga
|
- (BOOL)yk_usesYoga
|
||||||
{
|
{
|
||||||
NSNumber *usesYoga = objc_getAssociatedObject(self, @selector(yg_usesYoga));
|
NSNumber *usesYoga = objc_getAssociatedObject(self, @selector(yk_usesYoga));
|
||||||
return [usesYoga boolValue];
|
return [usesYoga boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)yg_includeInLayout
|
- (BOOL)yk_includeInLayout
|
||||||
{
|
{
|
||||||
NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(yg_includeInLayout));
|
NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(yk_includeInLayout));
|
||||||
return (includeInLayout != nil) ? [includeInLayout boolValue] : YES;
|
return (includeInLayout != nil) ? [includeInLayout boolValue] : YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUInteger)yg_numberOfChildren
|
- (NSUInteger)yk_numberOfChildren
|
||||||
{
|
{
|
||||||
return YGNodeGetChildCount([self ygNode]);
|
return YGNodeGetChildCount([self ygNode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Setters
|
#pragma mark - Setters
|
||||||
|
|
||||||
- (void)yg_setIncludeInLayout:(BOOL)includeInLayout
|
- (void)yk_setIncludeInLayout:(BOOL)includeInLayout
|
||||||
{
|
{
|
||||||
objc_setAssociatedObject(
|
objc_setAssociatedObject(
|
||||||
self,
|
self,
|
||||||
@selector(yg_includeInLayout),
|
@selector(yk_includeInLayout),
|
||||||
@(includeInLayout),
|
@(includeInLayout),
|
||||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setUsesYoga:(BOOL)enabled
|
- (void)yk_setUsesYoga:(BOOL)enabled
|
||||||
{
|
{
|
||||||
objc_setAssociatedObject(
|
objc_setAssociatedObject(
|
||||||
self,
|
self,
|
||||||
@selector(yg_usesYoga),
|
@selector(yk_usesYoga),
|
||||||
@(enabled),
|
@(enabled),
|
||||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setDirection:(YGDirection)direction
|
- (void)yk_setDirection:(YKDirection)direction
|
||||||
{
|
{
|
||||||
YGNodeStyleSetDirection([self ygNode], direction);
|
YGNodeStyleSetDirection([self ygNode], (YGDirection)direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setFlexDirection:(YGFlexDirection)flexDirection
|
- (void)yk_setFlexDirection:(YKFlexDirection)flexDirection
|
||||||
{
|
{
|
||||||
YGNodeStyleSetFlexDirection([self ygNode], flexDirection);
|
YGNodeStyleSetFlexDirection([self ygNode], (YGFlexDirection)flexDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setJustifyContent:(YGJustify)justifyContent
|
- (void)yk_setJustifyContent:(YKJustify)justifyContent
|
||||||
{
|
{
|
||||||
YGNodeStyleSetJustifyContent([self ygNode], justifyContent);
|
YGNodeStyleSetJustifyContent([self ygNode], (YGJustify)justifyContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setAlignContent:(YGAlign)alignContent
|
- (void)yk_setAlignContent:(YKAlign)alignContent
|
||||||
{
|
{
|
||||||
YGNodeStyleSetAlignContent([self ygNode], alignContent);
|
YGNodeStyleSetAlignContent([self ygNode], (YGAlign)alignContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setAlignItems:(YGAlign)alignItems
|
- (void)yk_setAlignItems:(YKAlign)alignItems
|
||||||
{
|
{
|
||||||
YGNodeStyleSetAlignItems([self ygNode], alignItems);
|
YGNodeStyleSetAlignItems([self ygNode], (YGAlign)alignItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setAlignSelf:(YGAlign)alignSelf
|
- (void)yk_setAlignSelf:(YKAlign)alignSelf
|
||||||
{
|
{
|
||||||
YGNodeStyleSetAlignSelf([self ygNode], alignSelf);
|
YGNodeStyleSetAlignSelf([self ygNode], (YGAlign)alignSelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setPositionType:(YGPositionType)positionType
|
- (void)yk_setPositionType:(YKPositionType)positionType
|
||||||
{
|
{
|
||||||
YGNodeStyleSetPositionType([self ygNode], positionType);
|
YGNodeStyleSetPositionType([self ygNode], (YGPositionType)positionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setFlexWrap:(YGWrap)flexWrap
|
- (void)yk_setFlexWrap:(YKWrap)flexWrap
|
||||||
{
|
{
|
||||||
YGNodeStyleSetFlexWrap([self ygNode], flexWrap);
|
YGNodeStyleSetFlexWrap([self ygNode], (YGWrap)flexWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setFlexGrow:(CGFloat)flexGrow
|
- (void)yk_setFlexGrow:(CGFloat)flexGrow
|
||||||
{
|
{
|
||||||
YGNodeStyleSetFlexGrow([self ygNode], flexGrow);
|
YGNodeStyleSetFlexGrow([self ygNode], flexGrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setFlexShrink:(CGFloat)flexShrink
|
- (void)yk_setFlexShrink:(CGFloat)flexShrink
|
||||||
{
|
{
|
||||||
YGNodeStyleSetFlexShrink([self ygNode], flexShrink);
|
YGNodeStyleSetFlexShrink([self ygNode], flexShrink);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setFlexBasis:(CGFloat)flexBasis
|
- (void)yk_setFlexBasis:(CGFloat)flexBasis
|
||||||
{
|
{
|
||||||
YGNodeStyleSetFlexBasis([self ygNode], flexBasis);
|
YGNodeStyleSetFlexBasis([self ygNode], flexBasis);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setPosition:(CGFloat)position forEdge:(YGEdge)edge
|
- (void)yk_setPosition:(CGFloat)position forEdge:(YKEdge)edge
|
||||||
{
|
{
|
||||||
YGNodeStyleSetPosition([self ygNode], edge, position);
|
YGNodeStyleSetPosition([self ygNode], (YGEdge)edge, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setMargin:(CGFloat)margin forEdge:(YGEdge)edge
|
- (void)yk_setMargin:(CGFloat)margin forEdge:(YKEdge)edge
|
||||||
{
|
{
|
||||||
YGNodeStyleSetMargin([self ygNode], edge, margin);
|
YGNodeStyleSetMargin([self ygNode], (YGEdge)edge, margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setPadding:(CGFloat)padding forEdge:(YGEdge)edge
|
- (void)yk_setPadding:(CGFloat)padding forEdge:(YKEdge)edge
|
||||||
{
|
{
|
||||||
YGNodeStyleSetPadding([self ygNode], edge, padding);
|
YGNodeStyleSetPadding([self ygNode], (YGEdge)edge, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setWidth:(CGFloat)width
|
- (void)yk_setWidth:(CGFloat)width
|
||||||
{
|
{
|
||||||
YGNodeStyleSetWidth([self ygNode], width);
|
YGNodeStyleSetWidth([self ygNode], width);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setHeight:(CGFloat)height
|
- (void)yk_setHeight:(CGFloat)height
|
||||||
{
|
{
|
||||||
YGNodeStyleSetHeight([self ygNode], height);
|
YGNodeStyleSetHeight([self ygNode], height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setMinWidth:(CGFloat)minWidth
|
- (void)yk_setMinWidth:(CGFloat)minWidth
|
||||||
{
|
{
|
||||||
YGNodeStyleSetMinWidth([self ygNode], minWidth);
|
YGNodeStyleSetMinWidth([self ygNode], minWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setMinHeight:(CGFloat)minHeight
|
- (void)yk_setMinHeight:(CGFloat)minHeight
|
||||||
{
|
{
|
||||||
YGNodeStyleSetMinHeight([self ygNode], minHeight);
|
YGNodeStyleSetMinHeight([self ygNode], minHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setMaxWidth:(CGFloat)maxWidth
|
- (void)yk_setMaxWidth:(CGFloat)maxWidth
|
||||||
{
|
{
|
||||||
YGNodeStyleSetMaxWidth([self ygNode], maxWidth);
|
YGNodeStyleSetMaxWidth([self ygNode], maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setMaxHeight:(CGFloat)maxHeight
|
- (void)yk_setMaxHeight:(CGFloat)maxHeight
|
||||||
{
|
{
|
||||||
YGNodeStyleSetMaxHeight([self ygNode], maxHeight);
|
YGNodeStyleSetMaxHeight([self ygNode], maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_setAspectRatio:(CGFloat)aspectRatio
|
- (void)yk_setAspectRatio:(CGFloat)aspectRatio
|
||||||
{
|
{
|
||||||
YGNodeStyleSetAspectRatio([self ygNode], aspectRatio);
|
YGNodeStyleSetAspectRatio([self ygNode], aspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Layout and Sizing
|
#pragma mark - Layout and Sizing
|
||||||
|
|
||||||
- (YGDirection)yg_resolvedDirection
|
- (YKDirection)yk_resolvedDirection
|
||||||
{
|
{
|
||||||
return YGNodeLayoutGetDirection([self ygNode]);
|
return (YKDirection)YGNodeLayoutGetDirection([self ygNode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)yg_applyLayout
|
- (void)yk_applyLayout
|
||||||
{
|
{
|
||||||
[self calculateLayoutWithSize:self.bounds.size];
|
[self calculateLayoutWithSize:self.bounds.size];
|
||||||
YGApplyLayoutToViewHierarchy(self);
|
YKApplyLayoutToViewHierarchy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGSize)yg_intrinsicSize
|
- (CGSize)yk_intrinsicSize
|
||||||
{
|
{
|
||||||
const CGSize constrainedSize = {
|
const CGSize constrainedSize = {
|
||||||
.width = YGUndefined,
|
.width = YGUndefined,
|
||||||
@@ -220,9 +220,9 @@
|
|||||||
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
||||||
{
|
{
|
||||||
NSAssert([NSThread isMainThread], @"YG Layout calculation must be done on main.");
|
NSAssert([NSThread isMainThread], @"YG Layout calculation must be done on main.");
|
||||||
NSAssert([self yg_usesYoga], @"YG Layout is not enabled for this view.");
|
NSAssert([self yk_usesYoga], @"YG Layout is not enabled for this view.");
|
||||||
|
|
||||||
YGAttachNodesFromViewHierachy(self);
|
YKAttachNodesFromViewHierachy(self);
|
||||||
|
|
||||||
const YGNodeRef node = [self ygNode];
|
const YGNodeRef node = [self ygNode];
|
||||||
YGNodeCalculateLayout(
|
YGNodeCalculateLayout(
|
||||||
@@ -237,7 +237,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static YGSize YGMeasureView(
|
static YGSize YKMeasureView(
|
||||||
YGNodeRef node,
|
YGNodeRef node,
|
||||||
float width,
|
float width,
|
||||||
YGMeasureMode widthMode,
|
YGMeasureMode widthMode,
|
||||||
@@ -254,12 +254,12 @@ static YGSize YGMeasureView(
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
return (YGSize) {
|
return (YGSize) {
|
||||||
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
.width = YKSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
||||||
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
.height = YKSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGFloat YGSanitizeMeasurement(
|
static CGFloat YKSanitizeMeasurement(
|
||||||
CGFloat constrainedSize,
|
CGFloat constrainedSize,
|
||||||
CGFloat measuredSize,
|
CGFloat measuredSize,
|
||||||
YGMeasureMode measureMode)
|
YGMeasureMode measureMode)
|
||||||
@@ -276,20 +276,20 @@ static CGFloat YGSanitizeMeasurement(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGAttachNodesFromViewHierachy(UIView *view) {
|
static void YKAttachNodesFromViewHierachy(UIView *view) {
|
||||||
YGNodeRef node = [view ygNode];
|
YGNodeRef node = [view ygNode];
|
||||||
|
|
||||||
// Only leaf nodes should have a measure function
|
// Only leaf nodes should have a measure function
|
||||||
if (![view yg_usesYoga] || view.subviews.count == 0) {
|
if (![view yk_usesYoga] || view.subviews.count == 0) {
|
||||||
YGNodeSetMeasureFunc(node, YGMeasureView);
|
YGNodeSetMeasureFunc(node, YKMeasureView);
|
||||||
YGRemoveAllChildren(node);
|
YKRemoveAllChildren(node);
|
||||||
} else {
|
} else {
|
||||||
YGNodeSetMeasureFunc(node, NULL);
|
YGNodeSetMeasureFunc(node, NULL);
|
||||||
|
|
||||||
// Create a list of all the subviews that we are going to use for layout.
|
// Create a list of all the subviews that we are going to use for layout.
|
||||||
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
||||||
for (UIView *subview in view.subviews) {
|
for (UIView *subview in view.subviews) {
|
||||||
if ([subview yg_includeInLayout]) {
|
if ([subview yk_includeInLayout]) {
|
||||||
[subviewsToInclude addObject:subview];
|
[subviewsToInclude addObject:subview];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,18 +307,18 @@ static void YGAttachNodesFromViewHierachy(UIView *view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shouldReconstructChildList) {
|
if (shouldReconstructChildList) {
|
||||||
YGRemoveAllChildren(node);
|
YKRemoveAllChildren(node);
|
||||||
|
|
||||||
for (int i = 0 ; i < subviewsToInclude.count; i++) {
|
for (int i = 0 ; i < subviewsToInclude.count; i++) {
|
||||||
UIView *const subview = subviewsToInclude[i];
|
UIView *const subview = subviewsToInclude[i];
|
||||||
YGNodeInsertChild(node, [subview ygNode], i);
|
YGNodeInsertChild(node, [subview ygNode], i);
|
||||||
YGAttachNodesFromViewHierachy(subview);
|
YKAttachNodesFromViewHierachy(subview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGRemoveAllChildren(const YGNodeRef node)
|
static void YKRemoveAllChildren(const YGNodeRef node)
|
||||||
{
|
{
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
return;
|
return;
|
||||||
@@ -329,7 +329,7 @@ static void YGRemoveAllChildren(const YGNodeRef node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGFloat YGRoundPixelValue(CGFloat value)
|
static CGFloat YKRoundPixelValue(CGFloat value)
|
||||||
{
|
{
|
||||||
static CGFloat scale;
|
static CGFloat scale;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
@@ -340,9 +340,9 @@ static CGFloat YGRoundPixelValue(CGFloat value)
|
|||||||
return round(value * scale) / scale;
|
return round(value * scale) / scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGApplyLayoutToViewHierarchy(UIView *view) {
|
static void YKApplyLayoutToViewHierarchy(UIView *view) {
|
||||||
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
||||||
if (![view yg_includeInLayout]) {
|
if (![view yk_includeInLayout]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,19 +359,19 @@ static void YGApplyLayoutToViewHierarchy(UIView *view) {
|
|||||||
|
|
||||||
view.frame = (CGRect) {
|
view.frame = (CGRect) {
|
||||||
.origin = {
|
.origin = {
|
||||||
.x = YGRoundPixelValue(topLeft.x),
|
.x = YKRoundPixelValue(topLeft.x),
|
||||||
.y = YGRoundPixelValue(topLeft.y),
|
.y = YKRoundPixelValue(topLeft.y),
|
||||||
},
|
},
|
||||||
.size = {
|
.size = {
|
||||||
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
|
.width = YKRoundPixelValue(bottomRight.x) - YKRoundPixelValue(topLeft.x),
|
||||||
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
|
.height = YKRoundPixelValue(bottomRight.y) - YKRoundPixelValue(topLeft.y),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const BOOL isLeaf = ![view yg_usesYoga] || view.subviews.count == 0;
|
const BOOL isLeaf = ![view yk_usesYoga] || view.subviews.count == 0;
|
||||||
if (!isLeaf) {
|
if (!isLeaf) {
|
||||||
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
||||||
YGApplyLayoutToViewHierarchy(view.subviews[i]);
|
YKApplyLayoutToViewHierarchy(view.subviews[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
96
YogaKit/YKEnums.h
Normal file
96
YogaKit/YKEnums.h
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKFlexDirection) {
|
||||||
|
YKFlexDirectionColumn,
|
||||||
|
YKFlexDirectionColumnReverse,
|
||||||
|
YKFlexDirectionRow,
|
||||||
|
YKFlexDirectionRowReverse,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKMeasureMode) {
|
||||||
|
YKMeasureModeUndefined,
|
||||||
|
YKMeasureModeExactly,
|
||||||
|
YKMeasureModeAtMost,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKPrintOptions) {
|
||||||
|
YKPrintOptionsLayout = 1,
|
||||||
|
YKPrintOptionsStyle = 2,
|
||||||
|
YKPrintOptionsChildren = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKEdge) {
|
||||||
|
YKEdgeLeft,
|
||||||
|
YKEdgeTop,
|
||||||
|
YKEdgeRight,
|
||||||
|
YKEdgeBottom,
|
||||||
|
YKEdgeStart,
|
||||||
|
YKEdgeEnd,
|
||||||
|
YKEdgeHorizontal,
|
||||||
|
YKEdgeVertical,
|
||||||
|
YKEdgeAll,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKPositionType) {
|
||||||
|
YKPositionTypeRelative,
|
||||||
|
YKPositionTypeAbsolute,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKDimension) {
|
||||||
|
YKDimensionWidth,
|
||||||
|
YKDimensionHeight,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKJustify) {
|
||||||
|
YKJustifyFlexStart,
|
||||||
|
YKJustifyCenter,
|
||||||
|
YKJustifyFlexEnd,
|
||||||
|
YKJustifySpaceBetween,
|
||||||
|
YKJustifySpaceAround,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKDirection) {
|
||||||
|
YKDirectionInherit,
|
||||||
|
YKDirectionLeftToRight,
|
||||||
|
YKDirectionRightToLeft,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKLogLevel) {
|
||||||
|
YKLogLevelError,
|
||||||
|
YKLogLevelWarn,
|
||||||
|
YKLogLevelInfo,
|
||||||
|
YKLogLevelDebug,
|
||||||
|
YKLogLevelVerbose,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKWrap) {
|
||||||
|
YKWrapNoWrap,
|
||||||
|
YKWrapWrap,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKOverflow) {
|
||||||
|
YKOverflowVisible,
|
||||||
|
YKOverflowHidden,
|
||||||
|
YKOverflowScroll,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKExperimentalFeature) {
|
||||||
|
YKExperimentalFeatureRounding,
|
||||||
|
YKExperimentalFeatureWebFlexBasis,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, YKAlign) {
|
||||||
|
YKAlignAuto,
|
||||||
|
YKAlignFlexStart,
|
||||||
|
YKAlignCenter,
|
||||||
|
YKAlignFlexEnd,
|
||||||
|
YKAlignStretch,
|
||||||
|
};
|
||||||
|
|
@@ -11,13 +11,6 @@
|
|||||||
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4A1DF8748400E7C260 /* AppDelegate.m */; };
|
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4A1DF8748400E7C260 /* AppDelegate.m */; };
|
||||||
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4D1DF8748400E7C260 /* ViewController.m */; };
|
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4D1DF8748400E7C260 /* ViewController.m */; };
|
||||||
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13687D521DF8748400E7C260 /* Assets.xcassets */; };
|
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13687D521DF8748400E7C260 /* Assets.xcassets */; };
|
||||||
13687D781DF878C600E7C260 /* YGEnums.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5E1DF8778F00E7C260 /* YGEnums.h */; };
|
|
||||||
13687D791DF878C600E7C260 /* YGMacros.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5F1DF8778F00E7C260 /* YGMacros.h */; };
|
|
||||||
13687D7A1DF878C600E7C260 /* Yoga.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; };
|
|
||||||
13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+Yoga.h */; };
|
|
||||||
13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */; };
|
|
||||||
13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D601DF8778F00E7C260 /* YGNodeList.c */; };
|
|
||||||
13687D821DF87CF200E7C260 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D621DF8778F00E7C260 /* Yoga.c */; };
|
|
||||||
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; };
|
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; };
|
||||||
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; };
|
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; };
|
||||||
63EE08411E06ED3D00EE5F9A /* YogaKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 63EE083F1E06ED3D00EE5F9A /* YogaKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
63EE08411E06ED3D00EE5F9A /* YogaKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 63EE083F1E06ED3D00EE5F9A /* YogaKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
@@ -25,12 +18,12 @@
|
|||||||
63EE08451E06ED3D00EE5F9A /* YogaKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 63EE083D1E06ED3D00EE5F9A /* YogaKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
63EE08451E06ED3D00EE5F9A /* YogaKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 63EE083D1E06ED3D00EE5F9A /* YogaKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
63EE084A1E06EEB700EE5F9A /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D601DF8778F00E7C260 /* YGNodeList.c */; };
|
63EE084A1E06EEB700EE5F9A /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D601DF8778F00E7C260 /* YGNodeList.c */; };
|
||||||
63EE084B1E06EEB700EE5F9A /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D621DF8778F00E7C260 /* Yoga.c */; };
|
63EE084B1E06EEB700EE5F9A /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D621DF8778F00E7C260 /* Yoga.c */; };
|
||||||
63EE084C1E06EEB700EE5F9A /* UIView+Yoga.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */; };
|
63EE084C1E06EEB700EE5F9A /* UIView+YogaKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D6A1DF8778F00E7C260 /* UIView+YogaKit.m */; };
|
||||||
63EE084D1E06EECB00EE5F9A /* YGEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D5E1DF8778F00E7C260 /* YGEnums.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
63EE084E1E06EECB00EE5F9A /* YGMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D5F1DF8778F00E7C260 /* YGMacros.h */; };
|
||||||
63EE084E1E06EECB00EE5F9A /* YGMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D5F1DF8778F00E7C260 /* YGMacros.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
63EE084F1E06EECB00EE5F9A /* YGNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D611DF8778F00E7C260 /* YGNodeList.h */; };
|
||||||
63EE084F1E06EECB00EE5F9A /* YGNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D611DF8778F00E7C260 /* YGNodeList.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
63EE08501E06EECB00EE5F9A /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; };
|
||||||
63EE08501E06EECB00EE5F9A /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
63EE08511E06EECB00EE5F9A /* UIView+YogaKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+YogaKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
63EE08511E06EECB00EE5F9A /* UIView+Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+Yoga.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
63EE08531E06F3D100EE5F9A /* YKEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 63EE08521E06F3D100EE5F9A /* YKEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@@ -44,30 +37,6 @@
|
|||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
13687D771DF878A000E7C260 /* yoga */ = {
|
|
||||||
isa = PBXCopyFilesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
dstPath = include/yoga;
|
|
||||||
dstSubfolderSpec = 16;
|
|
||||||
files = (
|
|
||||||
13687D781DF878C600E7C260 /* YGEnums.h in yoga */,
|
|
||||||
13687D791DF878C600E7C260 /* YGMacros.h in yoga */,
|
|
||||||
13687D7A1DF878C600E7C260 /* Yoga.h in yoga */,
|
|
||||||
);
|
|
||||||
name = yoga;
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
13687D7B1DF878CE00E7C260 /* YogaKit */ = {
|
|
||||||
isa = PBXCopyFilesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
dstPath = include/YogaKit;
|
|
||||||
dstSubfolderSpec = 16;
|
|
||||||
files = (
|
|
||||||
13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */,
|
|
||||||
);
|
|
||||||
name = YogaKit;
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
63EE08491E06ED3D00EE5F9A /* Embed Frameworks */ = {
|
63EE08491E06ED3D00EE5F9A /* Embed Frameworks */ = {
|
||||||
isa = PBXCopyFilesBuildPhase;
|
isa = PBXCopyFilesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -90,19 +59,19 @@
|
|||||||
13687D4D1DF8748400E7C260 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
13687D4D1DF8748400E7C260 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
||||||
13687D521DF8748400E7C260 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
13687D521DF8748400E7C260 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
13687D571DF8748400E7C260 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
13687D571DF8748400E7C260 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
13687D5E1DF8778F00E7C260 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = "<group>"; };
|
|
||||||
13687D5F1DF8778F00E7C260 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = "<group>"; };
|
13687D5F1DF8778F00E7C260 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = "<group>"; };
|
||||||
13687D601DF8778F00E7C260 /* YGNodeList.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = "<group>"; };
|
13687D601DF8778F00E7C260 /* YGNodeList.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = "<group>"; };
|
||||||
13687D611DF8778F00E7C260 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = "<group>"; };
|
13687D611DF8778F00E7C260 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = "<group>"; };
|
||||||
13687D621DF8778F00E7C260 /* Yoga.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = "<group>"; };
|
13687D621DF8778F00E7C260 /* Yoga.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = "<group>"; };
|
||||||
13687D631DF8778F00E7C260 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = "<group>"; };
|
13687D631DF8778F00E7C260 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = "<group>"; };
|
||||||
13687D691DF8778F00E7C260 /* UIView+Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UIView+Yoga.h"; path = "../../UIView+Yoga.h"; sourceTree = "<group>"; };
|
13687D691DF8778F00E7C260 /* UIView+YogaKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UIView+YogaKit.h"; path = "../../UIView+YogaKit.h"; sourceTree = "<group>"; };
|
||||||
13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "UIView+Yoga.m"; path = "../../UIView+Yoga.m"; sourceTree = "<group>"; };
|
13687D6A1DF8778F00E7C260 /* UIView+YogaKit.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "UIView+YogaKit.m"; path = "../../UIView+YogaKit.m"; sourceTree = "<group>"; };
|
||||||
13687D841DF87D1E00E7C260 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
13687D841DF87D1E00E7C260 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||||
13687D861DF87D2400E7C260 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
13687D861DF87D2400E7C260 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||||
63EE083D1E06ED3D00EE5F9A /* YogaKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = YogaKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
63EE083D1E06ED3D00EE5F9A /* YogaKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = YogaKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
63EE083F1E06ED3D00EE5F9A /* YogaKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YogaKit.h; sourceTree = "<group>"; };
|
63EE083F1E06ED3D00EE5F9A /* YogaKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YogaKit.h; sourceTree = "<group>"; };
|
||||||
63EE08401E06ED3D00EE5F9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
63EE08401E06ED3D00EE5F9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
63EE08521E06F3D100EE5F9A /* YKEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YKEnums.h; path = ../../YKEnums.h; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -170,7 +139,6 @@
|
|||||||
13687D5D1DF8778F00E7C260 /* yoga */ = {
|
13687D5D1DF8778F00E7C260 /* yoga */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
13687D5E1DF8778F00E7C260 /* YGEnums.h */,
|
|
||||||
13687D5F1DF8778F00E7C260 /* YGMacros.h */,
|
13687D5F1DF8778F00E7C260 /* YGMacros.h */,
|
||||||
13687D601DF8778F00E7C260 /* YGNodeList.c */,
|
13687D601DF8778F00E7C260 /* YGNodeList.c */,
|
||||||
13687D611DF8778F00E7C260 /* YGNodeList.h */,
|
13687D611DF8778F00E7C260 /* YGNodeList.h */,
|
||||||
@@ -195,8 +163,9 @@
|
|||||||
children = (
|
children = (
|
||||||
13687D5D1DF8778F00E7C260 /* yoga */,
|
13687D5D1DF8778F00E7C260 /* yoga */,
|
||||||
63EE083F1E06ED3D00EE5F9A /* YogaKit.h */,
|
63EE083F1E06ED3D00EE5F9A /* YogaKit.h */,
|
||||||
13687D691DF8778F00E7C260 /* UIView+Yoga.h */,
|
63EE08521E06F3D100EE5F9A /* YKEnums.h */,
|
||||||
13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */,
|
13687D691DF8778F00E7C260 /* UIView+YogaKit.h */,
|
||||||
|
13687D6A1DF8778F00E7C260 /* UIView+YogaKit.m */,
|
||||||
63EE08401E06ED3D00EE5F9A /* Info.plist */,
|
63EE08401E06ED3D00EE5F9A /* Info.plist */,
|
||||||
);
|
);
|
||||||
path = YogaKit;
|
path = YogaKit;
|
||||||
@@ -210,8 +179,8 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
63EE08411E06ED3D00EE5F9A /* YogaKit.h in Headers */,
|
63EE08411E06ED3D00EE5F9A /* YogaKit.h in Headers */,
|
||||||
63EE08511E06EECB00EE5F9A /* UIView+Yoga.h in Headers */,
|
63EE08531E06F3D100EE5F9A /* YKEnums.h in Headers */,
|
||||||
63EE084D1E06EECB00EE5F9A /* YGEnums.h in Headers */,
|
63EE08511E06EECB00EE5F9A /* UIView+YogaKit.h in Headers */,
|
||||||
63EE084E1E06EECB00EE5F9A /* YGMacros.h in Headers */,
|
63EE084E1E06EECB00EE5F9A /* YGMacros.h in Headers */,
|
||||||
63EE084F1E06EECB00EE5F9A /* YGNodeList.h in Headers */,
|
63EE084F1E06EECB00EE5F9A /* YGNodeList.h in Headers */,
|
||||||
63EE08501E06EECB00EE5F9A /* Yoga.h in Headers */,
|
63EE08501E06EECB00EE5F9A /* Yoga.h in Headers */,
|
||||||
@@ -225,8 +194,6 @@
|
|||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */;
|
buildConfigurationList = 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */;
|
||||||
buildPhases = (
|
buildPhases = (
|
||||||
13687D771DF878A000E7C260 /* yoga */,
|
|
||||||
13687D7B1DF878CE00E7C260 /* YogaKit */,
|
|
||||||
13687D3F1DF8748300E7C260 /* Sources */,
|
13687D3F1DF8748300E7C260 /* Sources */,
|
||||||
13687D401DF8748300E7C260 /* Frameworks */,
|
13687D401DF8748300E7C260 /* Frameworks */,
|
||||||
13687D411DF8748300E7C260 /* Resources */,
|
13687D411DF8748300E7C260 /* Resources */,
|
||||||
@@ -266,7 +233,7 @@
|
|||||||
13687D3B1DF8748300E7C260 /* Project object */ = {
|
13687D3B1DF8748300E7C260 /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastUpgradeCheck = 0810;
|
LastUpgradeCheck = 0820;
|
||||||
ORGANIZATIONNAME = facebook;
|
ORGANIZATIONNAME = facebook;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
13687D421DF8748300E7C260 = {
|
13687D421DF8748300E7C260 = {
|
||||||
@@ -321,11 +288,8 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */,
|
|
||||||
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */,
|
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */,
|
||||||
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */,
|
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */,
|
||||||
13687D821DF87CF200E7C260 /* Yoga.c in Sources */,
|
|
||||||
13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */,
|
|
||||||
13687D481DF8748400E7C260 /* main.m in Sources */,
|
13687D481DF8748400E7C260 /* main.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -336,7 +300,7 @@
|
|||||||
files = (
|
files = (
|
||||||
63EE084A1E06EEB700EE5F9A /* YGNodeList.c in Sources */,
|
63EE084A1E06EEB700EE5F9A /* YGNodeList.c in Sources */,
|
||||||
63EE084B1E06EEB700EE5F9A /* Yoga.c in Sources */,
|
63EE084B1E06EEB700EE5F9A /* Yoga.c in Sources */,
|
||||||
63EE084C1E06EEB700EE5F9A /* UIView+Yoga.m in Sources */,
|
63EE084C1E06EEB700EE5F9A /* UIView+YogaKit.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -369,6 +333,7 @@
|
|||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
CLANG_WARN_SUSPICIOUS_MOVES = YES;
|
CLANG_WARN_SUSPICIOUS_MOVES = YES;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
@@ -416,6 +381,7 @@
|
|||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
CLANG_WARN_SUSPICIOUS_MOVES = YES;
|
CLANG_WARN_SUSPICIOUS_MOVES = YES;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
Binary file not shown.
@@ -14,6 +14,4 @@ FOUNDATION_EXPORT double YogaKitVersionNumber;
|
|||||||
//! Project version string for YogaKit.
|
//! Project version string for YogaKit.
|
||||||
FOUNDATION_EXPORT const unsigned char YogaKitVersionString[];
|
FOUNDATION_EXPORT const unsigned char YogaKitVersionString[];
|
||||||
|
|
||||||
// In this header, you should import all the public headers of your framework using statements like #import <YogaKit/PublicHeader.h>
|
#import <YogaKit/UIView+YogaKit.h>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7,8 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import "ViewController.h"
|
#import "ViewController.h"
|
||||||
|
#import <YogaKit/YogaKit.h>
|
||||||
#import <YogaKit/UIView+Yoga.h>
|
|
||||||
|
|
||||||
@interface ViewController ()
|
@interface ViewController ()
|
||||||
|
|
||||||
@@ -20,17 +19,17 @@
|
|||||||
{
|
{
|
||||||
UIView *root = self.view;
|
UIView *root = self.view;
|
||||||
root.backgroundColor = [UIColor redColor];
|
root.backgroundColor = [UIColor redColor];
|
||||||
[root yg_setUsesYoga:YES];
|
[root yk_setUsesYoga:YES];
|
||||||
[root yg_setWidth:self.view.bounds.size.width];
|
[root yk_setWidth:self.view.bounds.size.width];
|
||||||
[root yg_setHeight:self.view.bounds.size.height];
|
[root yk_setHeight:self.view.bounds.size.height];
|
||||||
[root yg_setAlignItems:YGAlignCenter];
|
[root yk_setAlignItems:YKAlignCenter];
|
||||||
[root yg_setJustifyContent:YGJustifyCenter];
|
[root yk_setJustifyContent:YKJustifyCenter];
|
||||||
|
|
||||||
UIView *child1 = [UIView new];
|
UIView *child1 = [UIView new];
|
||||||
child1.backgroundColor = [UIColor blueColor];
|
child1.backgroundColor = [UIColor blueColor];
|
||||||
[child1 yg_setUsesYoga:YES];
|
[child1 yk_setUsesYoga:YES];
|
||||||
[child1 yg_setWidth:100];
|
[child1 yk_setWidth:100];
|
||||||
[child1 yg_setHeight:100];
|
[child1 yk_setHeight:100];
|
||||||
|
|
||||||
UIView *child2 = [UIView new];
|
UIView *child2 = [UIView new];
|
||||||
child2.backgroundColor = [UIColor greenColor];
|
child2.backgroundColor = [UIColor greenColor];
|
||||||
@@ -53,7 +52,7 @@
|
|||||||
[child2 addSubview:child3];
|
[child2 addSubview:child3];
|
||||||
[root addSubview:child1];
|
[root addSubview:child1];
|
||||||
[root addSubview:child2];
|
[root addSubview:child2];
|
||||||
[root yg_applyLayout];
|
[root yk_applyLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
25
enums.py
25
enums.py
@@ -89,6 +89,14 @@ ENUMS = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OBJC_ENUMS = {
|
||||||
|
'Direction': [
|
||||||
|
'Inherit',
|
||||||
|
'LeftToRight',
|
||||||
|
'RightToLeft',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
LICENSE = """/**
|
LICENSE = """/**
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@@ -111,7 +119,7 @@ def to_java_upper(symbol):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
root = os.path.dirname(__file__)
|
root = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
# write out C header
|
# write out C header
|
||||||
with open(root + '/yoga/YGEnums.h', 'w') as f:
|
with open(root + '/yoga/YGEnums.h', 'w') as f:
|
||||||
@@ -187,3 +195,18 @@ for name, values in ENUMS.items():
|
|||||||
f.write(' %s,\n' % value)
|
f.write(' %s,\n' % value)
|
||||||
f.write(' }\n')
|
f.write(' }\n')
|
||||||
f.write('}\n')
|
f.write('}\n')
|
||||||
|
|
||||||
|
# write out objc files
|
||||||
|
with open(root + '/YogaKit/YKEnums.h', 'w') as f:
|
||||||
|
objc_enums = ENUMS
|
||||||
|
objc_enums.update(OBJC_ENUMS)
|
||||||
|
f.write(LICENSE)
|
||||||
|
for name, values in objc_enums.items():
|
||||||
|
f.write('typedef NS_ENUM(NSInteger, YK%s) {\n' % name)
|
||||||
|
for value in values:
|
||||||
|
if isinstance(value, tuple):
|
||||||
|
f.write(' YK%s%s = %d,\n' % (name, value[0], value[1]))
|
||||||
|
else:
|
||||||
|
f.write(' YK%s%s,\n' % (name, value))
|
||||||
|
f.write('};\n')
|
||||||
|
f.write('\n')
|
||||||
|
Reference in New Issue
Block a user