Closed oleksii-demedetskyi closed 11 years ago
So we need discuss syntax of one constraint.
In simple case layout of views is looking as this
[view addConstraint:constraint];
[view addConstraint:constraint];
[view addConstraint:constraint];
[view addConstraint:constraint];
we can handle layout chains via custom block, but we need also support single constraint adding.
leftOf(view1).equal.rightOf(view2).plus(10);
This code will produce filled PVConstraintContext
that need to be saved. Also we need access to start methods.
Also, this constraint can be described as VFL
@"H:[view1]-10-[view2]"
VFL are much more simpler and readable even our solution.
Our goal is in shorthand record both types of constraints.
layout(view).(
@"H:[view1]-10-[view2]",
@"V:|-[view1]-[view3]-|",
leftOf(view1).equal.centerXOf(superview).plus(10),
);
In this case all constraints, even VFL, are listed in one expression.w
Or in current case:
[view setupLayout:^(LMMaster* $) {
$.vfl(@"H:[view1]-10-[view2]");
$.vfl(@"V:|-[view1]-[view3]-|");
$.leftOf(view1).equal.centerXOf(superview).plus(10);
];
@xNekOIx @AndreyMoskvin What do you think?
layout(view).withViews(NSDictionaryBinding(...)).metrics(@{})).(
vfl(@"H:[view1]-10-[view2]").options(...),
vfl(@"V:|-[view1]-[view3]-|"),
leftOf(view1).equal.centerXOf(superview).plus(10)
);
NSLayoutConstraint *constraint = ...
How to define single constraint?
NSLayoutConstraint *constraint = constraintWhere(leftOf().equal.centerXOf().plus());
Another option for single constraint is
NSLayoutConstraint *consraint = rv_equation().where.leftOf(view1).equal.centerXOf(self).plus(10).asConstraint;
@DAlOG @AndreyMoskvin
Should it be like this:
NSLayoutConstraint *consraint = PV.leftOf(view1).equal.centerXOf(self).plus(10).asConstraint;
or it still could be better to use this syntax:
NSLayoutConstraint *consraint = PVLeftOf(view1).equal.centerXOf(self).plus(10).asConstraint;
what do you think?
I like second one.
Agreed
We should have ability to save single constraint into variable or property.
Both this cases should be supported.