Summary:
Only add UIView nodes to Yoga where they are enabled.
We check for it in `isLeaf` but I think we should also check for them in the check for sub views.
Closes https://github.com/facebook/yoga/pull/609
Reviewed By: emilsjolander
Differential Revision: D5643387
Pulled By: dshahidehpour
fbshipit-source-id: a85c62b6b2e0120b2913e7f2df8b094d43ca49a6
Summary:
This is an easy diff to wrap YGPointValue() in an extern "C" block to make sure it compiles
when we are using inside of Objective-C++ classes.
Reviewed By: emilsjolander
Differential Revision: D5242366
fbshipit-source-id: 772aaac056b3a20041926d5f35128716848a271a
Summary: To fix builds where `sdks =` is not supported.
Reviewed By: splhack
Differential Revision: D5113020
fbshipit-source-id: b716acd6fb88ccb55c72b24f9fcdf20a2ea3693e
Summary:
calculateLayoutWithSize: can be useful when calculating table/collection view sizes before the views are fully laid out by UIKit.
Closes https://github.com/facebook/yoga/pull/558
Differential Revision: D5104863
Pulled By: emilsjolander
fbshipit-source-id: e0e0c6d502f6745be8d84de8c1b6e24cc25a0352
Summary:
This is used in a stack where I'm using YogaKit on tvOS. fb_apple_library needs `sdks = ` to get buck to do its thing for tvOS.
This seems like it should be OK since apple_library is a nop on non apple platforms (which makes sense since this is ObjC only) - I think that makes sense anyway?
Reviewed By: emilsjolander
Differential Revision: D5080261
fbshipit-source-id: f08d7e6d2599b9af25fb964ade485aef552f306b
Summary:
Moves the `YGLogger` into `YGConfig` and pass the `YGNodeRef` into the logger to be able to associate the log messages and assertions with the specific node.
Tackles facebook/yoga#530 and facebook/yoga#446
Closes https://github.com/facebook/yoga/pull/531
Reviewed By: astreet
Differential Revision: D4970149
Pulled By: emilsjolander
fbshipit-source-id: b7fcdaa273143ea2fa35861620b2e4d79f04f0af
Summary:
We still need to wait for the `YGUnitPoint` PR to be merged :) But please let me know what you think. One caveat: because of a limitation of Swift, a literal value can be automatically understood as a point-based `YGValue`, but variables have to be explicitly cast. I haven't found a way around it yet:
```
view.yoga.width = 10 // value == 10, unit == YGUnitPixel
let a: CGFloat = 100
view.yoga.height = a // Compiler error
view.yoga.height = YGValue(a) // works, not great
```
Closes https://github.com/facebook/yoga/pull/390
Reviewed By: emilsjolander
Differential Revision: D4954021
Pulled By: maxoll
fbshipit-source-id: 5eff6aeb6dd969d0d5dc557b149bb5819b0e31de
Summary:
Hi! After merging 3db38f2a80 the rounding algorithm become broken in YogaKit because it doesn't configure scale factor.
Closes https://github.com/facebook/yoga/pull/534
Differential Revision: D4969481
Pulled By: emilsjolander
fbshipit-source-id: 57ea42a3b1f37007b2392cda724d509e0b28c4cb
Summary:
The main container that gets called `applyLayoutPreservingOrigin:` is using its size as a fixed bounding box.
In some cases it's preferrable to let it accomodate its contents.
This diffs extends `applyLayoutPreservingOrigin:` by adding an additional parameter which can be used to sepecify whether width and/or height are fixed or flexible.
Feel free to suggest better names than `YGDimensionFlexibility` & co.
Let me know if you prefet to kill the API without flexiblity specifier - I'll codemod everything then.
Reviewed By: dshahidehpour
Differential Revision: D4929702
fbshipit-source-id: f128f244140b4a54d8ce3b3f4edddbb9756f8fdf
Summary: The `block` paramenter is marked as nonnull, so we can't pass `nil` directly in.
Reviewed By: dshahidehpour
Differential Revision: D4929692
fbshipit-source-id: a35ef2940d6986f4ff55444d8a99ba17eb7c677e
Summary: Using the newer/recommended API in the sample project. #accept2ship
Reviewed By: emilsjolander
Differential Revision: D4698936
fbshipit-source-id: 07b61df897524cd38390ba48dfa2a2e10942329b
Summary:
Before:
There was a broken link in ./docs/README.md
CONTRIBUTING didn't render markup on Github
After:
All links to CONTRIBUTING.md are not broken anymore
CONTRIBUTING.md renders markup on Github
Closes https://github.com/facebook/yoga/pull/458
Differential Revision: D4673746
Pulled By: emilsjolander
fbshipit-source-id: 151c1f38789a96b61dfbb544fd11996098dc456d
Summary:
Move configuration to new ```YGConfig``` and pass them down to CalculateLayout. See #418 .
Adds ```YGConfigNew()``` + ```YGConfigFree```, and changed ```YGSetExperimentalFeatureEnabled``` to use the config.
New function for calculation is ```YGNodeCalculateLayoutWithConfig```.
Closes https://github.com/facebook/yoga/pull/432
Reviewed By: astreet
Differential Revision: D4611359
Pulled By: emilsjolander
fbshipit-source-id: a1332f0e1b21cec02129dd021ee57408449e10b0
Summary:
I don't even know how people have been running tests (unless they install BUCK). This creates a workspace to make it much easier to run tests.
Closes https://github.com/facebook/yoga/pull/400
Differential Revision: D4565290
Pulled By: dshahidehpour
fbshipit-source-id: 762168ced81e517126ac05c92bb27ccad0d9d305
Summary:
...to reflect the modern world we live in with dynamic DPI platforms :)
Closes https://github.com/facebook/yoga/pull/375
Reviewed By: dshahidehpour
Differential Revision: D4528518
Pulled By: emilsjolander
fbshipit-source-id: e422bd4ae148e02c598a7b484a6adfa8c0e1e0c9
Summary: This is an update of facebook/yoga#368 which was reverted. It fixes support for align-content: strech with multiple lines. The problem with the last attempt at solving this was that align-items:stretch was interfering. We handle this now by detecting when the flex basis of the children hints at them overflowing. This is not 100% correct as the size of the items could change when remeasuring but it will work in 99% of cases.
Reviewed By: astreet
Differential Revision: D4551234
fbshipit-source-id: 2964f19cf415991dc55dfa2caa4868cb00c56bd0
Summary: For some internal Instagram diffs, and some external ones (auto-detection of dirty nodes). We need to give the dirty properties a little love. This adds a getter to find out if your node is dirty, and makes sure that the leaf node is properly setup before it is marked dirty to prevent a crash.
Reviewed By: emilsjolander
Differential Revision: D4549241
fbshipit-source-id: 36eda6fdb4ea7f968d126aab6da67896f4a01d40
Summary:
Currently, our configuration of Views looks like this:
```objc
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.isEnabled = YES;
view.yoga.height = 50;
view.yoga.width = 50;
```
Every time that we access `view.yoga` we have to access the associated object on `UIView` to get the `YGLayout`. This adds an extra `objc_msgSend` which increases binary size, and is slight perf impact.
This diff creates a way to modify the `YGLayout` with only a single `objc_msgSend`. Here's the new syntax:
```objc
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view configureLayoutWithBlock:^void(YGLayout *layout){
layout.isEnabled = YES
layout.height = 50;
layout.width = 50;
}];
```
Here's the Swift version:
```swift
let view = UIView(frame: .zero)
view.configureLayout { (layout) in
layout.isEnabled = true
layout.height = 50
layout.width = 50
}
```
Closes https://github.com/facebook/yoga/pull/393
Reviewed By: emilsjolander
Differential Revision: D4550382
Pulled By: dshahidehpour
fbshipit-source-id: 76d797d1e0de8e5dc767e02180a7fc440a70212e
Summary:
To date, our sample project was lacking. There is still a lot of work that can be done to improve, but, this is a step in the right direction.
Here are the changes in this commit:
1. The project is written in Swift.
2. Created new CollectionView (via [IGListKit](https://github.com/instagram/iglistkit)), making it very easy to add new examples.
3. New examples for basic layouts, and including/excluding layouts on the fly.
Here's a video!

Closes https://github.com/facebook/yoga/pull/392
Reviewed By: emilsjolander
Differential Revision: D4550379
Pulled By: dshahidehpour
fbshipit-source-id: 64a07acf96c1887f1d2ad0c54971fcedb64334a0
Summary: While debugging something at Instagram, I kept seeing a UILabel be truncated when it clearly had enough room to display all its' text. What I realized is that during our pixel rounding, we were losing precision because we were using the incorrect rounding function for floats. Changing from `round()` (which is for doubles) to `roundf()` fixed it.
Reviewed By: amonshiz
Differential Revision: D4549069
fbshipit-source-id: 78a1bb33e315e7c066b7fb625b1f5a28def76515
Summary:
Now that the Yoga library supports percentage values, the results returned from it's API were changed.
`YGNodeStyleGetPadding` returns the explicit value that you set, whereas `YGNodeLayoutGetPadding` returns the computed value. Since we are planning to build support for percentages, I'm modifying our API so that it strictly returns the value that was set. As a result:
```
view.yoga.margin = 10;
// view.yoga.margin == 10
// view.yoga.marginLeftWidth == 0
// view.yoga.marginRightWidth == 0
// etc.
```
Reviewed By: emilsjolander
Differential Revision: D4543471
fbshipit-source-id: a731025cd4b47e9f1a559c766494fc5a259291ae
Summary: Currently, we have an issue in YogaKit where it ignores the preexisting bounds a root view. There are multiple fixes for this, but the easiest one for developer experience is to apply the preexisting bounds of the root view to it's frame after layout calculation.
Reviewed By: emilsjolander
Differential Revision: D4537173
fbshipit-source-id: ccef8b1c1398ea299b4e5710abe597378347a48d
Summary:
Fix#241 and successor for #302
Added new property ```display``` with ```YGDisplayFlex``` and ```YGDisplayNone```. Allows to hide nodes from the layout without the need to remove it from the DOM.
Closes https://github.com/facebook/yoga/pull/369
Reviewed By: astreet
Differential Revision: D4501141
Pulled By: emilsjolander
fbshipit-source-id: 0dfeee381f6d1e4bbba81926126b83dd7abab9d6
Summary:
I incorrectly sized some assets, as a result, the sample project had some warnings about it when you built. This fixes it.
Closes https://github.com/facebook/yoga/pull/377
Differential Revision: D4515193
Pulled By: dshahidehpour
fbshipit-source-id: 3af6e79a17777bec3798bbf7294af5716f65e37a
Summary: The Sample app needed some love. It wouldn't build because of some import errors, adding files is very manual, and it looked bad. I have fixed all of these things.
Reviewed By: amonshiz
Differential Revision: D4508624
fbshipit-source-id: bda40defb167ef871d8d0d5bb853d8905b9682d8
Summary: For our YogaKit sample project we want to add Cocoapods support and reference the local podspec. Unfortunately, this won't work unless the podspec lives in the root directory.
Reviewed By: emilsjolander
Differential Revision: D4507887
fbshipit-source-id: 919a8c8506768c90e50b3ae27deb51394db021e6
Summary:
Hey there, congrats on the launch - we use React Native at Artsy, and I've been wondering about what Yoga + Jest Snapshots for RN looks like but haven't had the time to explore that yet.
With https://github.com/CocoaPods/cocoadocs.org/pull/501 I added the ability to customize the location of the README for the front-page of the CocoaPods site. That is being deployed as I speak, so it should be available the next time you decide to ship a version of Yoga.
I also fixed the capitalisation of CocoaPods, and removed a redundant CocoaPods badge on your initial README.
Closes https://github.com/facebook/yoga/pull/366
Reviewed By: emilsjolander
Differential Revision: D4488011
Pulled By: dshahidehpour
fbshipit-source-id: 6c0c4efc23a69e1fcb936214b159b49217218b49
Summary: Make the two podspecs more consistent with each other.
Reviewed By: dshahidehpour
Differential Revision: D4481945
fbshipit-source-id: ab782abecd709c763b4e931b6839a5cae6346281
Summary: Without specifying the deployment target, it was default to iOS 4.3. This would cause a build error because we are `unable to synthesize weak properties` which didn't come around until iOS 5. Setting default target to iOS 8.
Reviewed By: emilsjolander
Differential Revision: D4481772
fbshipit-source-id: d3be88d0f73533c6242fc1d9045c70ad4628fd21
Summary:
This supersedes #309 and #305.
This is still a **work-in-progress.**
**TODO**
- [x] Create Xcode project that builds an iOS framework
- [x] Fix failing tests on Xcode
- [ ] Make `pod lib lint` pass and make sure YogaKit can be included using CocoaPods
- [ ] Add `pod lib lint` to .travis.yml
- [x] Migrate to travis osx image with Xcode 8.2
**FOLLOW-UP**
- [ ] Make YogaKitSample use framework built by new Xcode project.
- [ ] Make Travis to upload prebuilt versions of the framework. More [here](https://github.com/Carthage/Carthage#use-travis-ci-to-upload-your-tagged-prebuild-frameworks)
- [ ] Upgrade github/jekyll docs about installation using Cocoapods/Carthage
Closes https://github.com/facebook/yoga/pull/352
Reviewed By: emilsjolander
Differential Revision: D4471950
Pulled By: dshahidehpour
fbshipit-source-id: 8f30c69f9a487b26aa2e5f3b66841334b01b0ab1
Summary:
I did some stylistic changes to the Objective-C unit tests for the following reasons:
- When an equality assert fails, the error messages reads as if the value we are testing is the first argument and the value we expect is the second argument. To improve the readability of test messages, I made sure all `XCTAssertEqual` and `XCTAssertNotEqual` have the arguments in the correct order.
- Because failing equality asserts already comes with a detailed message including the value tested and the expected value, I rewrote several truth asserts on `CGSizeEqual` to two equality asserts on the width and height: when those fail, the error message are clearer.
Closes https://github.com/facebook/yoga/pull/351
Reviewed By: emilsjolander
Differential Revision: D4454484
Pulled By: dshahidehpour
fbshipit-source-id: 0c1295a4a7e8477eacfb3f4ef6648984fd102a51