Closed edgarfgp closed 2 years ago
This PR adds basic support to match v1 for RelativeLayout based on : https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.relativelayout?view=xamarin-forms
RelativeToView as we need a way to eg the a reference to the view that we want base the position of our element
public static Constraint RelativeToView(View view, Func<RelativeLayout, View, double> measure) { var result = new Constraint { _measureFunc = layout => measure(layout, view), RelativeTo = new[] { view } }; return result; }
BoundsConstraint
public static BoundsConstraint FromExpression(Expression<Func<Rectangle>> expression, IEnumerable<View> parents = null) { return FromExpression(expression, false, parents); }
internal static BoundsConstraint FromExpression(Expression<Func> expression, bool fromExpression, IEnumerable parents = null) { Func compiled = expression.Compile(); var result = new BoundsConstraint { _measureFunc = compiled, RelativeTo = parents ?? ExpressionSearch.Default.FindObjects(expression).ToArray(), // make sure we have our own copy CreatedFromExpression = fromExpression };
return result;
}
### We could consider using ViewRef to try to accomplish this maybe ?
For now, let's merge this PR. Given the non-trivial support of RelativeToView and BoundsConstraint, and the fact it was never supported by v1 and no one complained about it, let's keep it for when the need arise.
This PR adds basic support to match v1 for RelativeLayout based on : https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.relativelayout?view=xamarin-forms
Not Implemented
RelativeToView as we need a way to eg the a reference to the view that we want base the position of our element
BoundsConstraint
internal static BoundsConstraint FromExpression(Expression<Func> expression, bool fromExpression, IEnumerable parents = null)
{
Func compiled = expression.Compile();
var result = new BoundsConstraint
{
_measureFunc = compiled,
RelativeTo = parents ?? ExpressionSearch.Default.FindObjects(expression).ToArray(), // make sure we have our own copy
CreatedFromExpression = fromExpression
};
}