[csharp] Fix tests Pt() extension #406
@@ -27,9 +27,3 @@ BASE_COMPILER_FLAGS = [
|
||||
|
||||
def yoga_dep(dep):
|
||||
return '//' + dep
|
||||
|
||||
class allow_unsafe_import:
|
||||
def __enter__(self):
|
||||
pass
|
||||
def __exit__(self, type, value, traceback):
|
||||
pass
|
||||
|
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = 'Yoga'
|
||||
spec.version = '1.0.2'
|
||||
spec.version = '1.1.0'
|
||||
spec.license = { :type => 'BSD', :file => "LICENSE" }
|
||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/c/'
|
||||
@@ -11,7 +11,7 @@ Pod::Spec.new do |spec|
|
||||
spec.authors = 'Facebook'
|
||||
spec.source = {
|
||||
:git => 'https://github.com/facebook/yoga.git',
|
||||
:tag => 'v2017.01.27.00',
|
||||
:tag => 'v2017.02.07.00',
|
||||
}
|
||||
|
||||
spec.module_name = 'yoga'
|
||||
|
@@ -1,6 +1,6 @@
|
||||
podspec = Pod::Spec.new do |spec|
|
||||
spec.name = 'YogaKit'
|
||||
spec.version = '1.0.3'
|
||||
spec.version = '1.1.0'
|
||||
spec.license = { :type => 'BSD', :file => "LICENSE" }
|
||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
|
||||
@@ -11,14 +11,14 @@ podspec = Pod::Spec.new do |spec|
|
||||
spec.authors = 'Facebook'
|
||||
spec.source = {
|
||||
:git => 'https://github.com/facebook/yoga.git',
|
||||
:tag => 'v2017.01.27.00',
|
||||
:tag => 'v2017.02.07.00',
|
||||
}
|
||||
|
||||
spec.platform = :ios
|
||||
spec.ios.deployment_target = '8.0'
|
||||
spec.ios.frameworks = 'UIKit'
|
||||
|
||||
spec.dependency 'Yoga', '~> 1.0'
|
||||
spec.dependency 'Yoga', '~> 1.1'
|
||||
spec.source_files = 'YogaKit/Source/*.{h,m}'
|
||||
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
||||
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
||||
|
@@ -222,7 +222,7 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
||||
- (void)applyLayout
|
||||
{
|
||||
[self calculateLayoutWithSize:self.view.bounds.size];
|
||||
YGApplyLayoutToViewHierarchy(self.view);
|
||||
YGApplyLayoutToViewHierarchy(self.view, YES);
|
||||
}
|
||||
|
||||
- (CGSize)intrinsicSize
|
||||
@@ -364,7 +364,7 @@ static CGFloat YGRoundPixelValue(CGFloat value)
|
||||
return round(value * scale) / scale;
|
||||
}
|
||||
|
||||
static void YGApplyLayoutToViewHierarchy(UIView *view)
|
||||
static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)
|
||||
{
|
||||
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
||||
|
||||
@@ -385,10 +385,11 @@ static void YGApplyLayoutToViewHierarchy(UIView *view)
|
||||
topLeft.y + YGNodeLayoutGetHeight(node),
|
||||
};
|
||||
|
||||
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
|
||||
view.frame = (CGRect) {
|
||||
.origin = {
|
||||
.x = YGRoundPixelValue(topLeft.x),
|
||||
.y = YGRoundPixelValue(topLeft.y),
|
||||
.x = YGRoundPixelValue(topLeft.x + origin.x),
|
||||
.y = YGRoundPixelValue(topLeft.y + origin.y),
|
||||
},
|
||||
.size = {
|
||||
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
|
||||
@@ -398,7 +399,7 @@ static void YGApplyLayoutToViewHierarchy(UIView *view)
|
||||
|
||||
if (!yoga.isLeaf) {
|
||||
for (NSUInteger i=0; i<view.subviews.count; i++) {
|
||||
YGApplyLayoutToViewHierarchy(view.subviews[i]);
|
||||
YGApplyLayoutToViewHierarchy(view.subviews[i], NO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -618,4 +618,39 @@
|
||||
XCTAssertEqual(view.yoga.borderEndWidth, 7);
|
||||
}
|
||||
|
||||
- (void)testOriginIsPreservedOnRootOfLayout {
|
||||
const CGSize containerSize = CGSizeMake(200, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(10, 10, containerSize.width, containerSize.height)];
|
||||
container.yoga.isEnabled = YES;
|
||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
subview1.yoga.isEnabled = YES;
|
||||
subview1.yoga.flexGrow = 1;
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
subview2.yoga.isEnabled = YES;
|
||||
subview2.yoga.flexGrow = 1;
|
||||
subview2.yoga.flexDirection = YGFlexDirectionColumn;
|
||||
subview2.yoga.marginLeft = 10;
|
||||
[container addSubview:subview2];
|
||||
[container.yoga applyLayout];
|
||||
|
||||
XCTAssertTrue(CGRectEqualToRect(container.frame, CGRectMake(10, 10, 200, 50)));
|
||||
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 95, 50)));
|
||||
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(105, 0, 95, 50)));
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
subview3.yoga.isEnabled = YES;
|
||||
subview3.yoga.alignSelf = YGAlignFlexEnd;
|
||||
subview3.yoga.height = 50;
|
||||
[subview2 addSubview:subview3];
|
||||
[subview2.yoga applyLayout];
|
||||
|
||||
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(115, 0, 85, 50)));
|
||||
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(85,0,0,50)));
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user