Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASStackLayoutSpec] Flex wrap fix and lineSpacing property #472

Merged
merged 3 commits into from
Aug 3, 2017
Merged

[ASStackLayoutSpec] Flex wrap fix and lineSpacing property #472

merged 3 commits into from
Aug 3, 2017

Conversation

flovouin
Copy link
Contributor

Hi guys,

I haven't opened an issue / feature request for this, but here it is, a PR that fixes a small bug in the flex wrap layout, and add a nice property to it.

  • The first commit fixes a bug where spacing is not taken into account when splitting items in lines. This causes items to overflow the allowed size range in certain cases. Specifically, too many items can be added to a line because the line length doesn't keep track of spacing. See the demo project for an example.
  • The second commit adds the lineSpacing property to the ASStackLayoutSpec that... well... adds space between lines. I tried to keep changes as minimal as possible, tell me what you think!

As usual, here's a small demo project that demonstrates the bug and the new feature.

Cheers,

Flo

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is awesome! You managed to fix a very well hidden bug and implement a frequently requested feature, all in a very compact and well-thought diff! The line spacing implementation, in particular, is very impressive. I don't recall it being defined/implemented anywhere else, including the original CSS flexbox spec, as well as its implementations such Yoga, servo's and WebKit's. While we'd like to stick to the CSS spec as much as possible, after reading your code, I'm convinced that it's a great addition to the framework that requires minimal maintenance and thus, is well-worth the divergence. In fact, I already have a use case for it in ASCollectionGalleryLayoutDelegate and ASCollectionFlowLayoutDelegate.

While it would be even better if we can have some new snapshot test cases for the bug fix and line spacing, I'm gonna approve this PR as is. Please feel free to follow up on the tests either in this PR or in a new one.

CHANGELOG.md Outdated
@@ -1,6 +1,7 @@
## master

* Add your own contributions to the next release on the line below this with your name.
- [ASStackLayoutSpec] Fix flex wrap overflow and add lineSpacing property. [Flo Vouin](https://github.com/flovouin)
Copy link
Member

@nguyenhuy nguyenhuy Aug 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since line spacing is a significant addition, I'd suggest to mention it in a separate line so people won't overlook it. It's your call though.

@@ -70,6 +70,7 @@ + (ASCollectionLayoutState *)calculateLayoutWithContext:(ASCollectionLayoutConte
alignItems:ASStackLayoutAlignItemsStart
flexWrap:ASStackLayoutFlexWrapWrap
alignContent:ASStackLayoutAlignContentStart
lineSpacing:0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have a convenient initializer that doesn't require lineSpacing, please remove this change.

@@ -81,6 +81,7 @@ + (ASCollectionLayoutState *)calculateLayoutWithContext:(ASCollectionLayoutConte
alignItems:ASStackLayoutAlignItemsStart
flexWrap:ASStackLayoutFlexWrapWrap
alignContent:ASStackLayoutAlignContentStart
lineSpacing:0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@flovouin
Copy link
Contributor Author

flovouin commented Aug 2, 2017

Hi Huy, thanks for the review!
I've made the changes you requested, so it should be all good.

I do agree that tests would be a nice addition. I'll try to address this but unfortunately I can't give you a time estimate for this, so I think it would be best to go ahead with this PR and I'll submit another one in the future.

Cheers,

@nguyenhuy
Copy link
Member

Ok, let's get this in. I created a separate issue for unit tests. Thanks for the awesome work, @flovouin!

@nguyenhuy nguyenhuy merged commit ba08ae1 into TextureGroup:master Aug 3, 2017
@flovouin flovouin deleted the FlexWrapImprovements branch December 21, 2017 17:44
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
…oup#472)

* ASStackUnpositionedLayout: Take spacing into account when laying out a wrapped stack.

* ASStackLayoutSpec: Add the lineSpacing property.

* Update CHANGELOG.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants