slodge/Cirrious.FluentLayout — pull request #3 by RocketPop (2014-04-02 22:29:44+00:00)
Title: Filter null constraints in AddConstraints()

I often find I have optional constraints (left vs right anchoring, size switches, optional UI elements, etc.) Especially in table view cells. I changed the above code to allow me to write layouts like so:

View.AddConstraints(
viewHasHeader ? TableViewControl.Below(HeaderContainerView) : null,
TableViewControl.AtLeftOf(View),
TableViewControl.AtRightOf(View),
TableViewControl.AtBottomOf(View)
);

This change is so I don't have to have lists of optional constraints (i.e. separate calls to AddConstraints() ) after the core set of constraints - that are then separated by many lines of code and if blocks. I was also debating adding my own custom constraints - which when they were not needed would return null. Something like BelowIfExists(this UIView view, UIView previous, float margin = 0f)

Not sure if the allowing of nulls in lists of constraints fits the rest of the design though :)