Files
yoga/YogaKit/CHANGELOG.md
Dustin Shahidehpour ae9f89b5d1 Add helper function for bulk updates.
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
2017-02-13 09:28:12 -08:00

840 B

CHANGELOG

The changelog for YogaKit.

1.2.0 (upcoming release)

Breaking Changes

  • applyLayout() has now been changed to applyLayout(preservingOrigin:).

  • Computed properties are no longer reflected in getter's of the affected properties.

// OLD
view.yoga.margin = 10
view.yoga.marginTop  // 10
view.yoga.marginLeft // 10

// NEW
view.yoga.margin = 10
view.yoga.marginTop // 0
view.yoga.marginLeft // 0

Enhancements

  • Pixel Rounding now uses roundf() instead of round().

  • There is now a method that allows "bulk" updates to YGLayout.

[view configureLayoutWithBlock:^(YGLayout *layout) {
  layout.isEnabled = YES;
  layout.width = 50;
  layout.height = 50;
}];
view.configureLayout { (layout) in
  layout.isEnabled = true
  layout.width = 50
  layout.height = 50
}