void ReleaseDesignerOutlets ()
		{
			if (TableHeightConstrant != null) {
				TableHeightConstrant.Dispose ();
				TableHeightConstrant = null;
			}

			if (ButtonTable != null) {
				ButtonTable.Dispose ();
				ButtonTable = null;
			}
		}
        public DifficultyView(IntPtr handle)
            : base(handle)
        {
            // HACK Not really nice, but...
              foreach (var c in this.Superview.Constraints)
              {
            if (c.FirstAttribute == NSLayoutAttribute.Leading && c.FirstItem == this)
              _leading = c;

            if (c.FirstAttribute == NSLayoutAttribute.Trailing && c.SecondItem == this)
              _trailing = c;
              }

              _leadingBaseConstant = _leading.Constant;
              _trailingBaseConstant = _trailing.Constant;
        }
Esempio n. 3
0
		public static void ScrollViewWithTableView(this UITableView tableView, UIView view, NSLayoutConstraint viewTopConstraint, NSLayoutConstraint tableViewTopConstraint, bool stickToTop = true)
		{
			var offset = tableView.ContentOffset.Y;
//			var headerFrame = view.Frame;
//			var tableViewFrame = tableView.Frame;
//
//			var point = tableView.PanGestureRecognizer.TranslationInView (tableView) ;
//
//			if(point.Y <= 0 && (point.Y * -1) <= view.Frame.Height) {
//				viewTopConstraint.Constant = point.Y;	
//				System.Diagnostics.Debug.WriteLine ("POINT: " + point.Y);
//			}
//			else if (viewTopConstraint.Constant < 0 && viewTopConstraint.Constant >= -view.Frame.Height)
//			{
//				viewTopConstraint.Constant = point.Y;	
//				System.Diagnostics.Debug.WriteLine ("NEW POINT: " + point.Y);
//			}
//			else if (point.Y > 0) {
//				viewTopConstraint.Constant = point.Y;	
//				System.Diagnostics.Debug.WriteLine ("NEW POINT: " + point.Y);
//			}



//			headerFrame.Y = scrollOffset;
//			tableViewFrame.Y = scrollOffset;
//			heaerFrame.
//			tableViewFrame.Height -= scrollOffset:
				
			//			var headerFrameTopConstraint = view.Superview.Constraints.FirstOrDefault (c => c.SecondItem != null && c.SecondItem.Equals (view) && c.FirstAttribute == NSLayoutAttribute.Top);



//			if(stickToTop == true) {
//				if(-headerFrameTopConstraint.Constant < scrollOffset) {
//					headerFrame.Y = -scrollOffset;	
//				}
//			} else {
//			view.SetNeedsLayout();
//			viewTopConstraint.Constant = -scrollOffset/2;
//			tableViewTopConstraint.Constant = -scrollOffset / 2;

//			}
//			view.LayoutIfNeeded();
				
//			view.Frame = headerFrame;
		}
		public NotificationBar (NSCoder coder)
			: base (coder)
		{
			heightConstraint = NSLayoutConstraint.Create (this, Height, Equal, null, NoAttribute, 1, 0);
			TranslatesAutoresizingMaskIntoConstraints = false;
			BackgroundColor = UIColor.Black;

			AddConstraint (heightConstraint);
			label = new UILabel {
				Text = "You have a new CloudKit notification!",
				TextColor = UIColor.White,
				TextAlignment = UITextAlignment.Center,
				TranslatesAutoresizingMaskIntoConstraints = false,
				Hidden = true,
				UserInteractionEnabled = true
			};
			AddSubview (label);

			button = new UIButton ();
			button.SetTitle ("âś•", UIControlState.Normal);
			button.AddTarget (Close, UIControlEvent.TouchDown);
			button.TranslatesAutoresizingMaskIntoConstraints = false;
			button.Hidden = true;

			AddSubview (button);

			var rightConstraint = NSLayoutConstraint.Create (this, RightMargin, Equal, button, Right, 1, 0);
			AddConstraint (rightConstraint);

			var centerConstraint = NSLayoutConstraint.Create (this, CenterY, Equal, button, CenterY, 1, 0);
			AddConstraint (centerConstraint);

			var leftConstraint = NSLayoutConstraint.Create (this, LeftMargin, Equal, label, Left, 1, 0);
			AddConstraint (leftConstraint);

			var rightLabelConstraint = NSLayoutConstraint.Create (button, Left, Equal, label, Right, 1, 8);
			AddConstraint (rightLabelConstraint);

			var centerLabelConstraint = NSLayoutConstraint.Create (this, CenterY, Equal, label, CenterY, 1, 0);
			AddConstraint (centerLabelConstraint);

			var tapGestureRecognizer = new UITapGestureRecognizer (ShowNotification);
			label.AddGestureRecognizer (tapGestureRecognizer);
		}
		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));
		}
		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
			};
			ContentView.AddSubviews (strokeEmulator, avatar);

			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 ();

			BackgroundView = new UIView ();
			UIImageView cycleView = new UIImageView ();
			cycleView.Image = UIImage.FromBundle ("avatarSelectionMask");
			SelectedBackgroundView = cycleView;
		}
Esempio n. 7
0
        public static UIView StretchHeight(this UIView view, UIView parentView, float top = 0, float bottom = 0)
        {
            parentView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-({top})-[view]-({bottom})-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary("view", view)));

            return(view);
        }
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = ApplicationTheme.BackgroundColor
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _newMapButton       = new UIBarButtonItem();
            _newMapButton.Title = "New map";

            _basemapButton       = new UIBarButtonItem();
            _basemapButton.Title = "Basemap";

            _layersButton       = new UIBarButtonItem();
            _layersButton.Title = "Layers";

            _saveButton       = new UIBarButtonItem();
            _saveButton.Title = "Save";

            UIToolbar toolbar = new UIToolbar();

            toolbar.TranslatesAutoresizingMaskIntoConstraints = false;
            toolbar.Items = new[]
            {
                _newMapButton,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                _basemapButton,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                _layersButton,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                _saveButton
            };

            _activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor  = UIColor.FromWhiteAlpha(0f, .8f),
                HidesWhenStopped = true
            };

            // Add the views.
            View.AddSubviews(_myMapView, toolbar, _activityIndicator);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor),

                toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),
                toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),

                _activityIndicator.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _activityIndicator.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _activityIndicator.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _activityIndicator.BottomAnchor.ConstraintEqualTo(View.BottomAnchor)
            });
        }
Esempio n. 9
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView()
            {
                BackgroundColor = ApplicationTheme.BackgroundColor
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            UIToolbar toolbar = new UIToolbar {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _connectivityImage = new UIImageView(new CoreGraphics.CGRect(0, 0, 25, 25));
            _attachmentImage   = new UIImageView(new CoreGraphics.CGRect(0, 0, 25, 25));

            UILabel connectivityLabel = new UILabel()
            {
                Text = "Connectivity"
            };
            UILabel attachmentLabel = new UILabel()
            {
                Text = "Attachment"
            };

            toolbar.Items = new[]
            {
                new UIBarButtonItem {
                    CustomView = _attachmentImage
                },
                new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace)
                {
                    Width = 8
                },
                new UIBarButtonItem {
                    CustomView = attachmentLabel
                },
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem {
                    CustomView = _connectivityImage
                },
                new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace)
                {
                    Width = 8
                },
                new UIBarButtonItem {
                    CustomView = connectivityLabel
                },
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
            };

            // Add the views.
            View.AddSubviews(_myMapView, toolbar);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[] {
                _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

                toolbar.TopAnchor.ConstraintEqualTo(_myMapView.BottomAnchor),
                toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),
                toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor)
            });
        }
Esempio n. 10
0
        public static UIView PinToRight(this UIView view, UIView parentView, int right = 0)
        {
            parentView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:[view]-({right})-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary("view", view)));

            return(view);
        }
Esempio n. 11
0
        /// <summary>
        /// Show the snackbar
        /// </summary>
        public void Show()
        {
            if (this.Superview != null)
            {
                return;
            }

            dismissTimer = NSTimer.CreateScheduledTimer(this.Duration, x => Dismiss());

            IconImageView.Hidden      = Icon == null;
            ActionButton.Hidden       = this.ActionBlock == null;
            SecondActionButton.Hidden = this.SecondActionBlock == null;
            seperateView.Hidden       = ActionButton.Hidden;

            iconImageViewWidthConstraint.Constant      = IconImageView.Hidden ? 0 : TTGSnackbar.snackbarIconImageViewWidth;
            actionButtonWidthConstraint.Constant       = ActionButton.Hidden ? 0 : (SecondActionButton.Hidden ? TTGSnackbar.snackbarActionButtonMaxWidth : TTGSnackbar.snackbarActionButtonMinWidth);
            secondActionButtonWidthConstraint.Constant = SecondActionButton.Hidden ? 0 : (ActionButton.Hidden ? TTGSnackbar.snackbarActionButtonMaxWidth : TTGSnackbar.snackbarActionButtonMinWidth);


            this.LayoutIfNeeded();

            var localSuperView = UIApplication.SharedApplication.KeyWindow;

            if (localSuperView != null)
            {
                localSuperView.AddSubview(this);

                heightConstraint = NSLayoutConstraint.Create(
                    this,
                    NSLayoutAttribute.Height,
                    NSLayoutRelation.GreaterThanOrEqual,
                    null,
                    NSLayoutAttribute.NoAttribute,
                    1,
                    Height);

                leftMarginConstraint = NSLayoutConstraint.Create(
                    this,
                    NSLayoutAttribute.Left,
                    NSLayoutRelation.Equal,
                    localSuperView,
                    NSLayoutAttribute.Left,
                    1,
                    LeftMargin);

                rightMarginConstraint = NSLayoutConstraint.Create(
                    this,
                    NSLayoutAttribute.Right,
                    NSLayoutRelation.Equal,
                    localSuperView,
                    NSLayoutAttribute.Right,
                    1,
                    -RightMargin);

                topMarginConstraint = NSLayoutConstraint.Create(
                    this,
                    NSLayoutAttribute.Top,
                    NSLayoutRelation.Equal,
                    localSuperView,
                    NSLayoutAttribute.Top,
                    1,
                    TopMargin);

                bottomMarginConstraint = NSLayoutConstraint.Create(
                    this,
                    NSLayoutAttribute.Bottom,
                    NSLayoutRelation.Equal,
                    localSuperView,
                    NSLayoutAttribute.Bottom,
                    1,
                    -BottomMargin);

                // Avoid the "UIView-Encapsulated-Layout-Height" constraint conflicts
                // http://stackoverflow.com/questions/25059443/what-is-nslayoutconstraint-uiview-encapsulated-layout-height-and-how-should-i
                leftMarginConstraint.Priority  = 999;
                rightMarginConstraint.Priority = 999;

                this.AddConstraint(heightConstraint);
                localSuperView.AddConstraint(leftMarginConstraint);
                localSuperView.AddConstraint(rightMarginConstraint);

                var positionConstraint = this.ShowOnTop
                    ? this.topMarginConstraint
                    : this.bottomMarginConstraint;

                localSuperView.AddConstraint(positionConstraint);

                // Show
                showWithAnimation();
            }
            else
            {
                Console.WriteLine("TTGSnackbar needs a keyWindows to display.");
            }
        }
        void ShowStateAndCityPicker()
        {
            if (statepickerWidthConstraint != null)
                this.View.RemoveConstraint(statepickerWidthConstraint);
            if (citypickerWidthConstraint != null)
                this.View.RemoveConstraint(citypickerWidthConstraint);
            //StatePicker Width Constraint
            statepickerWidthConstraint = NSLayoutConstraint.Create(StatePickerView, NSLayoutAttribute.Width,
                NSLayoutRelation.Equal, this.View, NSLayoutAttribute.Width, 0.5f, 0);
            //CityPicker Width Constraint
            citypickerWidthConstraint = NSLayoutConstraint.Create(CityPickerView, NSLayoutAttribute.Width,
                NSLayoutRelation.Equal, this.View, NSLayoutAttribute.Width, 0.5f, 0);

            this.View.AddConstraint(statepickerWidthConstraint);
            this.View.AddConstraint(citypickerWidthConstraint);
            this.View.LayoutIfNeeded();
        }
Esempio n. 13
0
		public override void ViewDidLayoutSubviews ()
		{
			base.ViewDidLayoutSubviews ();

			var ratio = NavBarBlendView.Bounds.Height / blendViewNormalHeight;
			if (ratio < 1) {
				if (bubbleWidhtConstraint != null || bubbleHeightConstraint != null)
					return;

				bubbleWidhtConstraint = SetConstant (BubbleImg, NSLayoutAttribute.Width, ratio * BubbleImg.IntrinsicContentSize.Width);
				bubbleHeightConstraint = SetConstant (BubbleImg, NSLayoutAttribute.Height, ratio * BubbleImg.IntrinsicContentSize.Height);

				bubbleTopNormalOffset = BubbleImgTopOffset.Constant;
				BubbleImgTopOffset.Constant -= (blendViewNormalHeight - BubbleImg.IntrinsicContentSize.Height) * (1 - ratio) / 2;
				BubbleImgTopOffset.Constant = NMath.Max (BubbleImgTopOffset.Constant, 0);

			} else {
				if (bubbleWidhtConstraint == null || bubbleHeightConstraint == null)
					return;

				BubbleImg.RemoveConstraint (bubbleWidhtConstraint);
				BubbleImg.RemoveConstraint (bubbleHeightConstraint);
				bubbleWidhtConstraint = bubbleHeightConstraint = null;

				BubbleImgTopOffset.Constant = bubbleTopNormalOffset;
			}

			View.LayoutIfNeeded ();
		}
Esempio n. 14
0
        void SetArrows()
        {
            CleanUpArrows();

            if (Element.ShowArrows)
            {
                var o             = Element.Orientation == CarouselViewOrientation.Horizontal ? "H" : "V";
                var formatOptions = Element.Orientation == CarouselViewOrientation.Horizontal ? NSLayoutFormatOptions.AlignAllCenterY : NSLayoutFormatOptions.AlignAllCenterX;

                prevBtn                 = new UIButton();
                prevBtn.Hidden          = Element.Position == 0 || Element.ItemsSource.GetCount() == 0;
                prevBtn.BackgroundColor = Element.ArrowsBackgroundColor.ToUIColor();
                prevBtn.Alpha           = Element.ArrowsTransparency;
                prevBtn.TranslatesAutoresizingMaskIntoConstraints = false;

                var prevArrow      = new UIImageView();
                var prevArrowImage = new UIImage(Element.Orientation == CarouselViewOrientation.Horizontal ? "Prev.png" : "Up.png");
                prevArrow.Image = prevArrowImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                prevArrow.TranslatesAutoresizingMaskIntoConstraints = false;
                prevArrow.TintColor = Element.ArrowsTintColor.ToUIColor();
                prevBtn.AddSubview(prevArrow);

                prevBtn.TouchUpInside += PrevBtn_TouchUpInside;

                var prevViewsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { prevBtn, prevArrow }, new NSObject[] { new NSString("superview"), new NSString("prevArrow") });
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("[prevArrow(==17)]", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[prevArrow(==17)]", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[prevArrow]-(2)-|", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[prevArrow]", formatOptions, new NSDictionary(), prevViewsDictionary));

                pageController.View.AddSubview(prevBtn);

                nextBtn                 = new UIButton();
                nextBtn.Hidden          = Element.Position == Element.ItemsSource.GetCount() - 1 || Element.ItemsSource.GetCount() == 0;
                nextBtn.BackgroundColor = Element.ArrowsBackgroundColor.ToUIColor();
                nextBtn.Alpha           = Element.ArrowsTransparency;
                nextBtn.TranslatesAutoresizingMaskIntoConstraints = false;

                var nextArrow      = new UIImageView();
                var nextArrowImage = new UIImage(Element.Orientation == CarouselViewOrientation.Horizontal ? "Next.png" : "Down.png");
                nextArrow.Image = nextArrowImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                nextArrow.TranslatesAutoresizingMaskIntoConstraints = false;
                nextArrow.TintColor = Element.ArrowsTintColor.ToUIColor();
                nextBtn.AddSubview(nextArrow);

                nextBtn.TouchUpInside += NextBtn_TouchUpInside;

                var nextViewsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { nextBtn, nextArrow }, new NSObject[] { new NSString("superview"), new NSString("nextArrow") });
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("[nextArrow(==17)]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[nextArrow(==17)]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":|-(2)-[nextArrow]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[nextArrow]", formatOptions, new NSDictionary(), nextViewsDictionary));

                pageController.View.AddSubview(nextBtn);

                var btnsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { pageController.View, prevBtn, nextBtn }, new NSObject[] { new NSString("superview"), new NSString("prevBtn"), new NSString("nextBtn") });

                var w = Element.Orientation == CarouselViewOrientation.Horizontal ? 20 : 36;
                var h = Element.Orientation == CarouselViewOrientation.Horizontal ? 36 : 20;

                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[prevBtn(==" + w + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[prevBtn(==" + h + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":|[prevBtn]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[prevBtn]", formatOptions, new NSDictionary(), btnsDictionary));

                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[nextBtn(==" + w + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[nextBtn(==" + h + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[nextBtn]|", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[nextBtn]", formatOptions, new NSDictionary(), btnsDictionary));
            }
        }
Esempio n. 15
0
        public override void MouseUp(NSEvent theEvent)
        {
            if (this.horizontalDragConstraint != null) {
                this.RemoveConstraint(this.horizontalDragConstraint);
                this.horizontalDragConstraint.Release();
                this.horizontalDragConstraint=null;
                this.RemoveConstraint(this.verticalDragConstraint);
                this.verticalDragConstraint.Release();
                this.verticalDragConstraint=null;

                this.SetOwnSizeConstraints(this.SizeConstraintsForCurrentPosition());

                // just for fun.  Try it out!
                this.Window.VisualizeConstraints (null);
            } else {
                this.SendMessageSuper (ResizableViewClass, "mouseUp:", theEvent);
            }
        }
Esempio n. 16
0
        public override void MouseDown(NSEvent theEvent)
        {
            NSPoint locationInSelf = this.ConvertPointFromView (theEvent.LocationInWindow, null);
            NSRect dragThumbFrame = this.dragThumbView.Frame;

            if (dragThumbFrame.PointInRect (locationInSelf)) {
                this.dragOffsetIntoGrowBox = new NSSize (locationInSelf.x - dragThumbFrame.origin.x, locationInSelf.y - dragThumbFrame.origin.y);
                NSDictionary metrics = NSDictionary.DictionaryWithObjectsAndKeys (
                NSNumber.NumberWithFloat (dragThumbFrame.MinX), (NSString)"initialThumbX",
                NSNumber.NumberWithFloat (dragThumbFrame.MinY), (NSString)"initialThumbY",
                null);
                NSDictionary views = NSDictionary.DictionaryWithObjectForKey (this.dragThumbView, (NSString)"dragThumbView");

                this.horizontalDragConstraint = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews ("H:|-(initialThumbX)-[dragThumbView]", 0, metrics, views).LastObject.Retain<NSLayoutConstraint> ();
                this.verticalDragConstraint = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews ("V:|-(initialThumbY)-[dragThumbView]", 0, metrics, views).LastObject.Retain<NSLayoutConstraint> ();

                // try lowering the priority to NSLayoutPriorityDragThatCannotResizeWindow to see the difference
                this.horizontalDragConstraint.Priority = NSLayoutPriority.NSLayoutPriorityDragThatCanResizeWindow;
                this.verticalDragConstraint.Priority = NSLayoutPriority.NSLayoutPriorityDragThatCanResizeWindow;

                this.AddConstraint (this.horizontalDragConstraint);
                this.AddConstraint (this.verticalDragConstraint);

                // just for fun.  Try it out!
                this.Window.VisualizeConstraints (NSArray.ArrayWithObjects (this.horizontalDragConstraint, this.verticalDragConstraint, null));
            }
        }
 void ShowStatePickerOnly()
 {
     UIView.Animate (
         0,
         () => {
         CityPickerView.Hidden = true;
         StatePickerView.Hidden = false;
         this.View.RemoveConstraint(statepickerWidthConstraint);
         this.View.RemoveConstraint(citypickerWidthConstraint);
         //Show Picker View Constraints
         statepickerWidthConstraint = NSLayoutConstraint.Create(StatePickerView, NSLayoutAttribute.Width,
             NSLayoutRelation.Equal, this.View, NSLayoutAttribute.Width, 1, 0);
         this.View.AddConstraint(statepickerWidthConstraint);
     },
         () => {
         this.View.LayoutIfNeeded();
     });
 }
		private void AddCardAndPreviewTab(List<NSLayoutConstraint> constraints)
		{
			_previewTab = AddPreviewTab ();
			_previewTab.TranslatesAutoresizingMaskIntoConstraints = false;

			PreviewLabel previewLabel = AddPreviewLabel ();
			previewLabel.TranslatesAutoresizingMaskIntoConstraints = false;

			CardView cardView = AddCardView ();
			cardView.TranslatesAutoresizingMaskIntoConstraints = false;

			// Pin the tab to the bottom center of the screen
			_cardRevealConstraint = NSLayoutConstraint.Create (_previewTab, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1f, 0f);
			constraints.Add (_cardRevealConstraint);
			constraints.Add(NSLayoutConstraint.Create(_previewTab, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1f, 0f));
			// Center the preview label within the tab
			constraints.Add(NSLayoutConstraint.Create (previewLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _previewTab, NSLayoutAttribute.Leading, 1f, PreviewTabHorizontalPadding));
			constraints.Add (NSLayoutConstraint.Create (previewLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, _previewTab, NSLayoutAttribute.Trailing, 1f, -PreviewTabHorizontalPadding));
			constraints.Add (NSLayoutConstraint.Create (previewLabel, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, _previewTab, NSLayoutAttribute.CenterY, 1f, 0f));

			// Pin the top of the card to the bottom of the tab
			constraints.Add (NSLayoutConstraint.Create (cardView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _previewTab, NSLayoutAttribute.Bottom, 1f, 0f));
			constraints.Add (NSLayoutConstraint.Create (cardView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, _previewTab, NSLayoutAttribute.CenterX, 1f, 0f));

			// Ensure that the card fits within the view
			constraints.Add (NSLayoutConstraint.Create (_cardView, NSLayoutAttribute.Width, NSLayoutRelation.LessThanOrEqual, View, NSLayoutAttribute.Width, 1f, 0f));
		}
		private void LayoutView(){
			this.TranslatesAutoresizingMaskIntoConstraints = false;

			if (this.Superview == null)
				return;

			foreach (var constraint in this.Constraints) {
				//TODO: Figure out voodoo
				Console.WriteLine (constraint);
			}

			foreach (var constraintString in new string[]{ "H:|[view]|", "V:[view]|" }) {
				this.Superview.AddConstraints (
					NSLayoutConstraint.FromVisualFormat(
						constraintString,
						NSLayoutFormatOptions.DirectionLeadingToTrailing,
						null,
						NSDictionary.FromObjectsAndKeys(new NSObject[] { this }, new NSObject[] { new NSString("view") })					
						)
					);	
			}

			heightConstraint = 
				NSLayoutConstraint.Create (
				this,
				NSLayoutAttribute.Height,
				NSLayoutRelation.Equal, 
				null,
				NSLayoutAttribute.NoAttribute,
				1.0f,
				0.0f);

			this.AddConstraint (heightConstraint);
		}
Esempio n. 20
0
        public virtual void UpdateCell(View cell, UITableView tableView)
        {
            if (_formsCell == cell && !CustomCell.IsForceLayout)
            {
                return;
            }
            CustomCell.IsForceLayout = false;

            if (_formsCell != null)
            {
                _formsCell.PropertyChanged -= CellPropertyChanged;
            }
            _formsCell = cell;
            _formsCell.PropertyChanged += CellPropertyChanged;

            IVisualElementRenderer renderer;

            if (_rendererRef == null || !_rendererRef.TryGetTarget(out renderer))
            {
                renderer = GetNewRenderer();
            }
            else
            {
                if (renderer.Element != null && renderer == Platform.GetRenderer(renderer.Element))
                {
                    renderer.Element.ClearValue(FormsInternals.RendererProperty);
                }

                var type            = Xamarin.Forms.Internals.Registrar.Registered.GetHandlerTypeForObject(this._formsCell);
                var reflectableType = renderer as System.Reflection.IReflectableType;
                var rendererType    = reflectableType != null?reflectableType.GetTypeInfo().AsType() : renderer.GetType();

                if (rendererType == type || (renderer.GetType() == FormsInternals.DefaultRenderer) && type == null)
                {
                    renderer.SetElement(this._formsCell);
                }
                else
                {
                    //when cells are getting reused the element could be already set to another cell
                    //so we should dispose based on the renderer and not the renderer.Element
                    FormsInternals.DisposeRendererAndChildren(renderer);
                    renderer = GetNewRenderer();
                }
            }

            Platform.SetRenderer(this._formsCell, renderer);

            if (!CustomCell.IsMeasureOnce || tableView.Frame.Width != _lastFrameWidth)
            {
                _lastFrameWidth = tableView.Frame.Width;
                var height = double.PositiveInfinity;
                var width  = tableView.Frame.Width - (CustomCell.UseFullSize ? 0 : 32); // CellBaseView layout margin
                var result = renderer.Element.Measure(tableView.Frame.Width, height, MeasureFlags.IncludeMargins);
                _lastMeasureWidth = result.Request.Width;
                if (_formsCell.HorizontalOptions.Alignment == LayoutAlignment.Fill)
                {
                    _lastMeasureWidth = width;
                }
                _lastMeasureHeight = result.Request.Height;

                if (_heightConstraint != null)
                {
                    _heightConstraint.Active = false;
                    _heightConstraint?.Dispose();
                }

                _heightConstraint          = renderer.NativeView.HeightAnchor.ConstraintEqualTo((nfloat)_lastMeasureHeight);
                _heightConstraint.Priority = 999f;
                _heightConstraint.Active   = true;

                renderer.NativeView.UpdateConstraintsIfNeeded();
            }

            Layout.LayoutChildIntoBoundingRegion(_formsCell, new Rectangle(0, 0, _lastMeasureWidth, _lastMeasureHeight));

            UpdateNativeCell();
        }
Esempio n. 21
0
        private void AddFilters()
        {
            filter = new UIView() { BackgroundColor = UIColor.FromRGBA (1,0,0,0.5f) };
            filter.TranslatesAutoresizingMaskIntoConstraints = false;
            Add(filter);
            View.AddConstraint(NSLayoutConstraint.Create(filter, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(filter, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View, NSLayoutAttribute.Top, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(filter, NSLayoutAttribute.Width, NSLayoutRelation.Equal, View, NSLayoutAttribute.Width, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(filter, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.Height, 1, 42));

            //			filter.SetNeedsLayout();
            //			filter.LayoutIfNeeded();

            filters = new UIView() { BackgroundColor = UIColor.FromRGBA(0,0,1,0.5f) };
            filters.TranslatesAutoresizingMaskIntoConstraints = false;
            Add(filters);
            filtersTop = NSLayoutConstraint.Create(filters, NSLayoutAttribute.Top, NSLayoutRelation.Equal, filter, NSLayoutAttribute.Bottom, 1, 0);
            View.AddConstraint(filtersTop);
            View.AddConstraint(NSLayoutConstraint.Create(filters, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(filters, NSLayoutAttribute.Width, NSLayoutRelation.Equal, View, NSLayoutAttribute.Width, 1, 0));
            View.AddConstraint(NSLayoutConstraint.Create(filters, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.Height, 1, 42));

            //			filters.SetNeedsLayout();
            //			filters.LayoutIfNeeded();
            //			var FrameWidth = filters.Frame.Width * 0.47;

            //			var channelFilter = new FilterDropdown(new CGRect(0, 0, FrameWidth, 23), "My:All Movies");
            //			channelFilter.TranslatesAutoresizingMaskIntoConstraints = false;
            //			filters.Add(channelFilter);
            //			channelFilter.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            //				{
            //					VM.ShowMovieFilters.Execute(null);
            //				}));
            //			filters.AddConstraint(NSLayoutConstraint.Create(channelFilter, NSLayoutAttribute.Left, NSLayoutRelation.Equal, filters, NSLayoutAttribute.Left, 1, 5));
            //			filters.AddConstraint(NSLayoutConstraint.Create(channelFilter, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, filters, NSLayoutAttribute.CenterY, 1, 0));
            //			filters.AddConstraint(NSLayoutConstraint.Create(channelFilter, NSLayoutAttribute.Width, NSLayoutRelation.Equal, filters, NSLayoutAttribute.Width, 0.47f, 0));
            //			filters.AddConstraint(NSLayoutConstraint.Create(channelFilter, NSLayoutAttribute.Height, NSLayoutRelation.Equal, filters, NSLayoutAttribute.Height, 0.75f, 0));
            //
            //			var dateFilter = new FilterDropdown(new CGRect(20, 16, FrameWidth, 23), "Release Date");
            //			dateFilter.TranslatesAutoresizingMaskIntoConstraints = false;
            //			filters.Add(dateFilter);
            //			dateFilter.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            //				{
            //					VM.ShowReleaseDateFilters.Execute(null);
            //				}));
            //			filters.AddConstraint(NSLayoutConstraint.Create(dateFilter, NSLayoutAttribute.Right, NSLayoutRelation.Equal, filters, NSLayoutAttribute.Right, 1, -5));
            //			filters.AddConstraint(NSLayoutConstraint.Create(dateFilter, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, filters, NSLayoutAttribute.CenterY, 1, 0));
            //			filters.AddConstraint(NSLayoutConstraint.Create(dateFilter, NSLayoutAttribute.Width, NSLayoutRelation.Equal, filters, NSLayoutAttribute.Width, 0.47f, 0));
            //			filters.AddConstraint(NSLayoutConstraint.Create(dateFilter, NSLayoutAttribute.Height, NSLayoutRelation.Equal, filters, NSLayoutAttribute.Height, 0.75f, 0));

            View.BringSubviewToFront(filter);
        }
        public static NSLayoutConstraint[] AttachToParentVertically(UIView parent, UIView child, nfloat margin)
        {
            NSLayoutConstraint[] result = new NSLayoutConstraint[2];

            result[0] = AttachToParentBottom(parent, child, margin);
            result[1] = AttachToParentTop(parent, child, margin);

            return result;
        }
        void CreateCompactConstraints()
        {
			if (compactConstraints?.Length > 0)
				return;
			
            mercuryCenter = CreateCenterXConstraint (mercury, "mercuryCenterX");
			venusCenter = CreateCenterXConstraint (venus, "venusCenterX");
			earthCenter = CreateCenterXConstraint (earth, "earthCenterX");
			marsCenter = CreateCenterXConstraint (mars, "marsCenterX");
			jupiterCenter = CreateCenterXConstraint (jupiter, "jupiterCenterX");
			saturnCenter = CreateCenterXConstraint (saturn, "saturnCenterX");
			uranusCenter = CreateCenterXConstraint (uranus, "uranusCenterX");
			neptuneCenter = CreateCenterXConstraint (neptune, "neptuneCenterX");

			compactConstraints = new [] {
				mercuryCenter, venusCenter, earthCenter, marsCenter, jupiterCenter, saturnCenter, uranusCenter, neptuneCenter
			};
        }
Esempio n. 24
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView()
            {
                BackgroundColor = ApplicationTheme.BackgroundColor
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _statusLabel = new UILabel
            {
                Text = "Instructions",
                AdjustsFontSizeToFitWidth = true,
                TextAlignment             = UITextAlignment.Center,
                BackgroundColor           = UIColor.FromWhiteAlpha(0, .6f),
                TextColor = UIColor.White,
                Lines     = 1,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _tracePickerButton = new UIButton(UIButtonType.System);
            _tracePickerButton.SetTitle("Trace type: Connected", UIControlState.Normal);
            _tracePickerButton.TranslatesAutoresizingMaskIntoConstraints = false;

            _startBarrierPicker = new UISegmentedControl(new string[] { "Start", "Barrier" });
            _startBarrierPicker.SelectedSegment = 0;

            _traceButton       = new UIBarButtonItem();
            _traceButton.Title = "Trace";

            _resetButton       = new UIBarButtonItem();
            _resetButton.Title = "Reset";

            _toolbar = new UIToolbar();
            _toolbar.TranslatesAutoresizingMaskIntoConstraints = false;
            _toolbar.Items = new[]
            {
                new UIBarButtonItem(_startBarrierPicker),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                _traceButton,
                _resetButton
            };

            _activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HidesWhenStopped = true,
                BackgroundColor  = UIColor.FromWhiteAlpha(0, .5f)
            };

            // Add the views.
            View.AddSubviews(_myMapView, _statusLabel, _tracePickerButton, _toolbar, _activityIndicator);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(_tracePickerButton.TopAnchor),

                _tracePickerButton.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _tracePickerButton.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _tracePickerButton.BottomAnchor.ConstraintEqualTo(_toolbar.TopAnchor),
                _tracePickerButton.HeightAnchor.ConstraintEqualTo(40),

                _toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),

                _statusLabel.TopAnchor.ConstraintEqualTo(_myMapView.TopAnchor),
                _statusLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _statusLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _statusLabel.HeightAnchor.ConstraintEqualTo(40),

                _activityIndicator.TopAnchor.ConstraintEqualTo(_statusLabel.BottomAnchor),
                _activityIndicator.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _activityIndicator.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _activityIndicator.BottomAnchor.ConstraintEqualTo(View.BottomAnchor)
            }
                                                   );
        }
        void CreateRegularConstraints ()
        {
			if (regularConstraints?.Length > 0 && sharedConstraints?.Count > 0)
            	return;
			
            UILayoutGuide leadingMercuryGuide = NewLayoutGuide ("leadingMercuryGuide");
			UILayoutGuide leadingVenusGuide = NewLayoutGuide ("leadingVenusGuide");
			UILayoutGuide leadingEarthGuide = NewLayoutGuide ("leadingEarthGuide");
			UILayoutGuide leadingMarsGuide = NewLayoutGuide ("leadingMarsGuide");
			UILayoutGuide leadingJupiterGuide = NewLayoutGuide ("leadingJupiterGuide");
			UILayoutGuide leadingSaturnGuide = NewLayoutGuide ("leadingSaturnGuide");
			UILayoutGuide leadingUranusGuide = NewLayoutGuide ("leadingUranusGuide");
			UILayoutGuide leadingNeptuneGuide = NewLayoutGuide ("leadingNeptuneGuide");

			UILayoutGuide trailingMercuryGuide = NewLayoutGuide ("trailingMercuryGuide");
			UILayoutGuide trailingVenusGuide = NewLayoutGuide ("trailingVenusGuide");
			UILayoutGuide trailingEarthGuide = NewLayoutGuide ("trailingEarthGuide");
			UILayoutGuide trailingMarsGuide = NewLayoutGuide ("trailingMarsGuide");
			UILayoutGuide trailingJupiterGuide = NewLayoutGuide ("trailingJupiterGuide");
			UILayoutGuide trailingSaturnGuide = NewLayoutGuide ("trailingSaturnGuide");
			UILayoutGuide trailingUranusGuide = NewLayoutGuide ("trailingUranusGuide");
			UILayoutGuide trailingNeptuneGuide = NewLayoutGuide ("trailingNeptuneGuide");
            
			IUILayoutSupport topLayoutGuide = TopLayoutGuide;

			var planetsAndGuides = NSDictionary.FromObjectsAndKeys (new object[] {
				mercury, venus, earth, mars, jupiter, saturn, uranus, neptune,
				leadingMercuryGuide, leadingVenusGuide, leadingEarthGuide, leadingMarsGuide,
				leadingJupiterGuide, leadingSaturnGuide, leadingUranusGuide, leadingNeptuneGuide,
				trailingMercuryGuide, trailingVenusGuide, trailingEarthGuide, trailingMarsGuide,
				trailingJupiterGuide, trailingSaturnGuide, trailingUranusGuide, trailingNeptuneGuide, topLayoutGuide
			}, new object[] {
				"mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune",
				"leadingMercuryGuide", "leadingVenusGuide", "leadingEarthGuide", "leadingMarsGuide",
				"leadingJupiterGuide", "leadingSaturnGuide", "leadingUranusGuide", "leadingNeptuneGuide",
				"trailingMercuryGuide", "trailingVenusGuide", "trailingEarthGuide", "trailingMarsGuide",
				"trailingJupiterGuide", "trailingSaturnGuide", "trailingUranusGuide", "trailingNeptuneGuide", "topLayoutGuide"
			});

			var topToBottom = NSLayoutConstraint.FromVisualFormat ("V:|[topLayoutGuide]-[leadingMercuryGuide]-" +
				"[leadingVenusGuide]-[leadingEarthGuide]-[leadingMarsGuide]-" +
				"[leadingJupiterGuide][leadingSaturnGuide][leadingUranusGuide]-" +
				"[leadingNeptuneGuide]-20-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, planetsAndGuides);
                
			sharedConstraints = new List<NSLayoutConstraint> (topToBottom);
			SetLayoutIdentifierForArray ((NSString)"topToBottom", NSArray.FromObjects (topToBottom));

			NewHorizontalArray ("|[leadingMercuryGuide][mercury][trailingMercuryGuide]|", "hMercury", planetsAndGuides);
			NewHorizontalArray ("|[leadingVenusGuide][venus][trailingVenusGuide]|", "hVenus", planetsAndGuides);
			NewHorizontalArray ("|[leadingEarthGuide][earth][trailingEarthGuide]|", "hEarth", planetsAndGuides);
			NewHorizontalArray ("|[leadingMarsGuide][mars][trailingMarsGuide]|", "hMars", planetsAndGuides);
			NewHorizontalArray ("|[leadingJupiterGuide][jupiter][trailingJupiterGuide]|", "hJupiter", planetsAndGuides);
			NewHorizontalArray ("|[leadingSaturnGuide][saturn][trailingSaturnGuide]|", "hSaturn", planetsAndGuides);
			NewHorizontalArray ("|[leadingUranusGuide][uranus][trailingUranusGuide]|", "hUranus", planetsAndGuides);
			NewHorizontalArray ("|[leadingNeptuneGuide][neptune][trailingNeptuneGuide]|", "hNeptune", planetsAndGuides);
            
			sharedConstraints.Add (GuideHeightToPlanet (leadingMercuryGuide, mercury, "guideHeightToMercury"));
			sharedConstraints.Add (GuideHeightToPlanet (leadingVenusGuide, venus, "guideHeightToVenus"));
			sharedConstraints.Add (GuideHeightToPlanet (leadingEarthGuide, earth, "guideHeightToEarth"));
			sharedConstraints.Add (GuideHeightToPlanet (leadingMarsGuide, mars, "guideHeightToMars"));
			sharedConstraints.Add (GuideHeightToPlanet (leadingJupiterGuide, jupiter, "guideHeightToJupiter"));
			sharedConstraints.Add (GuideHeightToPlanet (leadingSaturnGuide, saturn, "guideHeightToSaturn"));
			sharedConstraints.Add (GuideHeightToPlanet (leadingUranusGuide, uranus, "guideHeightToUranus"));
			sharedConstraints.Add (GuideHeightToPlanet (leadingNeptuneGuide, neptune, "guideHeightToNeptune"));

			mercuryLeadingToTrailing = leadingMercuryGuide.WidthAnchor.ConstraintEqualTo (trailingMercuryGuide.WidthAnchor, .02f);
			venusLeadingToTrailing = leadingVenusGuide.WidthAnchor.ConstraintEqualTo (trailingVenusGuide.WidthAnchor, .03f);
			earthLeadingToTrailing = leadingEarthGuide.WidthAnchor.ConstraintEqualTo (trailingEarthGuide.WidthAnchor, .06f);
			marsLeadingToTrailing = leadingMarsGuide.WidthAnchor.ConstraintEqualTo (trailingMarsGuide.WidthAnchor, .1f);
			jupiterLeadingToTrailing = leadingJupiterGuide.WidthAnchor.ConstraintEqualTo (trailingJupiterGuide.WidthAnchor, .2f);
			saturnLeadingToTrailing = leadingSaturnGuide.WidthAnchor.ConstraintEqualTo (trailingSaturnGuide.WidthAnchor, 1f);
			uranusLeadingToTrailing = leadingUranusGuide.WidthAnchor.ConstraintEqualTo (trailingUranusGuide.WidthAnchor, 2.7f);
			neptuneLeadingToTrailing = leadingNeptuneGuide.WidthAnchor.ConstraintEqualTo (trailingNeptuneGuide.WidthAnchor, 10f);
            
			mercuryLeadingToTrailing.SetIdentifier ("leadingTrailingAnchorMercury");
			venusLeadingToTrailing.SetIdentifier ("leadingTrailingAnchorVenus");
			earthLeadingToTrailing.SetIdentifier ("leadingTrailingAnchorEarth");
			marsLeadingToTrailing.SetIdentifier ("leadingTrailingAnchorMars");
			jupiterLeadingToTrailing.SetIdentifier ("leadingTrailingAnchorJupiter");
			saturnLeadingToTrailing.SetIdentifier ("leadingTrailingAnchorSaturn");
			uranusLeadingToTrailing.SetIdentifier ("leadingTrailingAnchorUranus");
			neptuneLeadingToTrailing.SetIdentifier ("leadingTrailingAnchorNeptune");
            
			regularConstraints = new [] {
				mercuryLeadingToTrailing, venusLeadingToTrailing, earthLeadingToTrailing, marsLeadingToTrailing,
				saturnLeadingToTrailing, jupiterLeadingToTrailing,  uranusLeadingToTrailing, neptuneLeadingToTrailing
			};
		}
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = ApplicationTheme.BackgroundColor
            };

            _myMapView = new MapView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _navigateButton = new UIBarButtonItem()
            {
                Title = "Navigate", Enabled = false
            };
            _recenterButton = new UIBarButtonItem()
            {
                Title = "Recenter", Enabled = false
            };

            _toolbar = new UIToolbar()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _toolbar.Items = new[]
            {
                _navigateButton,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                _recenterButton
            };

            _statusLabel = new UILabel
            {
                Text = "",
                AdjustsFontSizeToFitWidth = true,
                TextAlignment             = UITextAlignment.Left,
                BackgroundColor           = ApplicationTheme.BackgroundColor,
                TextColor     = ApplicationTheme.ForegroundColor,
                LineBreakMode = UILineBreakMode.WordWrap,
                Lines         = 0,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            // Add the views.
            View.AddSubviews(_myMapView, _toolbar, _statusLabel);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(_toolbar.TopAnchor),

                _toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),
                _toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

                _statusLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _statusLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _statusLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
            });
        }
		void SetUpToolbar ()
		{
			toolbar = new UIToolbar {
				TranslatesAutoresizingMaskIntoConstraints = false
			};
			chatInputView = new ChatInputView {
				TranslatesAutoresizingMaskIntoConstraints = false
			};

			View.AddSubview (toolbar);

			var pinLeft = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1, 0);
			View.AddConstraint (pinLeft);

			var pinRight = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1, 0);
			View.AddConstraint (pinRight);

			toolbarBottomConstraint = NSLayoutConstraint.Create (View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, toolbar, NSLayoutAttribute.Bottom, 1, 0);
			View.AddConstraint (toolbarBottomConstraint);

			toolbarHeightConstraint = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 0, 44);
			View.AddConstraint (toolbarHeightConstraint);

			toolbar.AddSubview (chatInputView);

			var c1 = NSLayoutConstraint.FromVisualFormat ("H:|[chat_container_view]|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"chat_container_view", chatInputView
			);
			var c2 = NSLayoutConstraint.FromVisualFormat ("V:|[chat_container_view]|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"chat_container_view", chatInputView
			);
			toolbar.AddConstraints (c1);
			toolbar.AddConstraints (c2);
		}
Esempio n. 28
0
 private void Initialize()
 {
     AddConstraint(NSLayoutConstraint.Create(this, NSLayoutAttribute.Height, NSLayoutRelation.GreaterThanOrEqual, 1, MinHeight));
 }
		public override void UpdateViewConstraints ()
		{
			float toolbarVerticalOffset = WantsFullScreenLayout ? GetStatusBarHeight (UIApplication.SharedApplication) : 0;

			if (toolbarTopConstraint == null) {
				var tconstraint2 = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Top, NSLayoutRelation.Equal,
                                                             View, NSLayoutAttribute.Top, 1.0f, toolbarVerticalOffset);
				toolbarTopConstraint = tconstraint2;

				var tconstraint1 = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Width, NSLayoutRelation.Equal,
                                                             View, NSLayoutAttribute.Width, 1.0f, 0.0f);

				var tconstraint3 = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Left, NSLayoutRelation.Equal,
                                                             View, NSLayoutAttribute.Left, 1.0f, 0.0f);

				var tconstraint4 = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Height, NSLayoutRelation.Equal,
                                                             toolbar, NSLayoutAttribute.Height, 0.0f, 44.0f);

				var constraint0 = NSLayoutConstraint.Create (photoImageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal,
                                                            photoImageView, NSLayoutAttribute.Height, 1.0f, 0.0f);

				var constraint1 = NSLayoutConstraint.Create (photoImageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal,
                                                            View, NSLayoutAttribute.CenterX, 1.0f, 0.0f);

				NSLayoutConstraint constraint2;

				if (WantsFullScreenLayout) {
					constraint2 = NSLayoutConstraint.Create (photoImageView, NSLayoutAttribute.Top, NSLayoutRelation.GreaterThanOrEqual, View,
							                                         NSLayoutAttribute.Top, 1.0f, 0.0f);
				} else {
					constraint2 = NSLayoutConstraint.Create (photoImageView, NSLayoutAttribute.Top, NSLayoutRelation.GreaterThanOrEqual, toolbar,
							                                         NSLayoutAttribute.Bottom, 1.0f, 0.0f);
				}
				NSLayoutConstraint constraint3 = NSLayoutConstraint.Create (photoImageView, NSLayoutAttribute.Bottom, NSLayoutRelation.LessThanOrEqual,
						                                                            View, NSLayoutAttribute.Bottom, 1.0f, 0.0f);

				View.AddConstraints (new NSLayoutConstraint[] {tconstraint1, tconstraint2, tconstraint3, tconstraint4, constraint0, constraint1, constraint2, constraint3});

				toolbarTopConstraint.Constant = toolbarVerticalOffset;

			}
			base.UpdateViewConstraints ();
		}
        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)
                });
            }
        }
Esempio n. 31
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            if (PageInfo == null)
            {
                return;
            }

            _imageView.Image =
                PageInfo?.ImagePath != null
                                        ? UIImage.FromBundle(PageInfo.ImagePath)
                                        : null;

            _pageText.Text      = PageInfo?.PageText ?? string.Empty;
            _pageText.TextColor = PageInfo?.PageTextColor ?? UIColor.Black;

            NSLayoutConstraint _pageTextLocation = null;

            switch (PageInfo.PageTextLocation)
            {
            case PageTextLocation.Bottom:
                _constraints.Add(
                    _pageTextLocation =
                        NSLayoutConstraint.Create(
                            _pageText, NSLayoutAttribute.Bottom,
                            NSLayoutRelation.Equal,
                            View, NSLayoutAttribute.Bottom,
                            1.0f, -Padding
                            )
                    );
                break;

            case PageTextLocation.Middle:
                _constraints.Add(
                    _pageTextLocation =
                        NSLayoutConstraint.Create(
                            _pageText, NSLayoutAttribute.CenterY,
                            NSLayoutRelation.Equal,
                            View, NSLayoutAttribute.CenterY,
                            1.0f, 0f
                            )
                    );
                break;

            case PageTextLocation.Top:
                _constraints.Add(
                    _pageTextLocation =
                        NSLayoutConstraint.Create(
                            _pageText, NSLayoutAttribute.Top,
                            NSLayoutRelation.Equal,
                            View, NSLayoutAttribute.Top,
                            1.0f, Padding
                            )
                    );
                break;
            }

            if (_pageTextLocation != null)
            {
                View.AddConstraint(_pageTextLocation);
            }
        }
Esempio n. 32
0
        public static UIView StretchWidth(this UIView view, UIView parentView, float left = 0, float right = 0)
        {
            parentView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:|-({left})-[view]-({right})-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary("view", view)));

            return(view);
        }
        private void CreateView()
        {
            GetPostSize();
            SetImage();

            var photoTitleSeparator = new UIView();

            photoTitleSeparator.BackgroundColor = Constants.R245G245B245;

            titleTextField = new UITextView();
            titleTextField.ScrollEnabled = false;
            titleTextField.Font          = Constants.Semibold14;
            titleEditImage       = new UIImageView();
            titleEditImage.Image = UIImage.FromBundle("ic_edit");

            var titleDescriptionSeparator = new UIView();

            titleDescriptionSeparator.BackgroundColor = Constants.R245G245B245;

            descriptionTextField = new UITextView();
            descriptionTextField.ScrollEnabled = false;
            descriptionTextField.Font          = Constants.Regular14;
            descriptionEditImage       = new UIImageView();
            descriptionEditImage.Image = UIImage.FromBundle("ic_edit");

            var descriptionHashtagSeparator = new UIView();

            descriptionHashtagSeparator.BackgroundColor = Constants.R245G245B245;

            tagField           = new UILabel();
            tagField.Text      = "Hashtag";
            tagField.Font      = Constants.Regular14;
            tagField.TextColor = Constants.R151G155B158;
            tagField.UserInteractionEnabled = true;
            var tap = new UITapGestureRecognizer(OpenTagPicker);

            tagField.AddGestureRecognizer(tap);

            hashtagImage       = new UIImageView();
            hashtagImage.Image = UIImage.FromBundle("ic_hash");

            var hashtagCollectionSeparator = new UIView();

            hashtagCollectionSeparator.BackgroundColor = Constants.R245G245B245;

            postPhotoButton = new UIButton();
            postPhotoButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.PublishButtonText), UIControlState.Normal);
            postPhotoButton.SetTitle("", UIControlState.Disabled);
            postPhotoButton.Layer.CornerRadius = 25;
            postPhotoButton.TitleLabel.Font    = Constants.Semibold14;
            postPhotoButton.TouchDown         += PostPhoto;

            loadingView                  = new UIActivityIndicatorView();
            loadingView.Color            = UIColor.White;
            loadingView.HidesWhenStopped = true;

            mainScroll.Bounces = false;
            mainScroll.AddSubview(photoTitleSeparator);
            mainScroll.AddSubview(titleTextField);
            mainScroll.AddSubview(titleEditImage);
            mainScroll.AddSubview(titleDescriptionSeparator);
            mainScroll.AddSubview(descriptionTextField);
            mainScroll.AddSubview(descriptionEditImage);
            mainScroll.AddSubview(descriptionHashtagSeparator);
            mainScroll.AddSubview(tagField);
            mainScroll.AddSubview(hashtagImage);
            mainScroll.AddSubview(hashtagCollectionSeparator);
            mainScroll.AddSubview(tagsCollectionView);
            mainScroll.AddSubview(postPhotoButton);
            mainScroll.AddSubview(loadingView);

            if (photoView != null)
            {
                photoTitleSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, photoView, 15f);
            }
            else
            {
                photoTitleSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, photoCollection, 15f);
            }

            photoTitleSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left, _separatorMargin);
            photoTitleSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right, _separatorMargin);
            photoTitleSeparator.AutoSetDimension(ALDimension.Height, 1f);
            photoTitleSeparator.AutoSetDimension(ALDimension.Width, UIScreen.MainScreen.Bounds.Width - _separatorMargin * 2);

            titleTextField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, photoTitleSeparator, 17f);
            titleTextField.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator, -5f);

            titleEditImage.AutoSetDimensionsToSize(new CGSize(18, 18));
            titleEditImage.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator);
            titleEditImage.AutoPinEdge(ALEdge.Left, ALEdge.Right, titleTextField, 5f);
            titleEditImage.AutoAlignAxis(ALAxis.Horizontal, titleTextField);

            titleDescriptionSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, titleTextField, 17f);
            titleDescriptionSeparator.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator);
            titleDescriptionSeparator.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator);
            titleDescriptionSeparator.AutoSetDimension(ALDimension.Height, 1f);

            descriptionTextField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, titleDescriptionSeparator, 17f);
            descriptionTextField.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator, -5f);

            descriptionEditImage.AutoSetDimensionsToSize(new CGSize(18, 18));
            descriptionEditImage.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator);
            descriptionEditImage.AutoPinEdge(ALEdge.Left, ALEdge.Right, descriptionTextField, 5f);
            descriptionEditImage.AutoAlignAxis(ALAxis.Horizontal, descriptionTextField);

            descriptionHashtagSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, descriptionTextField, 17f);
            descriptionHashtagSeparator.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator);
            descriptionHashtagSeparator.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator);
            descriptionHashtagSeparator.AutoSetDimension(ALDimension.Height, 1f);

            tagField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, descriptionHashtagSeparator);
            tagField.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator);
            tagField.AutoSetDimension(ALDimension.Height, 70f);

            hashtagImage.AutoSetDimensionsToSize(new CGSize(15, 17));
            hashtagImage.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator);
            hashtagImage.AutoPinEdge(ALEdge.Left, ALEdge.Right, tagField, 5f);
            hashtagImage.AutoAlignAxis(ALAxis.Horizontal, tagField);

            hashtagCollectionSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, tagField);
            hashtagCollectionSeparator.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator);
            hashtagCollectionSeparator.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator);
            hashtagCollectionSeparator.AutoSetDimension(ALDimension.Height, 1f);

            tagsCollectionView.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, hashtagCollectionSeparator, 25f);
            tagsCollectionView.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator);
            tagsCollectionView.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator);
            tagsCollectionHeight = tagsCollectionView.AutoSetDimension(ALDimension.Height, 0f);

            postPhotoButton.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, tagsCollectionView, 40f);
            postPhotoButton.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator);
            postPhotoButton.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator);
            postPhotoButton.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, 35f);
            postPhotoButton.AutoSetDimension(ALDimension.Height, 50f);

            loadingView.AutoAlignAxis(ALAxis.Horizontal, postPhotoButton);
            loadingView.AutoAlignAxis(ALAxis.Vertical, postPhotoButton);
        }
 public void EmptyConstraints()
 {
     _constraintTop = null;
     _constraintMiddle = null;
     _constraintBottom = null;
     _constraintRight = null;
     _constraintCenter = null;
     _constraintLeft = null;
     _constraintHeight = null;
     _constraintWidth = null;
 }
Esempio n. 35
0
 public static Action <nfloat> BindConstant(this NSLayoutConstraint constraint)
 => constant => constraint.Constant = constant;
Esempio n. 36
0
        public static UILabel AddLabel(UIView view, UILabel label, ResizeAlignment alignment, UIEdgeInsets margins)
        {
            label.SizeToFit();
            label.TranslatesAutoresizingMaskIntoConstraints = false;
            //label.AdjustsFontSizeToFitWidth = true;
            view.AddSubview(label);
            view.AddConstraints(new[] {
                (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Left, NSLayoutRelation.Equal, view, NSLayoutAttribute.Left, 1f, margins.Left)),
                (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Right, NSLayoutRelation.Equal, view, NSLayoutAttribute.Right, 1f, margins.Right)),
            });
            switch (alignment)
            {
            case ResizeAlignment.TopLeft:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1f, margins.Top)),
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1f, +label.Frame.Height + margins.Top)),
                });
                label.TextAlignment = UITextAlignment.Left;
                break;

            case ResizeAlignment.TopCenter:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1f, margins.Top)),
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1f, +label.Frame.Height + margins.Top)),
                });
                label.TextAlignment = UITextAlignment.Center;

                break;

            case ResizeAlignment.TopRight:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1f, margins.Top)),
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1f, +label.Frame.Height + margins.Top)),
                });
                label.TextAlignment = UITextAlignment.Right;

                break;

            case ResizeAlignment.CenterLeft:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, view, NSLayoutAttribute.CenterY, 1f, 0f)),
                });
                label.TextAlignment = UITextAlignment.Left;
                break;

            case ResizeAlignment.CenterCenter:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, view, NSLayoutAttribute.CenterY, 1f, 0f)),
                });
                label.TextAlignment = UITextAlignment.Center;

                break;

            case ResizeAlignment.CenterRight:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, view, NSLayoutAttribute.CenterY, 1f, 0f)),
                });
                label.TextAlignment = UITextAlignment.Right;
                break;

            case ResizeAlignment.BottomLeft:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1f, -(label.Frame.Height + margins.Bottom))),
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1f, margins.Bottom)),
                });
                label.TextAlignment = UITextAlignment.Left;
                break;

            case ResizeAlignment.BottomCenter:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1f, -(label.Frame.Height + margins.Bottom))),
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1f, margins.Bottom)),
                });
                label.TextAlignment = UITextAlignment.Left;
                break;

            case ResizeAlignment.BottomRight:
                view.AddConstraints(new[] {
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1f, -(label.Frame.Height + margins.Bottom))),
                    (NSLayoutConstraint)(NSLayoutConstraint.Create(label, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1f, margins.Bottom)),
                });
                label.TextAlignment = UITextAlignment.Left;
                break;
            }
            return(label);
        }
Esempio n. 37
0
 public static NSLayoutConstraint Create(NSObject view1, NSLayoutAttribute attribute1, NSLayoutRelation relation)
 {
     return(NSLayoutConstraint.Create(view1, attribute1, relation, null, NSLayoutAttribute.NoAttribute, 1.0f, 0f));
 }
        private void Initialize(IHostResourceProvider hostResources, object selectedValue)
        {
            this.selectedValue = selectedValue;
            Frame = new CGRect(10, 35, 630, 305);

            var FrameHeightHalf = (Frame.Height - 32) / 2;
            var FrameWidthHalf  = (Frame.Width - 32) / 2;
            var FrameWidthThird = (Frame.Width - 32) / 3;

            this.progressIndicator = new NSProgressIndicator(new CGRect(FrameWidthThird, FrameHeightHalf, 32, 32))
            {
                Hidden = true,
                Style  = NSProgressIndicatorStyle.Spinning,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };
            AddSubview(this.progressIndicator);

            this.resourceTable = new FirstResponderTableView {
                AutoresizingMask = NSViewResizingMask.WidthSizable,
                HeaderView       = null,
            };

            this.dataSource = new ResourceTableDataSource(viewModel);
            var resourceTableDelegate = new ResourceTableDelegate(hostResources, dataSource);

            resourceTableDelegate.ResourceSelected += (sender, e) => {
                this.previewPanel.SelectedResource = SelectedResource;

                this.selectedValue = BrushPropertyViewModel.GetCommonBrushForResource(SelectedResource);

                ResourceSelected?.Invoke(this, EventArgs.Empty);
            };
            this.resourceTable.Delegate   = resourceTableDelegate;
            this.resourceTable.DataSource = dataSource;

            NSTableColumn resourceImages = new NSTableColumn(ResourceImageColId)
            {
                Title = Properties.Resources.ResourceTableImageColumnTitle, Width = 32
            };

            this.resourceTable.AddColumn(resourceImages);

            NSTableColumn resourceTypes = new NSTableColumn(ResourceTypeColId)
            {
                Title = Properties.Resources.ResourceTableTypeColumnTitle, Width = 150
            };

            this.resourceTable.AddColumn(resourceTypes);

            NSTableColumn resourceName = new NSTableColumn(ResourceNameColId)
            {
                Title = Properties.Resources.ResourceTableNameColumnTitle, Width = 150
            };

            resourceTable.AddColumn(resourceName);

            NSTableColumn resourceValue = new NSTableColumn(ResourceValueColId)
            {
                Title = Properties.Resources.ResourceTableValueColumnTitle, Width = 45
            };

            this.resourceTable.AddColumn(resourceValue);

            this.resourceTable.DoubleClick += (object sender, EventArgs e) => {
                DoubleClicked?.Invoke(this, EventArgs.Empty);
            };

            // create a table view and a scroll view
            this.tableContainer = new NSScrollView(new CGRect(0, 0, resourceTable.TableColumns()[0].Width + resourceTable.TableColumns()[1].Width + resourceTable.TableColumns()[2].Width + 10, Frame.Height))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            this.tableContainer.DocumentView = resourceTable;
            AddSubview(this.tableContainer);

            this.previewPanel = new RequestResourcePreviewPanel(hostResources, new CGRect(Frame.Width - FrameWidthThird, 0, FrameWidthThird, Frame.Height));
            AddSubview(this.previewPanel);

            this.AddConstraints(new[] {
                NSLayoutConstraint.Create(this.tableContainer, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, -190f),
                NSLayoutConstraint.Create(this.tableContainer, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1f, 0f),
            });

            ReloadData();
        }
        public static NSLayoutConstraint[] AttachToParentHorizontally(UIView parent, UIView child, nfloat margin)
        {
            NSLayoutConstraint[] result = new NSLayoutConstraint[2];

            result[0] = AttachToParentLeft(parent, child, margin);
            result[1] = AttachToParentRight(parent, child, margin);

            return result;
        }
Esempio n. 40
0
        public override void WillMoveToParentViewController(UIViewController parent)
        {
            base.WillMoveToParentViewController(parent);

            if (parent != null)
            {
                View.BackgroundColor = PageInfo?.BackgroundColor ?? UIColor.Black;

                _imageView = new UIImageView {
                    ContentMode = UIViewContentMode.ScaleAspectFit,
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    ClipsToBounds = false
                };
                _imageView.Layer.ShadowColor   = UIColor.DarkGray.CGColor;
                _imageView.Layer.ShadowOffset  = new CoreGraphics.CGSize(0, 4);
                _imageView.Layer.ShadowOpacity = .75f;
                _imageView.Layer.ShadowRadius  = 4;

                Add(_imageView);

                _constraints.Add(
                    NSLayoutConstraint.Create(
                        _imageView, NSLayoutAttribute.Top,
                        NSLayoutRelation.Equal,
                        View, NSLayoutAttribute.Top,
                        1.0f, Padding
                        )
                    );

                _constraints.Add(
                    NSLayoutConstraint.Create(
                        _imageView, NSLayoutAttribute.Bottom,
                        NSLayoutRelation.Equal,
                        View, NSLayoutAttribute.Bottom,
                        1.0f, -Padding
                        )
                    );

                _constraints.Add(
                    NSLayoutConstraint.Create(
                        _imageView, NSLayoutAttribute.Leading,
                        NSLayoutRelation.Equal,
                        View, NSLayoutAttribute.Leading,
                        1.0f, Padding
                        )
                    );

                _constraints.Add(
                    NSLayoutConstraint.Create(
                        _imageView, NSLayoutAttribute.Trailing,
                        NSLayoutRelation.Equal,
                        View, NSLayoutAttribute.Trailing,
                        1.0f, -Padding
                        )
                    );

                _pageText = new UILabel {
                    TextAlignment = UITextAlignment.Center,
                    Lines         = 0,
                    LineBreakMode = UILineBreakMode.WordWrap,
                    TranslatesAutoresizingMaskIntoConstraints = false,
                };
                Add(_pageText);

                _constraints.Add(
                    NSLayoutConstraint.Create(
                        _pageText, NSLayoutAttribute.Leading,
                        NSLayoutRelation.Equal,
                        View, NSLayoutAttribute.Leading,
                        1.0f, Padding
                        )
                    );

                _constraints.Add(
                    NSLayoutConstraint.Create(
                        _pageText, NSLayoutAttribute.Trailing,
                        NSLayoutRelation.Equal,
                        View, NSLayoutAttribute.Trailing,
                        1.0f, -Padding
                        )
                    );

                View.AddConstraints(_constraints.ToArray());

                View.SetNeedsUpdateConstraints();
                View.UpdateConstraintsIfNeeded();
            }
            else
            {
                _imageView?.Image?.Dispose();
                _imageView?.RemoveFromSuperview();
                _imageView?.Dispose();

                _pageText?.Dispose();

                View?.RemoveConstraints(_constraints.ToArray());

                for (int i = _constraints.Count - 1; i >= 0; i--)
                {
                    _constraints [i].Dispose();
                }
                _constraints.Clear();
            }
        }
Esempio n. 41
0
		private void AddAllConstraints()
		{
			var constraints = new List<NSLayoutConstraint> ();

			// Fill the card with the background view (leaving a border around it)
			constraints.AddRange (new NSLayoutConstraint[] {
				NSLayoutConstraint.Create (_backgroundView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1f, BorderWidth),
				NSLayoutConstraint.Create (_backgroundView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, BorderWidth),
				NSLayoutConstraint.Create (this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, _backgroundView, NSLayoutAttribute.Trailing, 1f, BorderWidth),
				NSLayoutConstraint.Create (this, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _backgroundView, NSLayoutAttribute.Bottom, 1f, BorderWidth)
			});

			// Position the photo
			// The constant for the aspect ratio constraint will be updated once a photo is set
			_photoAspectRatioConstraint = NSLayoutConstraint.Create (_photo, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 0f, 0f);
			constraints.AddRange (new NSLayoutConstraint[] {
				NSLayoutConstraint.Create (_photo, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1f, HorizontalPadding),
				NSLayoutConstraint.Create (_photo, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, VerticalPadding),
				NSLayoutConstraint.Create (_photo, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 0f, PhotoWidth),
				NSLayoutConstraint.Create (_photo, NSLayoutAttribute.Bottom, NSLayoutRelation.LessThanOrEqual, this, NSLayoutAttribute.Bottom, 1f, -VerticalPadding),
				_photoAspectRatioConstraint
			});

			// Position the age to the right of the photo, with some spacing
			constraints.AddRange (new NSLayoutConstraint[] {
				NSLayoutConstraint.Create (_ageTitleLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _photo, NSLayoutAttribute.Trailing, 1f, InterItemHorizontalSpacing),
				NSLayoutConstraint.Create (_ageTitleLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _photo, NSLayoutAttribute.Top, 1f, 0f),
				NSLayoutConstraint.Create (_ageValueLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _ageTitleLabel, NSLayoutAttribute.Bottom, 1f, TitleValueSpacing),
				NSLayoutConstraint.Create (_ageValueLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _ageTitleLabel, NSLayoutAttribute.Leading, 1f, 0f)
			});

			// Position the hobbies to the right of the age
			constraints.AddRange (new NSLayoutConstraint [] {
				NSLayoutConstraint.Create (_hobbiesTitleLabel, NSLayoutAttribute.Leading, NSLayoutRelation.GreaterThanOrEqual, _ageTitleLabel, NSLayoutAttribute.Trailing, 1f, InterItemHorizontalSpacing),
				NSLayoutConstraint.Create (_hobbiesTitleLabel, NSLayoutAttribute.FirstBaseline, NSLayoutRelation.Equal, _ageTitleLabel, NSLayoutAttribute.FirstBaseline, 1f, 0f),
				NSLayoutConstraint.Create (_hobbiesValueLabel, NSLayoutAttribute.Leading, NSLayoutRelation.GreaterThanOrEqual, _ageValueLabel, NSLayoutAttribute.Trailing, 1f, InterItemHorizontalSpacing),
				NSLayoutConstraint.Create (_hobbiesValueLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _hobbiesTitleLabel, NSLayoutAttribute.Leading, 1f, 0f),
				NSLayoutConstraint.Create (_hobbiesValueLabel, NSLayoutAttribute.FirstBaseline, NSLayoutRelation.Equal, _ageValueLabel, NSLayoutAttribute.FirstBaseline, 1f, 0f),
				NSLayoutConstraint.Create (_hobbiesTitleLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.LessThanOrEqual, this, NSLayoutAttribute.Trailing, 1f, -HorizontalPadding),
				NSLayoutConstraint.Create (_hobbiesValueLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.LessThanOrEqual, this, NSLayoutAttribute.Trailing, 1f, -HorizontalPadding)
			});

			// Position the elevator pitch below the age and the hobbies
			constraints.AddRange (new NSLayoutConstraint[] {
				NSLayoutConstraint.Create (_elevatorPitchTitleLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _ageTitleLabel, NSLayoutAttribute.Leading, 1f, 0f),
				NSLayoutConstraint.Create (_elevatorPitchTitleLabel, NSLayoutAttribute.Top, NSLayoutRelation.GreaterThanOrEqual, _ageValueLabel, NSLayoutAttribute.Bottom, 1f, InterItemVerticalSpacing),
				NSLayoutConstraint.Create (_elevatorPitchTitleLabel, NSLayoutAttribute.Top, NSLayoutRelation.GreaterThanOrEqual, _hobbiesValueLabel, NSLayoutAttribute.Bottom, 1f, InterItemVerticalSpacing),
				NSLayoutConstraint.Create (_elevatorPitchTitleLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1f, -HorizontalPadding),
				NSLayoutConstraint.Create (_elevatorPitchValueLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _elevatorPitchTitleLabel, NSLayoutAttribute.Bottom, 1f, TitleValueSpacing),
				NSLayoutConstraint.Create (_elevatorPitchValueLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _elevatorPitchTitleLabel, NSLayoutAttribute.Leading, 1f, 0f),
				NSLayoutConstraint.Create (_elevatorPitchValueLabel, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1f, -HorizontalPadding),
				NSLayoutConstraint.Create (_elevatorPitchValueLabel, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1f, -VerticalPadding)
			});
			AddConstraints (constraints.ToArray ());
		}
Esempio n. 42
0
 public static Action <bool> BindActive(this NSLayoutConstraint constraint)
 => isActive => constraint.Active = isActive;
Esempio n. 43
0
        public override void MouseDown(NSEvent theEvent)
        {
            NSPoint locationInSelf = this.ConvertPointFromView (theEvent.LocationInWindow, null);
            int dividerIndex = this.dividerIndexForPoint (locationInSelf);

            if (dividerIndex != -1) {
                // First we lock the heights in place for the given dividerIndex
                this.SetHeightConstraints (this.ConstraintsForHeightsWithPrioritiesLowestAroundDivider (dividerIndex));

                // Now we add a constraint that forces the bottom edge of the view above the divider to align with the mouse location
                NSView viewAboveDivider = this.Subviews.ObjectAtIndex<NSView> ((uint)dividerIndex);
                this._draggingConstraint = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews ("V:[viewAboveDivider]-100-|", 0, null, NSDictionary.DictionaryWithObjectForKey (viewAboveDivider, (NSString)"viewAboveDivider")).LastObject.Retain<NSLayoutConstraint> ();
                this._draggingConstraint.Priority = NSLayoutPriority.NSLayoutPriorityDragThatCannotResizeWindow;
                this._draggingConstraint .Constant = locationInSelf.y;

                this.AddConstraint (this._draggingConstraint);
            } else {
                this.SendMessageSuper (SplitViewClass, "mouseDown:", theEvent);
            }
        }
Esempio n. 44
0
 public static NSLayoutConstraint Create(NSObject view1, NSLayoutAttribute attribute1, NSLayoutRelation relation, nfloat multiplier, nfloat constant)
 {
     return(NSLayoutConstraint.Create(view1, attribute1, relation, null, NSLayoutAttribute.NoAttribute, multiplier, constant));
 }
Esempio n. 45
0
        public override void MouseUp(NSEvent theEvent)
        {
            if (this._draggingConstraint != null) {
                // update the dragging constraint for the new location
                this.RemoveConstraint (this._draggingConstraint);
                this._draggingConstraint.Release ();
                this._draggingConstraint = null;

                // We lock the current heights in place
                this.SetHeightConstraints (this.ConstraintsForHeightsWithPrioritiesLowestAroundDivider (-2));
            } else {
                this.SendMessageSuper (SplitViewClass, "mouseUp:", theEvent);
            }
        }
        public BindingPathSelectorControl(CreateBindingViewModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            ViewModel = viewModel;

            TranslatesAutoresizingMaskIntoConstraints = false;

            this.pathBox = new NSView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                WantsLayer = true,

                // Layer out of alphabetical order so that WantsLayer creates the layer first
                Layer =
                {
                    CornerRadius =            1.0f,
                    BorderColor  = new CGColor(.5f, .5f, .5f, 1.0f),
                    BorderWidth  =               1,
                },
            };

            AddSubview(this.pathBox);

            this.pathHeader = new HeaderView {
                Title = Properties.Resources.Path,
            };
            this.pathHeader.HorizonalTitleOffset = -HorizontalCustomOffSet;

            this.pathBox.AddSubview(this.pathHeader);

            this.pathBox.AddConstraints(new[] {
                NSLayoutConstraint.Create(this.pathHeader, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.Top, 1f, 0f),
                NSLayoutConstraint.Create(this.pathHeader, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.Left, 1f, 0f),
                NSLayoutConstraint.Create(this.pathHeader, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.Width, 1f, 0f),
                NSLayoutConstraint.Create(this.pathHeader, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, BindingEditorWindow.HeaderHeight),
            });

            var customCheckBox = new NSButton {
                AccessibilityEnabled = true,
                AccessibilityTitle   = Properties.Resources.AccessibilityBindingPathSelectorCustomCheckbox,
                ControlSize          = NSControlSize.Small,
                Font  = NSFont.FromFontName(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
                Title = Properties.Resources.Custom,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            customCheckBox.SetButtonType(NSButtonType.Switch);

            this.pathHeader.AddSubview(customCheckBox);
            this.pathHeader.AddConstraints(new[] {
                NSLayoutConstraint.Create(customCheckBox, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this.pathHeader, NSLayoutAttribute.CenterX, 1, HorizontalCustomOffSet),
                NSLayoutConstraint.Create(customCheckBox, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this.pathHeader, NSLayoutAttribute.CenterY, 1, 0f),
            });

            this.customPathControl = new NSTextField {
                AccessibilityEnabled = true,
                AccessibilityTitle   = Properties.Resources.AccessibilityBindingPathSelectorCustomPath,
                ControlSize          = NSControlSize.Regular,
                Enabled = false,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var customPathHeightConstraint = NSLayoutConstraint.Create(this.customPathControl, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 0);

            this.pathBox.AddSubview(this.customPathControl);
            this.pathBox.AddConstraints(new[] {
                NSLayoutConstraint.Create(this.customPathControl, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.Top, 1f, 28f),
                NSLayoutConstraint.Create(this.customPathControl, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.Width, 1f, 0f),
                NSLayoutConstraint.Create(this.customPathControl, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.CenterX, 1, 0),
                customPathHeightConstraint,
            });

            // create a table view and a scroll view
            var outlineViewContainer = new NSScrollView {
                AccessibilityEnabled = true,
                AccessibilityTitle   = Properties.Resources.AccessibilityBindingPathSelectorPathTable,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            customCheckBox.Activated += (sender, e) => {
                this.customPathControl.Enabled      = customCheckBox.State == NSCellStateValue.On;
                customPathHeightConstraint.Constant = this.customPathControl.Enabled ? 22 : 0;
            };

            this.customPathControl.Changed += (sender, e) => {
                viewModel.Path = this.customPathControl.StringValue;
            };

            this.pathOutlineView = new PathOutlineView {
            };

            this.pathOutlineView.Activated += OnPathOutlineViewSelected;

            var pathColumn = new NSTableColumn(PathSelectorColumnColId);

            this.pathOutlineView.AddColumn(pathColumn);

            // Set OutlineTableColumn or the arrows showing children/expansion will not be drawn
            this.pathOutlineView.OutlineTableColumn = pathColumn;

            // add the panel to the window
            outlineViewContainer.DocumentView = this.pathOutlineView;

            this.pathBox.AddSubview(outlineViewContainer);

            this.pathBox.AddConstraints(new[] {
                NSLayoutConstraint.Create(outlineViewContainer, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.customPathControl, NSLayoutAttribute.Bottom, 1f, 0f),
                NSLayoutConstraint.Create(outlineViewContainer, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.Width, 1f, 0f),
                NSLayoutConstraint.Create(outlineViewContainer, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.CenterX, 1, 0),
                NSLayoutConstraint.Create(outlineViewContainer, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this.pathBox, NSLayoutAttribute.Bottom, 1f, 0f),
            });

            AddConstraints(new[] {
                NSLayoutConstraint.Create(this.pathBox, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 0f),
                NSLayoutConstraint.Create(this.pathBox, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f),
                NSLayoutConstraint.Create(this.pathBox, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1f, 0f),
                NSLayoutConstraint.Create(this.pathBox, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, 0f),
            });

            viewModel.PropertyChanged += OnPropertyChanged;
        }
Esempio n. 47
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = UIColor.White
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _takeMapOfflineButton = new UIBarButtonItem("Generate offline map", UIBarButtonItemStyle.Plain, TakeMapOfflineButton_Click);

            UIToolbar toolbar = new UIToolbar();

            toolbar.TranslatesAutoresizingMaskIntoConstraints = false;
            toolbar.Items = new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                _takeMapOfflineButton,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace)
            };

            _statusLabel = new UILabel
            {
                Text = "Use the button to take the map offline.",
                AdjustsFontSizeToFitWidth = true,
                TextAlignment             = UITextAlignment.Center,
                BackgroundColor           = UIColor.FromWhiteAlpha(0, .6f),
                TextColor = UIColor.White,
                Lines     = 1,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _loadingIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
            _loadingIndicator.TranslatesAutoresizingMaskIntoConstraints = false;
            _loadingIndicator.BackgroundColor = UIColor.FromWhiteAlpha(0, .6f);

            // Add the views.
            View.AddSubviews(_myMapView, toolbar, _loadingIndicator, _statusLabel);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor),

                toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),

                _statusLabel.TopAnchor.ConstraintEqualTo(_myMapView.TopAnchor),
                _statusLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _statusLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _statusLabel.HeightAnchor.ConstraintEqualTo(40),

                _loadingIndicator.TopAnchor.ConstraintEqualTo(_statusLabel.BottomAnchor),
                _loadingIndicator.BottomAnchor.ConstraintEqualTo(View.BottomAnchor),
                _loadingIndicator.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _loadingIndicator.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor)
            });
        }
Esempio n. 48
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = ApplicationTheme.BackgroundColor
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _resultLabel = new UILabel
            {
                Text = "Adjust the slider to start.",
                AdjustsFontSizeToFitWidth = true,
                TextAlignment             = UITextAlignment.Center,
                BackgroundColor           = UIColor.FromWhiteAlpha(0, .6f),
                TextColor = UIColor.White,
                Lines     = 1,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _operationPicker = new UISegmentedControl("Densify", "Generalize");
            _operationPicker.TranslatesAutoresizingMaskIntoConstraints = false;
            _operationPicker.SelectedSegment = 0;

            _slider = new UISlider();
            _slider.TranslatesAutoresizingMaskIntoConstraints = false;
            _slider.MinValue = 100.0F;
            _slider.MaxValue = 500.0F;
            _slider.Value    = 100.0F;

            UIToolbar toolbar = new UIToolbar();

            toolbar.TranslatesAutoresizingMaskIntoConstraints = false;
            toolbar.Items = new[]
            {
                new UIBarButtonItem {
                    CustomView = _operationPicker
                },
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem {
                    CustomView = _slider, Width = 150
                }
            };

            // Add the views.
            View.AddSubviews(_myMapView, toolbar, _resultLabel);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor),

                toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),

                _resultLabel.TopAnchor.ConstraintEqualTo(_myMapView.TopAnchor),
                _resultLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _resultLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _resultLabel.HeightAnchor.ConstraintEqualTo(40)
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.ModalPresentationStyle = UIModalPresentationStyle.Custom;
            this.TransitioningDelegate  = this;
            this.View.BackgroundColor   = UIColor.Clear;


            // Date Picker
            var datePicker = new UIDatePicker
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Date            = this.SelectedDateTime.ToNSDate(),
                BackgroundColor = BackgroundColor,
                Mode            = Mode,
                MinuteInterval  = MinuteInterval
            };

            if (MinimumDateTime != null)
            {
                datePicker.MinimumDate = MinimumDateTime.Value.ToNSDate();
            }

            if (MaximumDateTime != null)
            {
                datePicker.MaximumDate = MaximumDateTime.Value.ToNSDate();
            }

            dimmedView = new UIView(this.View.Bounds)
            {
                AutoresizingMask   = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
                TintAdjustmentMode = UIViewTintAdjustmentMode.Dimmed,
                BackgroundColor    = UIColor.Black
            };


            var dismissButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                UserInteractionEnabled = true
            };

            dismissButton.TouchUpInside += (s, e) =>
            {
                Cancel?.Invoke(this);
            };
            this.View.AddSubview(dismissButton);

            var containerView = new UIView
            {
                ClipsToBounds   = true,
                BackgroundColor = UIColor.White,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            containerView.Layer.CornerRadius = 5.0f;
            this.View.AddSubview(containerView);

            containerView.AddSubview(datePicker);

            var buttonContainerView = new UIView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.White
            };

            buttonContainerView.Layer.CornerRadius = 5.0f;
            this.View.AddSubview(buttonContainerView);

            var buttonDividerView = new UIView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromRGBA(205 / 255, 205 / 255, 205 / 255, 1)
            };

            this.View.AddSubview(buttonDividerView);

            var cancelButton = new UIButton();

            cancelButton.TranslatesAutoresizingMaskIntoConstraints = false;
            cancelButton.SetTitle(CancelText, UIControlState.Normal);
            cancelButton.SetTitleColor(UIColor.Red, UIControlState.Normal);

            cancelButton.TitleLabel.Font = UIFont.SystemFontOfSize(FontSize);
            cancelButton.TouchUpInside  += (s, e) =>
            {
                Cancel?.Invoke(this);
            };
            buttonContainerView.AddSubview(cancelButton);

            var button = new UIButton(UIButtonType.System);

            button.TranslatesAutoresizingMaskIntoConstraints = false;
            button.TitleLabel.Font = UIFont.BoldSystemFontOfSize(FontSize);
            button.SetTitle(this.OkText, UIControlState.Normal);
            button.TouchUpInside += (s, e) =>
            {
                Ok?.Invoke(this);
            };
            buttonContainerView.AddSubview(button);

            var views = NSDictionary.FromObjectsAndKeys(
                new NSObject[] { dismissButton, containerView, datePicker, buttonContainerView, buttonDividerView, cancelButton, button },
                new NSObject[] {
                new NSString("DismissButton"), new NSString("DatePickerContainerView"), new NSString("datePicker"),
                new NSString("ButtonContainerView"), new NSString("ButtonDividerView"), new NSString("CancelButton"),
                new NSString("SelectButton")
            }
                );

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[CancelButton][ButtonDividerView(0.5)][SelectButton(CancelButton)]|", 0, null, views));

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[CancelButton]|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[ButtonDividerView]|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[SelectButton]|", 0, null, views));

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[datePicker]|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[datePicker]|", 0, null, views));

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[DismissButton]|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-5-[DatePickerContainerView]-5-|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-5-[ButtonContainerView]-5-|", 0, null, views));

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[DismissButton][DatePickerContainerView]-10-[ButtonContainerView(40)]-5-|", 0, null, views));
        }
Esempio n. 50
0
        public TTGSnackbar() : base(CoreGraphics.CGRect.FromLTRB(0, 0, 320, 44))
        {
            this.TranslatesAutoresizingMaskIntoConstraints = false;
            this.BackgroundColor     = UIColor.DarkGray;
            this.Layer.CornerRadius  = 4;
            this.Layer.MasksToBounds = true;

            SetupSafeAreaInsets();

            this.MessageLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor       = UIColor.White,
                Font            = UIFont.SystemFontOfSize(14),
                BackgroundColor = UIColor.Clear,
                LineBreakMode   = UILineBreakMode.WordWrap,
                TextAlignment   = UITextAlignment.Left,
                Lines           = 0
            };

            this.AddSubview(this.MessageLabel);

            IconImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear,
                ContentMode     = IconContentMode
            };

            this.AddSubview(IconImageView);

            this.ActionButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear
            };
            this.ActionButton.TitleLabel.Font = UIFont.SystemFontOfSize(14);
            this.ActionButton.TitleLabel.AdjustsFontSizeToFitWidth = true;
            this.ActionButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            this.ActionButton.TouchUpInside += (s, e) =>
            {
                // there is a chance that user doesn't want to do anything here, he simply wants to dismiss
                ActionBlock?.Invoke(this);
                Dismiss();
            };

            this.AddSubview(this.ActionButton);

            this.SecondActionButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear
            };
            this.SecondActionButton.TitleLabel.Font = UIFont.BoldSystemFontOfSize(14);
            this.SecondActionButton.TitleLabel.AdjustsFontSizeToFitWidth = true;
            this.SecondActionButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            this.SecondActionButton.TouchUpInside += (s, e) =>
            {
                SecondActionBlock?.Invoke(this);
                Dismiss();
            };

            this.AddSubview(this.SecondActionButton);

            this.seperateView = new UIView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Gray
            };

            this.AddSubview(this.seperateView);

            // Add constraints
            var hConstraints = NSLayoutConstraint.FromVisualFormat(
                "H:|-0-[iconImageView]-2-[messageLabel]-2-[seperateView(0.5)]-2-[actionButton(>=44@999)]-0-[secondActionButton(>=44@999)]-0-|",
                0,
                new NSDictionary(),
                NSDictionary.FromObjectsAndKeys(
                    new NSObject[] {
                IconImageView,
                MessageLabel,
                seperateView,
                ActionButton,
                SecondActionButton
            },
                    new NSObject[] {
                new NSString("iconImageView"),
                new NSString("messageLabel"),
                new NSString("seperateView"),
                new NSString("actionButton"),
                new NSString("secondActionButton")
            }
                    )
                );

            var vConstraintsForIconImageView = NSLayoutConstraint.FromVisualFormat(
                "V:|-2-[iconImageView]-2-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { IconImageView }, new NSObject[] { new NSString("iconImageView") })
                );

            var vConstraintsForMessageLabel = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[messageLabel]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { MessageLabel }, new NSObject[] { new NSString("messageLabel") })
                );

            var vConstraintsForSeperateView = NSLayoutConstraint.FromVisualFormat(
                "V:|-4-[seperateView]-4-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { seperateView }, new NSObject[] { new NSString("seperateView") })
                );

            var vConstraintsForActionButton = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[actionButton]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { ActionButton }, new NSObject[] { new NSString("actionButton") })
                );

            var vConstraintsForSecondActionButton = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[secondActionButton]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { SecondActionButton }, new NSObject[] { new NSString("secondActionButton") })
                );

            iconImageViewWidthConstraint = NSLayoutConstraint.Create(IconImageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarIconImageViewWidth);

            actionButtonWidthConstraint = NSLayoutConstraint.Create(ActionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarActionButtonMinWidth);

            secondActionButtonWidthConstraint = NSLayoutConstraint.Create(SecondActionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarActionButtonMinWidth);

            //var vConstraintsForActivityIndicatorView = NSLayoutConstraint.FromVisualFormat(
            //"V:|-2-[activityIndicatorView]-2-|", 0,new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { activityIndicatorView }, new NSObject[] { new NSString("activityIndicatorView") })
            //);

            //todo fix constraint
            //var hConstraintsForActivityIndicatorView = NSLayoutConstraint.FromVisualFormat(
            //  //"H:[activityIndicatorView(activityIndicatorWidth)]-2-|",
            //  "H:[activityIndicatorView]-2-|",
            //  0,
            //  new NSDictionary(),
            //  NSDictionary.FromObjectsAndKeys(
            //      new NSObject[] {  activityIndicatorView },
            //                 new NSObject[] {  new NSString("activityIndicatorView") })
            //  //NSDictionary.FromObjectsAndKeys(new NSObject[] { activityIndicatorView }, new NSObject[] {  })
            //);

            IconImageView.AddConstraint(iconImageViewWidthConstraint);
            ActionButton.AddConstraint(actionButtonWidthConstraint);
            SecondActionButton.AddConstraint(secondActionButtonWidthConstraint);

            this.AddConstraints(hConstraints);
            this.AddConstraints(vConstraintsForIconImageView);
            this.AddConstraints(vConstraintsForMessageLabel);
            this.AddConstraints(vConstraintsForSeperateView);
            this.AddConstraints(vConstraintsForActionButton);
            this.AddConstraints(vConstraintsForSecondActionButton);
            //this.AddConstraints(vConstraintsForActivityIndicatorView);
            //this.AddConstraints(hConstraintsForActivityIndicatorView);
        }
Esempio n. 51
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = UIColor.White
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _layerList = new UITableView();
            _layerList.TranslatesAutoresizingMaskIntoConstraints = false;
            _layerList.RowHeight = 40;

            UILabel helpLabel = new UILabel
            {
                Text = "Select layers for display.",
                AdjustsFontSizeToFitWidth = true,
                TextAlignment             = UITextAlignment.Center,
                BackgroundColor           = UIColor.FromWhiteAlpha(0, .6f),
                TextColor = UIColor.White,
                Lines     = 1,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            // Add the views.
            View.AddSubviews(_myMapView, _layerList, helpLabel);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                helpLabel.LeadingAnchor.ConstraintEqualTo(_myMapView.LeadingAnchor),
                helpLabel.TrailingAnchor.ConstraintEqualTo(_myMapView.TrailingAnchor),
                helpLabel.TopAnchor.ConstraintEqualTo(_myMapView.TopAnchor),
                helpLabel.HeightAnchor.ConstraintEqualTo(40),
            });

            _portraitConstraints = new[]
            {
                _layerList.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _layerList.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _layerList.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _layerList.HeightAnchor.ConstraintEqualTo(_layerList.RowHeight * 4),
                _myMapView.TopAnchor.ConstraintEqualTo(_layerList.BottomAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor)
            };

            _landscapeConstraints = new[]
            {
                _layerList.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _layerList.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _layerList.BottomAnchor.ConstraintEqualTo(View.BottomAnchor),
                _layerList.TrailingAnchor.ConstraintEqualTo(View.CenterXAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(_layerList.TrailingAnchor),
                _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor)
            };

            SetLayoutOrientation();
        }
Esempio n. 52
0
        public UIDayScheduleSnapshot()
        {
            var background = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor
            };

            {
                var paddingContainer = new UIControl()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    _stackViewHolidays = new UIStackView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Axis    = UILayoutConstraintAxis.Vertical,
                        Spacing = 1
                    };
                    paddingContainer.Add(_stackViewHolidays);
                    _stackViewHolidays.StretchWidth(paddingContainer);

                    _timetable = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        _scheduleGapLines = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleGapLines);
                        _scheduleGapLines.StretchWidthAndHeight(_timetable);

                        _scheduleTimesColumn = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleTimesColumn);
                        _scheduleTimesColumn.StretchHeight(_timetable);
                        _scheduleTimesColumn.SetWidth(TIME_INDICATOR_SIZE);
                        _scheduleTimesColumn.PinToLeft(_timetable);

                        var verticalDivider = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            BackgroundColor = UIColorCompat.SecondaryLabelColor
                        };
                        _timetable.Add(verticalDivider);
                        verticalDivider.StretchHeight(_timetable);
                        verticalDivider.SetWidth(GAP_SIZE);
                        verticalDivider.PinToLeft(_timetable, left: (int)TIME_INDICATOR_SIZE);

                        _scheduleItemsColumn = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleItemsColumn);
                        _scheduleItemsColumn.StretchHeight(_timetable);
                        _scheduleItemsColumn.StretchWidth(_timetable, left: TIME_INDICATOR_SIZE + GAP_SIZE + 8, right: 8);

                        // Normally we would have used constraints to lay these out horizontally, but for some reason constraints
                        // are acting up and the horizontal constraints weren't working correctly, so just pinning things to the left
                        // and applying correct padding
                        // Maybe it was because I originally forgot TranslatesAutoresizing on the verticalDivider... that would explain it
                    }
                    paddingContainer.Add(_timetable);
                    _timetable.StretchWidth(paddingContainer);

                    _holidaysItemsSourceAdapter = new BareUIStackViewItemsSourceAdapter <UIMainCalendarItemView>(_stackViewHolidays);

                    paddingContainer.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[holidays][timetable]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                        "holidays", _stackViewHolidays,
                                                                                        "timetable", _timetable));
                }
                background.Add(paddingContainer);
                paddingContainer.StretchWidthAndHeight(background);
            }
            this.Add(background);
            background.StretchWidthAndHeight(this, top: 16, bottom: 16);
        }
Esempio n. 53
0
        void addEdgeConstraint(NSLayoutAttribute edge, NSView parentView, NSView subView)
        {
            var constraint = NSLayoutConstraint.Create(subView, edge, NSLayoutRelation.Equal, parentView, edge, 1, 0);

            parentView.AddConstraint(constraint);
        }
Esempio n. 54
0
        private void InitializeViews()
        {
            base.TranslatesAutoresizingMaskIntoConstraints = false;
            base.BackgroundColor = new UIColor(235f / 255f, 1);

            // [ [labelName] [labelGPA] ]
            // [ semesterView           ]
            // [ buttonAddSemester      ]

            // stackView
            // + viewNameAndGpa
            //   + labelName
            //   + labelGpa
            // + semesterView
            // + buttonAddSemester

            var stackView = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 12
            };

            // Name and GPA
            var viewNameAndGpa = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            viewNameAndGpa.TouchUpInside += new WeakEventHandler(delegate { OnRequestEditYear?.Invoke(this, DataContext as ViewItemYear); }).Handler;
            {
                var labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelName, nameof(ViewItemYear.Name));
                viewNameAndGpa.AddSubview(labelName);

                var labelGpa = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelGpa, nameof(ViewItemYear.GPA), (gpa) =>
                {
                    return(((double)gpa).ToString("0.0##"));
                });
                viewNameAndGpa.AddSubview(labelGpa);

                viewNameAndGpa.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelName]->=6-[labelGpa]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary("labelName", labelName, "labelGpa", labelGpa)));
                labelName.StretchHeight(viewNameAndGpa);
                labelGpa.StretchHeight(viewNameAndGpa);
            }
            stackView.AddArrangedSubview(viewNameAndGpa);
            viewNameAndGpa.StretchWidth(stackView);

            // Semester
            var stackViewSemesters = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8
            };

            _itemsSourceSemesters = new BareUIStackViewItemsSourceAdapter <UISemesterView>(stackViewSemesters);
            _itemsSourceSemesters.OnViewCreated += _itemsSourceSemesters_OnViewCreated;
            stackView.AddArrangedSubview(stackViewSemesters);
            stackViewSemesters.StretchWidth(stackView);

            // Add semester button
            var buttonAddSemester = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonAddSemester.SetTitle("Add Semester", UIControlState.Normal);
            buttonAddSemester.TouchUpInside += new WeakEventHandler(ButtonAddSemester_TouchUpInside).Handler;
            stackView.AddArrangedSubview(buttonAddSemester);
            buttonAddSemester.StretchWidth(stackView);

            base.AddSubview(stackView);
            stackView.StretchWidthAndHeight(this, top: 6, bottom: 6, left: 8, right: 8);
        }
        void AddAdBanner(bool show)
        {
            if (searchTableBottom != null)
                View.RemoveConstraint(searchTableBottom);

            if (show)
            {
                ads.Hidden = false;

                //Ads Constraints
                this.View.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(ads, NSLayoutAttribute.Width, NSLayoutRelation.Equal, holderView, NSLayoutAttribute.Width, 1, 0),
                    NSLayoutConstraint.Create(ads, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, holderView, NSLayoutAttribute.CenterX, 1, 0),
                    NSLayoutConstraint.Create(ads, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, holderView, NSLayoutAttribute.Bottom, 1, 0),
                    //NSLayoutConstraint.Create(ads, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 50),
                });

                searchTableBottom = NSLayoutConstraint.Create(SearchTableView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ads, NSLayoutAttribute.Bottom, 1, 0);
            }
            else
            {
                ads.Hidden = true;
                searchTableBottom = NSLayoutConstraint.Create(SearchTableView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, holderView, NSLayoutAttribute.Bottom, 1, 0);
            }
            View.AddConstraint(searchTableBottom);
            this.View.LayoutIfNeeded();
        }