Example #1
0
        public static void UpdateConstraints(LayoutConstraintItem item, Action <ConstraintMaker> closure)
        {
            if (item.Constraints?.Length <= 0)
            {
                MakeConstraints(item, closure);
                return;
            }

            var maker = new ConstraintMaker(item);

            closure(maker);

            var constraints = new List <Constraint>();

            foreach (var description in maker._descriptions)
            {
                if (description.Constraint != null)
                {
                    constraints.Add(description.Constraint);
                }
            }

            foreach (var constraint in constraints)
            {
                constraint.ActivateIfNeeded(updateExisting: true);
            }
        }
Example #2
0
        public ConstraintMaker(LayoutConstraintItem item)
        {
            _item = item;
            _item.Prepare();

            _descriptions = new List <ConstraintDescription>();
        }
Example #3
0
 public ConstraintDescription(LayoutConstraintItem item, ConstraintAttributes attributes)
 {
     Item       = item;
     Constant   = 0.0f;
     Priority   = 1000.0f;
     Multiplier = 1.0f;
     Attributes = attributes;
 }
Example #4
0
        public static void RemoveConstraints(LayoutConstraintItem item)
        {
            var constraints = item.Constraints;

            foreach (var constraint in constraints)
            {
                constraint.DeactivateIfNeeded();
            }
        }
Example #5
0
        public static Constraint[] PrepareConstraints(LayoutConstraintItem item, Action <ConstraintMaker> closure)
        {
            var maker = new ConstraintMaker(item);

            closure(maker);

            var constraints = new List <Constraint>();

            foreach (var description in maker._descriptions)
            {
                if (description.Constraint != null)
                {
                    constraints.Add(description.Constraint);
                }
            }

            return(constraints.ToArray());
        }
Example #6
0
        public static void MakeConstraints(LayoutConstraintItem item, Action <ConstraintMaker> closure)
        {
            var maker = new ConstraintMaker(item);

            closure(maker);

            var constraints = new List <Constraint>();

            foreach (var description in maker._descriptions)
            {
                if (description.Constraint != null)
                {
                    constraints.Add(description.Constraint);
                }
            }

            foreach (var constraint in constraints)
            {
                constraint.ActivateIfNeeded(updateExisting: false);
            }
        }
Example #7
0
 public LayoutConstraint(LayoutConstraintItem itemA, NSLayoutAttribute attributeA, NSLayoutRelation relation, UIView itemB, NSLayoutAttribute attributeB, nfloat multiplier, nfloat constant)
 {
     _value = NSLayoutConstraint.Create(itemA.Value, attributeA, relation, itemB, attributeB, multiplier, constant);
 }
Example #8
0
 public static void RemakeConstraints(LayoutConstraintItem item, Action <ConstraintMaker> closure)
 {
     RemoveConstraints(item);
     MakeConstraints(item, closure);
 }