Example #1
0
        void Initialize()
        {
            BubbleHighlightedImage = highlightedBubbleImage;
            BubbleImage            = normalBubbleImage;

            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[bubble]|",
                                                                           0,
                                                                           "bubble", BubbleImageView));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-2-[bubble]-2-|",
                                                                           0,
                                                                           "bubble", BubbleImageView
                                                                           ));
            BubbleImageView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[bubble(>=48)]",
                                                                               0,
                                                                               "bubble", BubbleImageView
                                                                               ));

            var vSpaceTop = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Top, 1, 10);

            ContentView.AddConstraint(vSpaceTop);

            var vSpaceBottom = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);

            ContentView.AddConstraint(vSpaceBottom);

            var msgTrailing = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.LessThanOrEqual, BubbleImageView, NSLayoutAttribute.Trailing, 1, -16);

            ContentView.AddConstraint(msgTrailing);

            var msgCenter = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, -3);

            ContentView.AddConstraint(msgCenter);

            MessageLabel.TextColor = UIColor.White;
        }
Example #2
0
        void Initialize()
        {
            BubbleHighlightedImage = highlightedBubbleImage;
            BubbleImg = normalBubbleImage;

            ContentView.AddConstraint(Layout.PinRightEdge(ContentView, BubbleView));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-2-[bubble]-2-|",
                                                                           NSLayoutFormatOptions.DirectionLeftToRight,
                                                                           "bubble", BubbleView
                                                                           ));
            BubbleView.AddConstraint(Layout.WidthMin(BubbleView, 48));

            var vSpaceTop = NSLayoutConstraint.Create(MessageLbl, NSLayoutAttribute.Top, NSLayoutRelation.Equal, BubbleView, NSLayoutAttribute.Top, 1, 10);

            ContentView.AddConstraint(vSpaceTop);

            var vSpaceBottom = NSLayoutConstraint.Create(MessageLbl, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleView, NSLayoutAttribute.Bottom, 1, -10);

            ContentView.AddConstraint(vSpaceBottom);

            var msgTrailing = NSLayoutConstraint.Create(MessageLbl, NSLayoutAttribute.Trailing, NSLayoutRelation.LessThanOrEqual, BubbleView, NSLayoutAttribute.Trailing, 1, -16);

            ContentView.AddConstraint(msgTrailing);

            var msgCenter = NSLayoutConstraint.Create(MessageLbl, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleView, NSLayoutAttribute.CenterX, 1, -3);

            ContentView.AddConstraint(msgCenter);
        }
Example #3
0
        void Initialize()
        {
            BubbleHighlightedImage = highlightedBubbleImage;
            BubbleImage            = normalBubbleImage;

            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[bubble]",
                                                                           (NSLayoutFormatOptions)0,
                                                                           "bubble", BubbleImageView));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-2-[bubble]-2-|",
                                                                           (NSLayoutFormatOptions)0,
                                                                           "bubble", BubbleImageView
                                                                           ));
            BubbleImageView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[bubble(>=48)]",
                                                                               (NSLayoutFormatOptions)0,
                                                                               "bubble", BubbleImageView
                                                                               ));

            var vSpaceTop = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Top, 1, 10);

            ContentView.AddConstraint(vSpaceTop);

            var vSpaceBottom = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);

            ContentView.AddConstraint(vSpaceBottom);

            var msgLeading = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Leading, NSLayoutRelation.GreaterThanOrEqual, BubbleImageView, NSLayoutAttribute.Leading, 1, 16);

            ContentView.AddConstraint(msgLeading);

            var msgCenter = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, 3);

            ContentView.AddConstraint(msgCenter);
        }
Example #4
0
 private void CreateUI()
 {
     SeparatorInset = UIEdgeInsets.Zero;
     _imageV        = new MvxCachedImageView {
         TranslatesAutoresizingMaskIntoConstraints = false,
         ContentMode = UIViewContentMode.ScaleAspectFit
     };
     ContentView.AddSubview(_imageV);
     ContentView.AddConstraint(NSLayoutConstraint.Create(_imageV, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Left, 1, 0));
     ContentView.AddConstraint(NSLayoutConstraint.Create(_imageV, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1, 0));
     ContentView.AddConstraint(NSLayoutConstraint.Create(_imageV, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Bottom, 1, 0));
     ContentView.AddConstraint(NSLayoutConstraint.Create(_imageV, NSLayoutAttribute.Width, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Width, IMAGE_WIDTH, 0));
     _priceL = new UILabel {
         TranslatesAutoresizingMaskIntoConstraints = false,
         Font          = UIFont.BoldSystemFontOfSize(12),
         TextAlignment = UITextAlignment.Right
     };
     _priceL.SetContentHuggingPriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Vertical);
     ContentView.AddSubview(_priceL);
     ContentView.AddConstraint(NSLayoutConstraint.Create(_priceL, NSLayoutAttribute.Left, NSLayoutRelation.Equal, _imageV, NSLayoutAttribute.Right, 1, MARGIN));
     ContentView.AddConstraint(NSLayoutConstraint.Create(_priceL, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Right, 1, -MARGIN));
     ContentView.AddConstraint(NSLayoutConstraint.Create(_priceL, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Bottom, 1, -MARGIN));
     _titleL = new UILabel {
         TranslatesAutoresizingMaskIntoConstraints = false,
         Lines = 0
     };
     ContentView.AddSubview(_titleL);
     ContentView.AddConstraint(NSLayoutConstraint.Create(_titleL, NSLayoutAttribute.Left, NSLayoutRelation.Equal, _imageV, NSLayoutAttribute.Right, 1, MARGIN));
     ContentView.AddConstraint(NSLayoutConstraint.Create(_titleL, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1, MARGIN));
     ContentView.AddConstraint(NSLayoutConstraint.Create(_titleL, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Right, 1, -MARGIN));
     ContentView.AddConstraint(NSLayoutConstraint.Create(_titleL, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _priceL, NSLayoutAttribute.Top, 1, -MARGIN));
 }
Example #5
0
        CollectionItemMultiCell(CGRect frame) : base(frame)
        {
            label = new UIButton(CoreGraphics.CGRect.Empty);
            label.SetTitleColor(UIColor.Black, UIControlState.Normal);
            label.TitleLabel.Lines         = 1;
            label.Font                     = UIFont.SystemFontOfSize(13);
            label.Frame                    = new CGRect(5, ContentView.Frame.Y, ContentView.Frame.Width - 20, ContentView.Frame.Height);
            label.TitleLabel.TextAlignment = UITextAlignment.Left;
            label.TranslatesAutoresizingMaskIntoConstraints = false;

            ContentView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.CenterY, 1, 0));
            ContentView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1, 2));
            //ContentView.AddConstraint(NSLayoutConstraint.Create(label, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Trailing, 1, -2));

            ContentView.AddSubview(label);

            imgIcon                 = new UIImageView(CoreGraphics.CGRect.Empty);
            imgIcon.Image           = UIImage.FromFile("close").ImageWithRenderingMode(UIKit.UIImageRenderingMode.AlwaysOriginal);
            imgIcon.BackgroundColor = UIColor.Clear;
            imgIcon.ContentMode     = UIViewContentMode.ScaleAspectFit;
            imgIcon.Frame           = new CGRect(label.Frame.X, label.Frame.Y, 10, 10);
            imgIcon.TranslatesAutoresizingMaskIntoConstraints = false;
            ContentView.AddSubview(imgIcon);

            ContentView.AddConstraint(NSLayoutConstraint.Create(imgIcon, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.CenterY, 1, 0));
            ContentView.AddConstraint(NSLayoutConstraint.Create(imgIcon, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Trailing, 1, -2));
            //ContentView.AddConstraint(NSLayoutConstraint.Create(imgIcon, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1, 5));

            ContentView.Layer.BackgroundColor = UIColor.Gray.CGColor;
            ContentView.Layer.CornerRadius    = 4;
        }
Example #6
0
        void Initialize()
        {
            iconContainer = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };
            taskIcon = new UIImageView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
            };
            taskNameLbl = new UILabel {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Lines         = 2,
            };

            iconContainer.AddSubview(taskIcon);
            ContentView.AddSubviews(iconContainer, taskNameLbl);

            iconContainer.Height(IconMaxArea.Height);
            taskIcon.CenterXY();

            NSLayoutConstraint constraint = null;

            constraint = NSLayoutConstraint.Create(iconContainer, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Left, 1, 10);
            ContentView.AddConstraint(constraint);
            constraint = NSLayoutConstraint.Create(iconContainer, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Right, 1, -10);
            ContentView.AddConstraint(constraint);

            ContentView.AddConstraint(Layout.VerticalSpacing(iconContainer, taskNameLbl));
            taskNameLbl.CenterX();
            ContentView.AddConstraints(Layout.PinLeftRightEdges(taskNameLbl, 10, 10));

            SetupSelectedView();
        }
Example #7
0
        protected override void OnDataContextAssigned()
        {
            if (DataContext != null)
            {
                _completionBar.BackgroundColor = BareUIHelper.ToColor(DataContext.Class?.Color);

                if (_constraintCompletionBarHeight != null)
                {
                    ContentView.RemoveConstraint(_constraintCompletionBarHeight);
                }

                nfloat multiplier = 1;
                if (DataContext.IsComplete)
                {
                    multiplier = 0;
                }
                else if (DataContext.Type == TaskOrEventType.Task)
                {
                    multiplier = 1 - (nfloat)DataContext.PercentComplete;
                }
                _constraintCompletionBarHeight = NSLayoutConstraint.Create(
                    _completionBar,
                    NSLayoutAttribute.Height,
                    NSLayoutRelation.Equal,
                    ContentView,
                    NSLayoutAttribute.Height,
                    multiplier,
                    0);
                ContentView.AddConstraint(_constraintCompletionBarHeight);

                _labelTitle.AttributedText = new NSAttributedString(DataContext.Name, strikethroughStyle: DataContext.IsComplete ? NSUnderlineStyle.Single : NSUnderlineStyle.None);

                _labelSubtitle.Text      = DataContext.Subtitle;
                _labelSubtitle.TextColor = BareUIHelper.ToColor(DataContext.Class?.Color);

                if (string.IsNullOrWhiteSpace(DataContext.Details))
                {
                    _labelDescription.Text = "";
                }
                else
                {
                    _labelDescription.Text = " - " + DataContext.Details;
                }
            }

            base.OnDataContextChanged();
        }
Example #8
0
 /// <summary>
 /// Sets the bottom constraint of the content view based on the last subview.
 /// </summary>
 protected virtual void UpdateContentViewBottomConstraint()
 {
     if (ContentView.Subviews != null && ContentView.Subviews.Length > 0)
     {
         if (_contentViewBottomConstraint != null)
         {
             ContentView.RemoveConstraint(_contentViewBottomConstraint);
         }
         var last = ContentView.Subviews[ContentView.Subviews.Length - 1];
         _contentViewBottomConstraint = NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, last, NSLayoutAttribute.Bottom, 1, 40f);
         ContentView.AddConstraint(
             _contentViewBottomConstraint
             );
         ContentView.SetNeedsLayout();
         ContentView.LayoutIfNeeded();
     }
 }
Example #9
0
        void Initialize()
        {
            BubbleHighlightedImage = highlightedBubbleImage;
            BubbleImage            = normalBubbleImage;

            var views = new NSMutableDictionary();

            views.Add(new NSString("bubble"), BubbleImageView);
            views.Add(new NSString("date"), DateLabel);

            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[bubble]|", 0, "bubble", BubbleImageView));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-2-[bubble]-[date]-2-|", 0, null, views));

            BubbleImageView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[bubble(>=48)]", 0, "bubble", BubbleImageView));

            var vSpaceTop = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Top, 1, 10);

            ContentView.AddConstraint(vSpaceTop);

            var vSpaceBottom = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);

            ContentView.AddConstraint(vSpaceBottom);

            var msgTrailing = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.LessThanOrEqual, BubbleImageView, NSLayoutAttribute.Trailing, 1, -16);

            ContentView.AddConstraint(msgTrailing);

            var msgCenter = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, -3);

            ContentView.AddConstraint(msgCenter);

            var vSpaceTopDate = NSLayoutConstraint.Create(DateLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, 3);

            ContentView.AddConstraint(vSpaceTopDate);

            var dateLeading = NSLayoutConstraint.Create(DateLabel, NSLayoutAttribute.Leading, NSLayoutRelation.GreaterThanOrEqual, BubbleImageView, NSLayoutAttribute.Leading, 1, 16);

            ContentView.AddConstraint(dateLeading);

            var dateCenter = NSLayoutConstraint.Create(DateLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, 3);

            ContentView.AddConstraint(dateCenter);

            MessageLabel.TextColor = UIColor.White;
        }
        public void UpdateItem(nfloat constraintSize)
        {
            Background.TranslatesAutoresizingMaskIntoConstraints = false;
            List <NSLayoutConstraint> constants = new List <NSLayoutConstraint>();

            foreach (var constraint in ContentView.Constraints)
            {
                if (constraint.FirstAttribute == NSLayoutAttribute.Width || constraint.FirstAttribute == NSLayoutAttribute.Height || constraint.FirstAttribute == NSLayoutAttribute.CenterX || constraint.FirstAttribute == NSLayoutAttribute.CenterY)
                {
                    constants.Add(constraint);
                }
            }
            ContentView.RemoveConstraints(constants.ToArray());
            ContentView.AddConstraint(ChallengesConstraints.ChallengesCollectionCellCenterXConstraint(Background, ContentView));
            ContentView.AddConstraint(ChallengesConstraints.ChallengesCollectionCellCenterYConstraint(Background, ContentView));
            ContentView.AddConstraint(ChallengesConstraints.ChallengesCollectionCellWidthConstraint(Background, ContentView, constraintSize));
            ContentView.AddConstraint(ChallengesConstraints.ChallengesCollectionCellHeightConstraint(Background, ContentView, constraintSize));
        }
Example #11
0
        private void SetupConstraints()
        {
            ContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            _topRulerRightConstraint = _topBorder.AtRightOf(ContentView, 14).ToLayoutConstraints().First();
            _topRulerLeftConstraint  = _topBorder.AtLeftOf(ContentView, 14).ToLayoutConstraints().First();

            ContentView.AddConstraint(_topRulerLeftConstraint);
            ContentView.AddConstraint(_topRulerRightConstraint);

            ContentView.AddConstraints(
                _topBorder.AtTopOf(ContentView),
                _topBorder.Height().EqualTo(1),

                _avatar.AtLeftOf(ContentView, 14),
                _avatar.WithSameCenterY(ContentView),
                _avatar.Height().EqualTo(45),
                _avatar.Width().EqualTo(45),

                _displayName.WithSameCenterY(_avatar).Plus(-13),
                _displayName.ToRightOf(_avatar, 10),

                _timeAgo.AtRightOf(ContentView, 14),
                _timeAgo.WithSameCenterY(_displayName).Plus(1),
                _timeAgo.ToRightOf(_displayName, 14),

                _unreadContainer.Below(_timeAgo, 5),
                _unreadContainer.AtRightOf(ContentView, 30),
                _unreadContainer.Width().EqualTo(20),
                _unreadContainer.Height().EqualTo(20),

                _numberUnread.WithSameCenterX(_unreadContainer),
                _numberUnread.WithSameCenterY(_unreadContainer),

                _lastMessage.Below(_displayName, 3),
                _lastMessage.WithSameLeft(_displayName),
                _lastMessage.ToLeftOf(_timeAgo),

                _bottomBorder.AtBottomOf(ContentView),
                _bottomBorder.AtLeftOf(ContentView),
                _bottomBorder.AtRightOf(ContentView),
                _bottomBorder.Height().EqualTo(1)
                );
        }
Example #12
0
            public ImageCell()
            {
                SelectionStyle = UITableViewCellSelectionStyle.None;
                ContentView.BackgroundColor = UIColor.Clear;
                BackgroundColor             = UIColor.Clear;

                var contenView = new UIView {
                    Alpha           = 0.5f,
                    BackgroundColor = UIColor.Black,
                    TranslatesAutoresizingMaskIntoConstraints = false
                };

                var imageView = new UIImageView(UIImage.FromBundle("logo"))
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };

                var closeButton = UIButton.FromType(UIButtonType.System);

                closeButton.Frame = new CoreGraphics.CGRect(20, 30, 50, 50);
                closeButton.SetTitle("x", UIControlState.Normal);
                closeButton.SetTitleColor(UIColor.White.ColorWithAlpha(0.8f), UIControlState.Normal);
                closeButton.Font = UIFont.FromName(closeButton.Font.Name, 35);
                CloseStream      = closeButton.RXTouchUpInside();

                var views = new NSDictionary("contenView", contenView, "imageView", imageView, "closeButton", closeButton);

                ContentView.Add(contenView);
                ContentView.Add(imageView);
                ContentView.Add(closeButton);

                ContentView.AddConstraint(NSLayoutConstraint.Create(contenView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.CenterX, 1f, 0f));
                ContentView.AddConstraint(NSLayoutConstraint.Create(contenView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.CenterY, 1f, 0f));
                ContentView.AddConstraint(NSLayoutConstraint.Create(contenView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Width, 1f, 0f));
                ContentView.AddConstraint(NSLayoutConstraint.Create(contenView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Height, 1f, 0f));

                ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[imageView(200)]", 0, null, views));
                ContentView.AddConstraint(NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.CenterX, 1f, 0f));
                ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-50-[imageView(60)]-30-|", 0, null, views));

                ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-10-[closeButton]", 0, null, views));
                ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-60-[closeButton]", 0, null, views));
            }
Example #13
0
        void Initialize()
        {
            strokeEmulator = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.White
            };
            strokeEmulator.Layer.MasksToBounds = false;
            strokeEmulator.Layer.ShadowOffset  = new CGSize(0, 0.5f);
            strokeEmulator.Layer.ShadowRadius  = 0;
            strokeEmulator.Layer.ShadowOpacity = 0.2f;
            strokeEmulator.Layer.ShadowColor   = UIColor.Black.CGColor;

            avatar = new UIImageView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ClipsToBounds = true,
                ContentMode   = UIViewContentMode.ScaleAspectFill
            };
            nickname = new UILabel {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Lines         = 2
            };
            ContentView.AddSubviews(strokeEmulator, avatar, nickname);

            avatarCenterY = NSLayoutConstraint.Create(avatar, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1, 0);
            avatarWidth   = Layout.Width(avatar, 0);
            avatarHeight  = Layout.Height(avatar, 0);
            ContentView.AddConstraints(new NSLayoutConstraint[] { avatarCenterY, avatarWidth, avatarHeight });

            strokeEmulatorCenterY = NSLayoutConstraint.Create(strokeEmulator, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1, 0);
            strokeEmulatorWidth   = Layout.Width(strokeEmulator, 0);
            strokeEmulatorHeight  = Layout.Height(strokeEmulator, 0);
            ContentView.AddConstraints(new NSLayoutConstraint[] { strokeEmulatorCenterY, strokeEmulatorWidth, strokeEmulatorHeight });

            avatar.CenterX();
            strokeEmulator.CenterX();

            nickNameTopSpacing = NSLayoutConstraint.Create(nickname, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1, 0);
            ContentView.AddConstraint(nickNameTopSpacing);
            ContentView.AddConstraints(Layout.PinLeftRightEdges(nickname, 0, 0));
        }
Example #14
0
        void Initialize()
        {
            BubbleHighlightedImage = highlightedBubbleImage;
            BubbleImage            = normalBubbleImage;

            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[bubble]",
                                                                           0,
                                                                           "bubble", BubbleImageView));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-2-[bubble]-2-|",
                                                                           0,
                                                                           "bubble", BubbleImageView
                                                                           ));
            BubbleImageView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[bubble(>=48)]",
                                                                               0,
                                                                               "bubble", BubbleImageView
                                                                               ));

            var vSpaceTop = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Top, 1, 10);

            ContentView.AddConstraint(vSpaceTop);

            var vSpaceBottom = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);

            ContentView.AddConstraint(vSpaceBottom);

            var msgLeading = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Leading, NSLayoutRelation.GreaterThanOrEqual, BubbleImageView, NSLayoutAttribute.Leading, 1, 16);

            ContentView.AddConstraint(msgLeading);

            var msgCenter = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, 3);

            ContentView.AddConstraint(msgCenter);
            Hediye.Hidden = true;
            ContentView.BackgroundColor = UIColor.Clear;
            //MessageLabel.Layer.CornerRadius = 25;
            //MessageLabel.Layer.BorderWidth = 10f;
            //MessageLabel.ClipsToBounds = true;
            //MessageLabel.Layer.BorderColor = UIColor.FromRGB(229, 229, 234).CGColor;
            //MessageLabel.BackgroundColor = UIColor.FromRGB(229, 229, 234);
            //MessageLabel.Insent = UIEdgeInsetsMake(10, 0, 10, 0);
        }
Example #15
0
        private void SetupConstraints()
        {
            ContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            _bottomRulerLeftConstraint  = _bottomRuler.AtLeftOf(ContentView, 14).ToLayoutConstraints().First();
            _bottomRulerRightConstraint = _bottomRuler.AtRightOf(ContentView, 14).ToLayoutConstraints().First();

            ContentView.AddConstraint(_bottomRulerLeftConstraint);
            ContentView.AddConstraint(_bottomRulerRightConstraint);

            ContentView.AddConstraints(
                _avatar.AtTopOf(ContentView, 14),
                _avatar.AtLeftOf(ContentView, 14),
                _avatar.Height().EqualTo(35),
                _avatar.Width().EqualTo(35),

                _displayName.WithSameTop(_avatar).Minus(2),
                _displayName.Height().EqualTo(20),
                _displayName.ToRightOf(_avatar, 13),

                _timeAgo.ToRightOf(_displayName, 7),
                _timeAgo.WithSameBottom(_displayName),
                //_timeAgo.AtLeftOf(ContentView, 14),

                Text.Below(_displayName, 3),
                Text.ToLeftOf(_contextButton, 10),
                Text.ToRightOf(_avatar, 10),

                _contextButton.AtRightOf(ContentView, 10),
                _contextButton.AtTopOf(ContentView, 5),
                _contextButton.Width().EqualTo(30),
                _contextButton.Height().EqualTo(30),

                _bottomRuler.Height().EqualTo(1),
                _bottomRuler.AtBottomOf(ContentView)
                );
        }
Example #16
0
        private void SetupConstraints()
        {
            ContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            // Backpanel bottom constraint for usage in detailsview
            _backPanelBottomConstraint = _backPanel.AtBottomOf(ContentView, 0).WithIdentifier("BackPanelBottomToView").ToLayoutConstraints().First();

            // Main image constraints
            _mainImageHeightConstraint        = _mainImage.Height().EqualTo(0).WithIdentifier("MainImageHeightConstraint").ToLayoutConstraints().First();
            _mainImageBottomSpacingConstraint = _mainImage.Above(_leftSubImage, 3).WithIdentifier("MainImageAboveLeftSub").ToLayoutConstraints().First();

            // Sub image constraints
            _subImageSpacingConstraint = _leftSubImage.Above(_ruler, 8).WithIdentifier("LeftSubImageAboveRuler").ToLayoutConstraints().First();
            _subImageHeightConstraint  = _leftSubImage.Height().EqualTo(50).WithIdentifier("LeftSubHeight").ToLayoutConstraints().First();

            ContentView.AddConstraint(_backPanelBottomConstraint);
            ContentView.AddConstraint(_mainImageHeightConstraint);
            ContentView.AddConstraint(_mainImageBottomSpacingConstraint);
            ContentView.AddConstraint(_subImageSpacingConstraint);
            ContentView.AddConstraint(_subImageHeightConstraint);

            ContentView.AddConstraints(
                // TOP
                _backPanel.AtTopOf(ContentView, 5).WithIdentifier("BackPanelAtTopContentView"),
                _backPanel.AtRightOf(ContentView, 0).WithIdentifier("BackPanelAtRightOfContentView"),
                _backPanel.AtLeftOf(ContentView, 0).WithIdentifier("BackPanelAtLeftOfContentView"),

                _topBorder.AtTopOf(_backPanel).WithIdentifier("TopBorderAtTopOfBackpanel"),
                _topBorder.AtLeftOf(_backPanel).WithIdentifier("TopBorderAtLeftOfBackpanel"),
                _topBorder.AtRightOf(_backPanel).WithIdentifier("TopBorderAtRightOfBackpanel"),
                _topBorder.Height().EqualTo(1).WithIdentifier("TopBorderHeightEqualTo1"),

                _avatarImageView.Below(_topBorder, 14).WithIdentifier("AvatarImageBelowTopBorder"),
                _avatarImageView.AtLeftOf(_backPanel, 14).WithIdentifier("AvatarImageAtLeftOfBackPanel"),
                _avatarImageView.Height().EqualTo(45).WithIdentifier("AvatarImageHeightEquealTo"),
                _avatarImageView.Width().EqualTo(45).WithIdentifier("AvatarImageWidthEqualTo"),

                _displayName.Bottom().EqualTo().CenterYOf(_avatarImageView).Minus(1.5f).WithIdentifier("DisplayNameBottomEqualtoCenterYOfAvatarImage"),
                _displayName.ToRightOf(_avatarImageView, 10).WithIdentifier("DisplayNameToRightOfAvatarImage"),
                _displayName.ToLeftOf(_contextButton, 13),

                _timeAgo.Below(_displayName, 3).WithIdentifier("TimeAgoBelowDisplayName"),
                _timeAgo.WithSameLeft(_displayName).WithIdentifier("TimeAgoWithSameLeftDisplayName"),
                _timeAgo.WithSameRight(_displayName).WithIdentifier("TimeAgoWithSameRightDisplayName"),

                _postText.Below(_avatarImageView, 8).WithIdentifier("PostTextBelowAvatarImage"),
                _postText.AtLeftOf(_backPanel, 11).WithIdentifier("PostTextAtLeftOfBackPanel"),
                _postText.AtRightOf(_backPanel, 14).WithIdentifier("PostTextAtRightOfBackPanel"),

                _contextButton.AtRightOf(_backPanel, 10),
                _contextButton.AtTopOf(_backPanel, 5),
                _contextButton.Width().EqualTo(30),
                _contextButton.Height().EqualTo(30),

                // CONTENT
                _mainImage.AtLeftOf(_backPanel).WithIdentifier("MainImageAtLeftOfBackPanel"),
                _mainImage.AtRightOf(_backPanel).WithIdentifier("MainImageAtRightOfBackPanel"),

                // INFORMATION
                _dateBackPanel.AtTopOf(_mainImage, 20).WithIdentifier("DateBackPanelAtTopOfContentView"),
                _dateBackPanel.AtRightOf(_mainImage, 20).WithIdentifier("DateBackPanelAtRightOfContentView"),
                _dateBackPanel.Width().EqualTo(90).WithIdentifier("DateBackPanelWidth"),
                _dateBackPanel.Height().EqualTo(25).WithIdentifier("DateBackPanelHeight"),

                _date.WithSameCenterY(_dateBackPanel).WithIdentifier("DateAtRightOfContentView"),
                _date.WithSameCenterX(_dateBackPanel).WithIdentifier("DateAtBottomOfContentView"),

                _infoContainerPlaceholder.AtTopOf(_mainImage),
                _infoContainerPlaceholder.AtLeftOf(_mainImage),
                _infoContainerPlaceholder.AtRightOf(_mainImage),
                _infoContainerPlaceholder.AtBottomOf(_mainImage),

                _infoContainer.AtLeftOf(_infoContainerPlaceholder).WithIdentifier("InfoContainerAtLeftOfBackground"),
                _infoContainer.AtRightOf(_infoContainerPlaceholder).WithIdentifier("InforContainerAtRightOfBackground"),
                _infoContainer.WithSameCenterY(_infoContainerPlaceholder),

                _title.AtLeftOf(_infoContainer, 20).WithIdentifier("NameAtLeftOfBackgorund"),
                _title.AtRightOf(_infoContainer, 20).WithIdentifier("NameAtRightBackground"),
                _title.AtTopOf(_infoContainer, 4),

                _time.Below(_title, 5).WithIdentifier("TimeAboveLocation"),
                _time.AtLeftOf(_infoContainer, 20).WithIdentifier("TimeAtLeftOfBackground"),
                _time.AtRightOf(_infoContainer, 20).WithIdentifier("TimeAtRightOfBackground"),

                _location.Below(_time, 3),
                _location.AtBottomOf(_infoContainer),
                _location.AtLeftOf(_infoContainer, 20),
                _location.AtRightOf(_infoContainer, 20),

                // ---------------------------------------------

                _leftSubImage.AtLeftOf(_backPanel).WithIdentifier("LeftSubImageAtLeftOfBackPanel"),

                _rightSubImage.WithSameTop(_leftSubImage).WithIdentifier("RightSubImageWithSameTopLeftSub"),
                _rightSubImage.WithSameWidth(_leftSubImage).WithIdentifier("RightSubImageWithSameWidthLeftSub"),
                _rightSubImage.AtRightOf(_backPanel).WithIdentifier("RightSubImageAtRightOfBackPanel"),
                _rightSubImage.ToRightOf(_leftSubImage, 3).WithIdentifier("RightSubImageToRightOfLeftSub"),
                _rightSubImage.WithSameHeight(_leftSubImage).WithIdentifier("RightSubImageWithSameHeightLeftSub"),

                // BOTTOM
                _ruler.Above(_commentButton).WithIdentifier("RulerBelowContentContainer"),
                _ruler.Height().EqualTo(1).WithIdentifier("RulerHeightEqualTo1"),
                _ruler.WithSameLeft(_avatarImageView).WithIdentifier("RulerWithSameLeftAvatarImage"),
                _ruler.WithSameRight(_displayName).WithIdentifier("RulerWithSameRightDisplayName"),

                _commentButton.Above(_bottomBorder).WithIdentifier("CommentButtonBelowRuler"),
                _commentButton.WithSameLeft(_avatarImageView).WithIdentifier("CommentWithSameLeftAvatarImage"),
                _commentButton.Height().EqualTo(50).WithIdentifier("CommentButtonHeightEqualTo"),

                _likeButton.WithSameCenterY(_commentButton).WithIdentifier("LikeButtonWithSameCenterYCommentButton"),
                _likeButton.ToRightOf(_commentButton, 15).WithIdentifier("LikeButtonToRightOfCommentButton"),
                _likeButton.WithSameHeight(_commentButton).WithIdentifier("LikeButtonWithSameHeightCommentButton"),

                _bottomBorder.AtBottomOf(_backPanel).WithIdentifier("BottomBorderAtBottomOfBackPanel"),
                _bottomBorder.AtLeftOf(_backPanel).WithIdentifier("BottomBorderAtLeftOfBackPanel"),
                _bottomBorder.AtRightOf(_backPanel).WithIdentifier("BottomBorderAtRightOfBackPanel"),
                _bottomBorder.Height().EqualTo(1).WithIdentifier("BottomBorderHeightEqualTo1")
                );
        }
Example #17
0
        private void SetupConstraints()
        {
            ContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            _imageBackgroundTopSpacingConstraint =
                _imageBackground.Below(_infoBackGround, 5).ToLayoutConstraints().First();
            _imageBackgroundHeightConstraint = _imageBackground.Height().EqualTo(134).ToLayoutConstraints().First();

            _attendingHeight = _ruler.Below(_header, 125).ToLayoutConstraints().First();

            ContentView.AddConstraint(_imageBackgroundHeightConstraint);
            ContentView.AddConstraint(_imageBackgroundTopSpacingConstraint);
            ContentView.AddConstraint(_attendingHeight);

            ContentView.AddConstraints(
                _header.AtTopOf(ContentView),
                _header.AtLeftOf(ContentView),
                _header.AtRightOf(ContentView),
                _header.Height().EqualTo(345),

                _dateBackPanel.AtTopOf(ContentView, 20),
                _dateBackPanel.AtRightOf(ContentView, 20),
                _dateBackPanel.Width().EqualTo(90),
                _dateBackPanel.Height().EqualTo(25),

                _date.WithSameCenterY(_dateBackPanel),
                _date.WithSameCenterX(_dateBackPanel),

                _infoContainerPlaceHolder.Below(_dateBackPanel),
                _infoContainerPlaceHolder.Above(_attendButton),
                _infoContainerPlaceHolder.AtLeftOf(_header),
                _infoContainerPlaceHolder.AtRightOf(_header),

                _infoContainer.AtLeftOf(_header),
                _infoContainer.AtRightOf(_header),
                _infoContainer.WithSameCenterY(_infoContainerPlaceHolder),

                _title.AtTopOf(_infoContainer),
                _title.AtRightOf(_infoContainer, 20),
                _title.AtLeftOf(_infoContainer, 20),

                _time.Below(_title, 5),
                _time.AtLeftOf(_infoContainer, 20),
                _time.AtRightOf(_infoContainer, 20),

                _location.Below(_time, 5),
                _location.AtLeftOf(_infoContainer, 20),
                _location.AtRightOf(_infoContainer, 20),
                _location.Below(_infoContainer),

                _attendButton.Height().EqualTo(45),
                _attendButton.AtBottomOf(_header, 39),
                _attendButton.AtLeftOf(_header, 39),
                _attendButton.AtRightOf(_header, 39),

                _infoBackGround.Below(_header),
                _infoBackGround.AtLeftOf(ContentView),
                _infoBackGround.AtRightOf(ContentView),

                _attendingLabel.Below(_header, 30),
                _attendingLabel.AtLeftOf(ContentView, 14),
                _attendingLabel.AtRightOf(ContentView, 14),

                _attendingCollection.Below(_attendingLabel, 13),
                _attendingCollection.AtLeftOf(ContentView, 14),
                _attendingCollection.AtRightOf(ContentView, 14),
                _attendingCollection.Height().EqualTo(31),

                _ruler.AtLeftOf(ContentView, 10),
                _ruler.AtRightOf(ContentView, 10),
                _ruler.Height().EqualTo(1),

                _eventInfoHeader.Below(_ruler, 13),
                _eventInfoHeader.AtLeftOf(ContentView, 14),
                _eventInfoHeader.Height().EqualTo(20),

                _eventDateLabel.Below(_eventInfoHeader, 14),
                _eventDateLabel.AtLeftOf(ContentView, 14),
                _eventDateLabel.Height().EqualTo(20),

                _eventDate.AtLeftOf(ContentView, 100),
                _eventDate.WithSameCenterY(_eventDateLabel),

                _eventTimeLabel.Below(_eventDateLabel, 7),
                _eventTimeLabel.AtLeftOf(ContentView, 14),

                _eventTime.WithSameCenterY(_eventTimeLabel),
                _eventTime.WithSameLeft(_eventDate),
                _eventTime.AtRightOf(ContentView, 14),

                _eventLocationLabel.Below(_eventTimeLabel, 7),
                _eventLocationLabel.AtLeftOf(ContentView, 14),

                EventLocation.WithSameTop(_eventLocationLabel),
                EventLocation.WithSameLeft(_eventDate),
                EventLocation.AtRightOf(ContentView, 14),

                _infoBottomBorder.Below(EventLocation, 30),
                _infoBottomBorder.Height().EqualTo(1),
                _infoBottomBorder.AtLeftOf(ContentView),
                _infoBottomBorder.AtRightOf(ContentView),
                _infoBottomBorder.AtBottomOf(_infoBackGround),

                _imageBackground.AtLeftOf(ContentView),
                _imageBackground.AtRightOf(ContentView),

                _imageTopBorder.AtTopOf(_imageBackground),
                _imageTopBorder.AtLeftOf(ContentView),
                _imageTopBorder.AtRightOf(ContentView),
                _imageTopBorder.Height().EqualTo(1),

                _imageBottomBorder.AtBottomOf(_imageBackground),
                _imageBottomBorder.AtLeftOf(ContentView),
                _imageBottomBorder.AtRightOf(ContentView),
                _imageBottomBorder.Height().EqualTo(1),

                _imageCollection.AtTopOf(_imageBackground),
                _imageCollection.AtLeftOf(_imageBackground, 14),
                _imageCollection.AtRightOf(_imageBackground, 14),
                _imageCollection.AtBottomOf(_imageBackground),

                _aboutBackground.Below(_imageBackground, 5),
                _aboutBackground.AtLeftOf(ContentView),
                _aboutBackground.AtRightOf(ContentView),

                _aboutHeaderLabel.AtTopOf(_aboutBackground, 14),
                _aboutHeaderLabel.AtLeftOf(_aboutBackground, 14),
                _aboutHeaderLabel.AtRightOf(_aboutBackground, 14),
                _aboutHeaderLabel.Height().EqualTo(20),

                AboutText.Below(_aboutHeaderLabel, 13),
                AboutText.AtLeftOf(_aboutBackground, 12),
                AboutText.AtRightOf(_aboutBackground, 12),

                _aboutTopBorder.AtTopOf(_aboutBackground),
                _aboutTopBorder.Height().EqualTo(1),
                _aboutTopBorder.AtLeftOf(_aboutBackground),
                _aboutTopBorder.AtRightOf(_aboutBackground),

                _aboutRuler.Below(AboutText, 10),
                _aboutRuler.AtLeftOf(_aboutBackground),
                _aboutRuler.AtRightOf(_aboutBackground),
                _aboutRuler.Height().EqualTo(1),
                _aboutRuler.AtBottomOf(_aboutBackground)

                //_commentButton.Below(_aboutRuler),
                //_commentButton.AtLeftOf(ContentView, 14),
                //_commentButton.Height().EqualTo(50),
                );
        }
        public FormEntryTableViewCell(
            string labelName           = null,
            bool useTextView           = false,
            nfloat?height              = null,
            bool useLabelAsPlaceholder = false,
            float leadingConstant      = 15f)
            : base(UITableViewCellStyle.Default, nameof(FormEntryTableViewCell))
        {
            var descriptor = UIFontDescriptor.PreferredBody;
            var pointSize  = descriptor.PointSize;

            if (labelName != null && !useLabelAsPlaceholder)
            {
                Label = new UILabel
                {
                    Text = labelName,
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font      = UIFont.FromDescriptor(descriptor, 0.8f * pointSize),
                    TextColor = ThemeHelpers.MutedColor
                };

                ContentView.Add(Label);
            }

            if (useTextView)
            {
                TextView = new UITextView
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font            = UIFont.FromDescriptor(descriptor, pointSize),
                    TextColor       = ThemeHelpers.TextColor,
                    TintColor       = ThemeHelpers.TextColor,
                    BackgroundColor = ThemeHelpers.BackgroundColor
                };

                if (!ThemeHelpers.LightTheme)
                {
                    TextView.KeyboardAppearance = UIKeyboardAppearance.Dark;
                }

                ContentView.Add(TextView);
                ContentView.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, leadingConstant),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextView, NSLayoutAttribute.Trailing, 1f, 15f),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextView, NSLayoutAttribute.Bottom, 1f, 10f)
                });

                if (labelName != null && !useLabelAsPlaceholder)
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f));
                }
                else
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f));
                }

                if (height.HasValue)
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value));
                }

                TextView.Changed += (object sender, EventArgs e) =>
                {
                    ValueChanged?.Invoke(sender, e);
                };
            }

            else
            {
                TextField = new UITextField
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BorderStyle     = UITextBorderStyle.None,
                    Font            = UIFont.FromDescriptor(descriptor, pointSize),
                    ClearButtonMode = UITextFieldViewMode.WhileEditing,
                    TextColor       = ThemeHelpers.TextColor,
                    TintColor       = ThemeHelpers.TextColor,
                    BackgroundColor = ThemeHelpers.BackgroundColor
                };

                if (!ThemeHelpers.LightTheme)
                {
                    TextField.KeyboardAppearance = UIKeyboardAppearance.Dark;
                }

                if (useLabelAsPlaceholder)
                {
                    TextField.Placeholder = labelName;
                }

                ContentView.Add(TextField);
                ContentView.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, leadingConstant),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Trailing, 1f, 15f),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Bottom, 1f, 10f)
                });

                if (labelName != null && !useLabelAsPlaceholder)
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f));
                }
                else
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f));
                }

                if (height.HasValue)
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value));
                }

                TextField.AddTarget((object sender, EventArgs e) =>
                {
                    ValueChanged?.Invoke(sender, e);
                }, UIControlEvent.EditingChanged);
            }

            if (labelName != null && !useLabelAsPlaceholder)
            {
                ContentView.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(Label, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, leadingConstant),
                    NSLayoutConstraint.Create(Label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Trailing, 1f, 15f)
                });
            }
        }
        public PickerTableViewCell(
            string labelName,
            nfloat?height = null)
            : base(UITableViewCellStyle.Default, nameof(PickerTableViewCell))
        {
            var descriptor = UIFontDescriptor.PreferredBody;
            var pointSize  = descriptor.PointSize;

            Label = new UILabel
            {
                Text = labelName,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromDescriptor(descriptor, 0.8f * pointSize),
                TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f)
            };

            ContentView.Add(Label);

            TextField = new NoCaretField
            {
                BorderStyle = UITextBorderStyle.None,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.FromDescriptor(descriptor, pointSize)
            };

            var width   = (float)UIScreen.MainScreen.Bounds.Width;
            var toolbar = new UIToolbar(new RectangleF(0, 0, width, 44))
            {
                BarStyle    = UIBarStyle.Default,
                Translucent = true
            };
            var spacer     = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (o, a) =>
            {
                var s = (PickerSource)Picker.Model;
                if (s.SelectedIndex == -1 && Items != null && Items.Count > 0)
                {
                    UpdatePickerSelectedIndex(0);
                }
                TextField.Text = s.SelectedItem;
                TextField.ResignFirstResponder();
            });

            toolbar.SetItems(new[] { spacer, doneButton }, false);

            TextField.InputView          = Picker;
            TextField.InputAccessoryView = toolbar;

            ContentView.Add(TextField);

            ContentView.AddConstraints(new NSLayoutConstraint[] {
                NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f),
                NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Trailing, 1f, 15f),
                NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Bottom, 1f, 10f),
                NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f),
                NSLayoutConstraint.Create(Label, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f),
                NSLayoutConstraint.Create(Label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f),
                NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Trailing, 1f, 15f)
            });

            if (height.HasValue)
            {
                ContentView.AddConstraint(
                    NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value));
            }

            Picker.Model = new PickerSource(this);
        }
        public FormEntryTableViewCell(
            string labelName           = null,
            bool useTextView           = false,
            nfloat?height              = null,
            bool useLabelAsPlaceholder = false)
            : base(UITableViewCellStyle.Default, nameof(FormEntryTableViewCell))
        {
            var descriptor = UIFontDescriptor.PreferredBody;
            var pointSize  = descriptor.PointSize;

            if (labelName != null && !useLabelAsPlaceholder)
            {
                Label = new UILabel
                {
                    Text = labelName,
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font      = UIFont.FromDescriptor(descriptor, 0.8f * pointSize),
                    TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f)
                };

                ContentView.Add(Label);
            }

            if (useTextView)
            {
                TextView = new UITextView
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.FromDescriptor(descriptor, pointSize)
                };

                ContentView.Add(TextView);
                ContentView.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextView, NSLayoutAttribute.Trailing, 1f, 15f),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextView, NSLayoutAttribute.Bottom, 1f, 10f)
                });

                if (labelName != null && !useLabelAsPlaceholder)
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f));
                }
                else
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f));
                }

                if (height.HasValue)
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value));
                }
            }
            else
            {
                TextField = new UITextField
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BorderStyle     = UITextBorderStyle.None,
                    Font            = UIFont.FromDescriptor(descriptor, pointSize),
                    ClearButtonMode = UITextFieldViewMode.WhileEditing
                };

                if (useLabelAsPlaceholder)
                {
                    TextField.Placeholder = labelName;
                }

                ContentView.Add(TextField);
                ContentView.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Trailing, 1f, 15f),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Bottom, 1f, 10f)
                });

                if (labelName != null && !useLabelAsPlaceholder)
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f));
                }
                else
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f));
                }

                if (height.HasValue)
                {
                    ContentView.AddConstraint(
                        NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value));
                }
            }

            if (labelName != null && !useLabelAsPlaceholder)
            {
                ContentView.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(Label, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f),
                    NSLayoutConstraint.Create(Label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f),
                    NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Trailing, 1f, 15f)
                });
            }
        }
Example #21
0
        public UITaskCell(string cellId) : base(cellId)
        {
            var graySideBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromWhiteAlpha(180 / 255f, 1)
            };

            ContentView.AddSubview(graySideBar);
            graySideBar.SetWidth(8);
            graySideBar.PinToLeft(ContentView);
            graySideBar.StretchHeight(ContentView);

            _completionBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            ContentView.AddSubview(_completionBar);
            _completionBar.SetWidth(8);
            _completionBar.PinToLeft(ContentView);
            ContentView.AddConstraint(NSLayoutConstraint.Create(
                                          _completionBar,
                                          NSLayoutAttribute.CenterY,
                                          NSLayoutRelation.Equal,
                                          ContentView,
                                          NSLayoutAttribute.CenterY,
                                          1,
                                          0));

            _stackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis = UILayoutConstraintAxis.Vertical
            };

            var titleAndDescription = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            {
                _labelTitle = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredCaption1
                };
                titleAndDescription.Add(_labelTitle);
                _labelTitle.StretchHeight(titleAndDescription);

                _labelDescription = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font      = UIFont.PreferredCaption2,
                    TextColor = UIColor.DarkGray
                };
                titleAndDescription.Add(_labelDescription);
                _labelDescription.StretchHeight(titleAndDescription);

                titleAndDescription.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[title][description]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                       "title", _labelTitle,
                                                                                       "description", _labelDescription));

                // Don't let title compress, the description should be the one that shrinks
                _labelTitle.SetContentCompressionResistancePriority(501, UILayoutConstraintAxis.Horizontal);
                _labelDescription.SetContentCompressionResistancePriority(499, UILayoutConstraintAxis.Horizontal);

                // Don't let the title unnecessarily expand either
                _labelTitle.SetContentHuggingPriority(501, UILayoutConstraintAxis.Horizontal);
            }
            _stackView.AddArrangedSubview(titleAndDescription);
            titleAndDescription.StretchWidth(_stackView);

            _labelSubtitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.PreferredCaption1
            };
            _stackView.AddArrangedSubview(_labelSubtitle);
            _labelSubtitle.StretchWidth(_stackView);

            ContentView.AddSubview(_stackView);
            _stackView.StretchWidthAndHeight(ContentView, left: 16, top: 8, bottom: 8);
        }
Example #22
0
        void Initialize()
        {
            BubbleHighlightedImage = highlightedBubbleImage;
            BubbleImage            = normalBubbleImage;

            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[bubble]|",
                                                                           0,
                                                                           "bubble", BubbleImageView));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-2-[bubble]-2-|",
                                                                           0,
                                                                           "bubble", BubbleImageView
                                                                           ));
            BubbleImageView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[bubble(>=48)]",
                                                                               0,
                                                                               "bubble", BubbleImageView
                                                                               ));

            var vSpaceTop = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Top, 1, 10);

            ContentView.AddConstraint(vSpaceTop);

            var vSpaceBottom = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);

            ContentView.AddConstraint(vSpaceBottom);

            var msgTrailing = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.LessThanOrEqual, BubbleImageView, NSLayoutAttribute.Trailing, 1, -16);

            ContentView.AddConstraint(msgTrailing);

            var msgCenter = NSLayoutConstraint.Create(MessageLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, -3);

            ContentView.AddConstraint(msgCenter);



            //var vSpaceBottom0 = NSLayoutConstraint.Create(AudioDownloadButton, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);
            //ContentView.AddConstraint(vSpaceBottom0);

            //var msgCenter0 = NSLayoutConstraint.Create(AudioDownloadButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, -10);
            //ContentView.AddConstraint(msgCenter0);



            var vSpaceBottom1 = NSLayoutConstraint.Create(AudioPlayButton, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);

            ContentView.AddConstraint(vSpaceBottom1);

            var msgCenter1 = NSLayoutConstraint.Create(AudioPlayButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, -3);            //

            ContentView.AddConstraint(msgCenter1);


            //var vSpaceBottom2 = NSLayoutConstraint.Create(AudioStopButton, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);
            //ContentView.AddConstraint(vSpaceBottom2);

            //var msgCenter2 = NSLayoutConstraint.Create(AudioStopButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, -80);
            //ContentView.AddConstraint(msgCenter2);

            var vSpaceBottomi = NSLayoutConstraint.Create(ImageAttachment, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.Bottom, 1, -10);

            ContentView.AddConstraint(vSpaceBottomi);


            var msgCenteri = NSLayoutConstraint.Create(ImageAttachment, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, BubbleImageView, NSLayoutAttribute.CenterX, 1, -3);

            ContentView.AddConstraint(msgCenteri);

            MessageLabel.TextColor = UIColor.White;
        }
Example #23
0
        public UIGradeCell(string cellId) : base(cellId)
        {
            var graySideBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromWhiteAlpha(180 / 255f, 1)
            };

            ContentView.AddSubview(graySideBar);
            graySideBar.SetWidth(8);
            graySideBar.PinToLeft(ContentView);
            graySideBar.StretchHeight(ContentView);

            _completionBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            ContentView.AddSubview(_completionBar);
            _completionBar.SetWidth(8);
            _completionBar.PinToLeft(ContentView);
            ContentView.AddConstraint(NSLayoutConstraint.Create(
                                          _completionBar,
                                          NSLayoutAttribute.CenterY,
                                          NSLayoutRelation.Equal,
                                          ContentView,
                                          NSLayoutAttribute.CenterY,
                                          1,
                                          0));

            _stackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis = UILayoutConstraintAxis.Vertical
            };

            var titleAndGrade = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            {
                _labelTitle = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredCaption1
                };
                BindingHost.SetLabelTextBinding(_labelTitle, nameof(DataContext.Name));
                titleAndGrade.Add(_labelTitle);
                _labelTitle.StretchHeight(titleAndGrade);

                _labelGrade = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredCaption2.Bold()
                };
                BindingHost.SetLabelTextBinding(_labelGrade, nameof(DataContext.GradeSubtitle));
                titleAndGrade.Add(_labelGrade);
                _labelGrade.StretchHeight(titleAndGrade);

                titleAndGrade.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[title][grade]-16-|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                 "title", _labelTitle,
                                                                                 "grade", _labelGrade));

                // Don't let grade compress, the title should be the one that shrinks
                _labelGrade.SetContentCompressionResistancePriority(501, UILayoutConstraintAxis.Horizontal);
                _labelTitle.SetContentCompressionResistancePriority(499, UILayoutConstraintAxis.Horizontal);

                // Don't let the grade unnecessarily expand either
                _labelGrade.SetContentHuggingPriority(501, UILayoutConstraintAxis.Horizontal);
            }
            _stackView.AddArrangedSubview(titleAndGrade);
            titleAndGrade.StretchWidth(_stackView);

            _labelDescription = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.PreferredCaption1,
                TextColor = UIColor.DarkGray
            };
            BindingHost.SetLabelTextBinding(_labelDescription, nameof(DataContext.Details));
            _stackView.AddArrangedSubview(_labelDescription);
            _labelDescription.StretchWidth(_stackView);

            ContentView.AddSubview(_stackView);
            _stackView.StretchWidthAndHeight(ContentView, left: 16, top: 8, bottom: 8);

            BindingHost.SetBinding(nameof(DataContext.IsDropped), delegate
            {
                if (_constraintCompletionBarHeight != null)
                {
                    ContentView.RemoveConstraint(_constraintCompletionBarHeight);
                }

                nfloat multiplier = 1;
                if (DataContext.IsDropped)
                {
                    multiplier = 0;
                }
                _constraintCompletionBarHeight = NSLayoutConstraint.Create(
                    _completionBar,
                    NSLayoutAttribute.Height,
                    NSLayoutRelation.Equal,
                    ContentView,
                    NSLayoutAttribute.Height,
                    multiplier,
                    0);
                ContentView.AddConstraint(_constraintCompletionBarHeight);
            });
        }