public SuggestionsView() { TranslatesAutoresizingMaskIntoConstraints = false; BackgroundColor = UIColor.White; ClipsToBounds = true; heightConstraint = HeightAnchor.ConstraintEqualTo(0); }
public ActionButton() { BackgroundColor = ApplicationTheme.ActionBackgroundColor; SetTitleColor(ApplicationTheme.ActionForegroundColor, UIControlState.Normal); SetTitleColor(ApplicationTheme.ActionForegroundColor.ColorWithAlpha(0.5f), UIControlState.Disabled); Layer.CornerRadius = ApplicationTheme.CornerRadius; HeightAnchor.ConstraintEqualTo(ApplicationTheme.ActionButtonHeight).Active = true; }
public ToggleButton(string optionKey, bool selected, float width, float height) { OptionKey = optionKey; WidthAnchor.ConstraintEqualTo(width).Active = true; HeightAnchor.ConstraintEqualTo(height).Active = true; Layer.CornerRadius = 5; Selected = selected; TouchUpInside += (sender, args) => Selected = !Selected; }
public override void MovedToSuperview() { base.MovedToSuperview(); TopAnchor.ConstraintEqualTo(Superview.TopAnchor).Active = true; WidthAnchor.ConstraintEqualTo(Superview.WidthAnchor).Active = true; CenterXAnchor.ConstraintEqualTo(Superview.CenterXAnchor).Active = true; //Actual value is set with bindings a few lines below var heightConstraint = HeightAnchor.ConstraintEqualTo(1); heightConstraint.Active = true; prepareTitleLabel(); prepareSuggestionViews(); SetNeedsLayout(); LayoutIfNeeded(); this.DelayBind(() => { var heightConverter = new CollectionSizeToHeightConverter <Suggestion>( emptyHeight: emptyHeight, heightPerElement: suggestionHeight + distanceBetweenSuggestions, additionalHeight: distanceAbowTitleLabel + distanceBelowTitleLabel + (float)titleLabel.Frame.Height ); heightConverter.MaxCollectionSize = suggestionViews.Count; var bindingSet = this.CreateBindingSet <SuggestionsView, SuggestionsViewModel>(); bindingSet.Bind(this) .For(v => v.BindVisibility()) .To(vm => vm.IsEmpty); bindingSet.Bind(heightConstraint) .For(c => c.BindConstant()) .To(vm => vm.Suggestions) .WithConversion(heightConverter); for (int i = 0; i < suggestionViews.Count; i++) { bindingSet.Bind(suggestionViews[i]) .For(v => v.Suggestion) .To(vm => vm.Suggestions[i]); } bindingSet.Apply(); }); }
public override void LayoutSubviews() { if (FormsCell == null) { return; } //This sets the content views frame. base.LayoutSubviews(); if (CustomCell.IsMeasureOnce && Frame.Width <= _lastWidth && Frame.Height <= _lastHeight) { Layout.LayoutChildIntoBoundingRegion(FormsCell, new Rectangle(0, 0, _lastWidth, _lastHeight)); return; } SizeToFit(); Layout.LayoutChildIntoBoundingRegion(FormsCell, new Rectangle(0, 0, Frame.Width, Frame.Height)); if (_rendererRef == null) { return; } IVisualElementRenderer renderer; if (_rendererRef.TryGetTarget(out renderer)) { renderer.NativeView.Frame = FormsCell.Bounds.ToRectangleF(); } if (_heightConstraint != null) { _heightConstraint.Active = false; _heightConstraint?.Dispose(); } _heightConstraint = HeightAnchor.ConstraintEqualTo(Frame.Height); _heightConstraint.Priority = 999f; _heightConstraint.Active = true; _lastWidth = Frame.Width; _lastHeight = Frame.Height; }
private void ApplyDimensions() { if (Width == 0 && Height == 0) { return; } TranslatesAutoresizingMaskIntoConstraints = false; if (Width != 0) { WidthAnchor.ConstraintEqualTo(Width).Active = true; } if (Height != 0) { HeightAnchor.ConstraintEqualTo(Height).Active = true; } }
public CustomFloatingactionbutton(ActionButtonView View) { _view = View; SetIcon(); Layer.CornerRadius = (nfloat)_view.HeightRequest / 2; BackgroundColor = _view.BackgroundColor.ToUIColor(); heightConstraint = HeightAnchor.ConstraintEqualTo((nfloat)View.HeightRequest); heightConstraint.Active = true; widthConstraint = WidthAnchor.ConstraintEqualTo((nfloat)View.HeightRequest); widthConstraint.Active = true; TouchDown += delegate(object sender, EventArgs e) { UIView.Animate(0.1, 0, UIViewAnimationOptions.Autoreverse, () => { BackgroundColor = View.SelectedColor.ToUIColor(); }, () => { BackgroundColor = View.BackgroundColor.ToUIColor(); }); View.ClickAction(); }; _view.PropertyChanged += _view_PropertyChanged; }