mamaral / Neon

A powerful Swift programmatic UI layout framework.
MIT License
4.58k stars 389 forks source link

Align views next to each other to the write while wrapping #33

Open tim12s opened 8 years ago

tim12s commented 8 years ago

Hi,

For certain scenarios I want to align components next to each other "to the right" while automatically wrapping to the next line if required. Different screen widths will allow a differing number of components to align next to each other. The current pull request addresses this. This does not logically apply in all scenarios. Reactive web pages commonly address this and elastic changes can happen vertically but this change will keep this simple for now.

  1. Add line wrapping capability utilizing .ToTheRightMatchingTopWrapping to indicate that a component aligned to another component on the right can wrap below and align itself to the left inside of the superview (+padding).
  2. Add a newline capability to ensure that the newline anchor is relative to the end of the previous line which may be wrapped. This uses .UnderMatchingLeftFollowing indicate that it must be under the tailing component to the left. This is applicable to both align and alignAndFillWidth.
  3. Updated the ViewController example with the necessary line wrapping examples showing both examples, with a subsequent alignAndFill.
  4. Superview was using Frame instead of Bounds to determine the superview which is incorrect when the superview undergoes translations. This was corrected.

neon-flex