Ejemplo n.º 1
0
		public LineLayout ()
		{
			ItemSize = new CGSize (ITEM_SIZE, ITEM_SIZE);
			ScrollDirection = UICollectionViewScrollDirection.Horizontal;
			SectionInset = new UIEdgeInsets (200, 0.0f, 200, 0.0f);
			MinimumLineSpacing = 50.0f;
		}
        protected virtual void KeyboardDidShowNotification(NSNotification notification)
        {
            UIView activeView = KeyboardGetActiveView();
            if (activeView == null)
                return;

            ((UITextField)activeView).ShowDoneButtonOnKeyboard();

            UIScrollView scrollView = activeView.FindSuperviewOfType(this.View, typeof(UIScrollView)) as UIScrollView;
            if (scrollView == null)
                return;

            RectangleF keyboardBounds = UIKeyboard.BoundsFromNotification(notification);

            UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, keyboardBounds.Size.Height, 0.0f);
            scrollView.ContentInset = contentInsets;
            scrollView.ScrollIndicatorInsets = contentInsets;

            // If activeField is hidden by keyboard, scroll it so it's visible
            RectangleF viewRectAboveKeyboard = new RectangleF(this.View.Frame.Location, new SizeF(this.View.Frame.Width, this.View.Frame.Size.Height - keyboardBounds.Size.Height));

            RectangleF activeFieldAbsoluteFrame = activeView.Superview.ConvertRectToView(activeView.Frame, this.View);
            // activeFieldAbsoluteFrame is relative to this.View so does not include any scrollView.ContentOffset

            // Check if the activeField will be partially or entirely covered by the keyboard
            if (!viewRectAboveKeyboard.Contains(activeFieldAbsoluteFrame)) {
                // Scroll to the activeField Y position + activeField.Height + current scrollView.ContentOffset.Y - the keyboard Height
                PointF scrollPoint = new PointF(0.0f, activeFieldAbsoluteFrame.Location.Y + activeFieldAbsoluteFrame.Height + scrollView.ContentOffset.Y - viewRectAboveKeyboard.Height);
                scrollView.SetContentOffset(scrollPoint, true);
            }
        }
 public CardLayoutFlow(UIView superView)
 {
     _superView = superView;
     ItemSize = new SizeF(100.0f, 153.0f);
     SectionInset = new UIEdgeInsets(0, 60, 0, 60);
     ScrollDirection = UICollectionViewScrollDirection.Horizontal;
 }
Ejemplo n.º 4
0
 // Workaround until this method is available in Xamarin.iOS
 public static CoreGraphics.CGRect InsetRect(CoreGraphics.CGRect rect, UIEdgeInsets insets)
 {
     return new CoreGraphics.CGRect(rect.X + insets.Left,
                            rect.Y + insets.Top,
                            rect.Width - insets.Left - insets.Right,
                            rect.Height - insets.Top - insets.Bottom);
 }
Ejemplo n.º 5
0
        public ImagePanScrollBarView(RectangleF frame, UIEdgeInsets edgeInsets)
            : base(frame)
        {
            var scrollbarPath = UIBezierPath.Create ();
            scrollbarPath.MoveTo (new PointF (edgeInsets.Left, Bounds.Height - edgeInsets.Bottom));
            scrollbarPath.AddLineTo (new PointF (Bounds.Width - edgeInsets.Right, Bounds.Height - edgeInsets.Bottom));

            var backgroundLayer = new CAShapeLayer () {
                Path = scrollbarPath.CGPath,
                LineWidth = 1,
                StrokeColor = UIColor.White.ColorWithAlpha (.1f).CGColor,
                FillColor = UIColor.Clear.CGColor
            };

            scrollbarLayer = new CAShapeLayer () {
                Path = scrollbarPath.CGPath,
                LineWidth = 1,
                StrokeColor = UIColor.White.CGColor,
                FillColor = UIColor.Clear.CGColor,
                Actions = new NSDictionary ("strokeStart", NSNull.Null, "strokeEnd", NSNull.Null)
            };

            Layer.AddSublayer (backgroundLayer);
            Layer.AddSublayer (scrollbarLayer);
        }
Ejemplo n.º 6
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            if (ImageView != null)
            {
                var center = ImageView.Center;
                ImageView.Frame = new CGRect(0, 0, ImageSize, ImageSize);
                ImageView.Center = new CGPoint(ImageSize, center.Y);

                if (RoundedImage)
                {
                    ImageView.Layer.MasksToBounds = true;
                    ImageView.Layer.CornerRadius = ImageSize / 2f;
                }
                else
                {
                    ImageView.Layer.MasksToBounds = false;
                    ImageView.Layer.CornerRadius = 0;
                }

                if (TextLabel != null)
                {
                    var frame = TextLabel.Frame;
                    frame.X = ImageSize * 2;
                    frame.Width += (TextLabel.Frame.X - frame.X);
                    TextLabel.Frame = frame;
                }
            }

            SeparatorInset = new UIEdgeInsets(0, TextLabel.Frame.Left, 0, 0);
            SetupNotificationView();
        }
Ejemplo n.º 7
0
        public void UpdateWidth(int itemsCount, float width)
        {
            float interval = width / (itemsCount + 1);

            SectionInset = new UIEdgeInsets(0, interval - ITEM_SIZE / 2, 0, 0);
            MinimumLineSpacing = interval - ITEM_SIZE;
        }
Ejemplo n.º 8
0
 private void OnKeyboardNotification (NSNotification notification)
 {
     var keyboardFrame = UIKeyboard.FrameEndFromNotification (notification);
     var inset = new UIEdgeInsets(0, 0, keyboardFrame.Height, 0);
     TableView.ContentInset = inset;
     TableView.ScrollIndicatorInsets = inset;
 }
Ejemplo n.º 9
0
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            if (BorderWidthAll > 0)
            {
                BorderWidth = new UIEdgeInsets(BorderWidthAll, BorderWidthAll, BorderWidthAll, BorderWidthAll);
            }

            if (BorderColorAll != null)
            {
                BorderColorTop = BorderColorBottom = BorderColorLeft = BorderColorRight = BorderColorAll;
            }

            var xMin = rect.GetMinX();
            var xMax = rect.GetMaxX();

            var yMin = rect.GetMinY();
            var yMax = rect.GetMaxY();

            var fWidth = this.Frame.Size.Width;
            var fHeight = this.Frame.Size.Height;

            var context = UIGraphics.GetCurrentContext();

            if (context != null)
                DrawBorders(context, xMin, xMax, yMin, yMax, fWidth, fHeight);
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

              TitleEdgeInsets = new UIEdgeInsets(0, 10, 0, 0);
              SetImage(BACK_IMAGE, UIControlState.Normal);
        }
Ejemplo n.º 11
0
partial         void ApplyPadding(System.Windows.Thickness padding)
        {
            var inset = new UIEdgeInsets(padding.TopF(), padding.LeftF(), padding.BottomF(), padding.RightF());
            var tableView = (UITableView)this.NativeUIElement;
            tableView.ContentInset = inset;
            tableView.ScrollIndicatorInsets = inset;
        }
 public override void LayoutSubviews()
 {
     base.LayoutSubviews();
     SeparatorInset = new UIEdgeInsets(0, Bounds.Width, 0, 0);
     TextView.Frame = new RectangleF(0, 0, ContentView.Frame.Width, ContentView.Frame.Height);
     TextView.LayoutIfNeeded();
 }
Ejemplo n.º 13
0
		public static UIImage ButtonImage (UIColor color, float cornerRadius, UIColor shadowColor, UIEdgeInsets shadowInsets)
		{

			UIImage topImage = ImageWithColor (color, cornerRadius);
			UIImage bottomImage = ImageWithColor (shadowColor, cornerRadius);

			float totalHeight = EdgeSizeFromCornerRadius (cornerRadius) + shadowInsets.Top + shadowInsets.Bottom;
			float totalWidth = EdgeSizeFromCornerRadius (cornerRadius) + shadowInsets.Left + shadowInsets.Right;
			float topWidth = EdgeSizeFromCornerRadius (cornerRadius);
			float topHeight = EdgeSizeFromCornerRadius (cornerRadius);
			RectangleF topRect = new RectangleF (shadowInsets.Left, shadowInsets.Top, topWidth, topHeight);
			RectangleF bottomRect = new RectangleF (0, 0, totalWidth, totalHeight);

			UIGraphics.BeginImageContextWithOptions (new SizeF (totalWidth, totalHeight), false, 0.0f);

			if (!RectangleF.Equals (bottomRect, topRect)) {
				bottomImage.Draw (bottomRect);
			}
			topImage.Draw (topRect);

			UIImage buttonImage = UIGraphics.GetImageFromCurrentImageContext ();
			UIGraphics.EndImageContext ();
			UIEdgeInsets resizeableInsets = new UIEdgeInsets (cornerRadius + shadowInsets.Top,
			                                                  cornerRadius + shadowInsets.Left,
			                                                  cornerRadius + shadowInsets.Bottom,
			                                                  cornerRadius + shadowInsets.Right);
			return buttonImage.CreateResizableImage (resizeableInsets);
		}
Ejemplo n.º 14
0
        /// <summary>
        /// Adjusts the edge insets.
        /// </summary>
        void AdjustEdgeInsets()
        {
            const float Inset = 8f;

            HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
            ImageEdgeInsets = new UIEdgeInsets(0f, Inset, 0f, 0f);
            TitleEdgeInsets = new UIEdgeInsets(0f, Inset * 2, 0f, 0f);
        }
Ejemplo n.º 15
0
 public MainMenuFlowLayout()
 {
     ItemSize = new SizeF (ITEM_SIZE, ITEM_SIZE);
     ScrollDirection = UICollectionViewScrollDirection.Vertical;
     SectionInset = new UIEdgeInsets(65, 0, 100, 0);
     MinimumLineSpacing = 20.0f;
     MinimumInteritemSpacing = 0f;
 }
 public PackageManagerButton()
 {
     BackgroundColor = Colors.AppleBlue;
     SetTitleColor(UIColor.White, UIControlState.Normal);
     Layer.CornerRadius = 5;
     HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
     TitleEdgeInsets = new UIEdgeInsets(0, 0, 0, 10);
 }
Ejemplo n.º 17
0
		public CustomTableView(RectangleF bounds, UITableViewStyle style) : base(bounds, style)
		{
			ApplyDropShadow();
			
			// Necessary because we are using a transparent navigation bar setting
			// http://stackoverflow.com/questions/2339620/uitableview-add-content-offset-at-top
			ContentInset = new UIEdgeInsets(44, 0, 0, 0);
		}
Ejemplo n.º 18
0
		// UIEdgeInsetsInsetRect is missing from MonoTouch
		public RectangleF UIEdgeInsetsInsetRect(RectangleF rect, UIEdgeInsets insets)
		{
			return new RectangleF(
				rect.X + insets.Left, 						// 0 + 20 left 
				rect.Y + insets.Top,  						// 0 + 10 top
				rect.Width - (insets.Left + insets.Right),	// 100 - (20 left + 40 right)
				rect.Height	- (insets.Top + insets.Bottom)  // 200 - (10 top + 30 bottom)			  
			);
		}
Ejemplo n.º 19
0
		public SessionsCollectionViewFlowLayout() : base()
        {
			// Remove spacing between items on iPhone to stack two album arts in width
			float spacing = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone ? 0 : 8;
            ItemSize = new SizeF(160, 160);
			SectionInset = new UIEdgeInsets(spacing, spacing, spacing, spacing);
			HeaderReferenceSize = new SizeF(0, 52);
			MinimumInteritemSpacing = spacing;
			MinimumLineSpacing = spacing;
        }
Ejemplo n.º 20
0
 public TotalCell()
     : base(UITableViewCellStyle.Value1,"totalcell")
 {
     //TextLabel.Text = "Total";
     SeparatorInset = new UIEdgeInsets (0, 0, 0, 0);
     SelectionStyle = UITableViewCellSelectionStyle.None;
     TextColor = UIColor.White;
     BackgroundColor = Theme.Current.SideBarCellColor;
     DetailTextLabel.Font = UIFont.BoldSystemFontOfSize (30);
 }
		public StatusButton (IntPtr handle) : base (handle)
		{
			ContentEdgeInsets = new UIEdgeInsets(0, 38, 0, 0);
			AddSubview (statusImage = new UIImageView (new RectangleF (12, (Frame.Height - 16) / 2, 16, 16)));

			SetTitleColor (Theme.LabelColor, UIControlState.Normal);
			SetBackgroundImage (Theme.DropDown, UIControlState.Normal);

			TouchUpInside += OnTouchUpInside;
		}
Ejemplo n.º 22
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            MainImageView.Layer.MasksToBounds = true;
            MainImageView.Layer.CornerRadius = MainImageView.Frame.Height / 2f;
            ContentView.Opaque = true;

            SeparatorInset = new UIEdgeInsets(0, TitleLabel.Frame.Left, 0, 0);
            TitleLabel.TextColor = Theme.CurrentTheme.MainTitleColor;
            TimeLabel.TextColor = Theme.CurrentTheme.MainTextColor;
        }
Ejemplo n.º 23
0
 public CustomerPickerCell()
     : base(UITableViewCellStyle.Default,"contactsCell")
 {
     this.Frame = new System.Drawing.RectangleF (0, 0, 320, 60);
     TextLabel.Text = "Pick a Customer";
     TextLabel.TextAlignment = UITextAlignment.Center;
     TextLabel.TextColor = UIColor.White;
     TextLabel.Font = UIFont.BoldSystemFontOfSize (TextLabel.Font.PointSize);
     BackgroundColor = Color.LightBlue;//UIColor.FromRGB (69,70,69);// Theme.Current.SideBackgroundColor.ColorWithAlpha(.5f);
     ImageView.TintColor = UIColor.White;
     ImageView.Image = image.Value.ImageWithRenderingMode (UIImageRenderingMode.AlwaysTemplate);
     SeparatorInset = new UIEdgeInsets (0, 0, 0, 0);
 }
Ejemplo n.º 24
0
 public CustomViewCell(UIView child)
     : base(UITableViewCellStyle.Default, "CustomViewCell")
 {
     SelectionStyle = UITableViewCellSelectionStyle.None;
     ResizeChild = true;
     Padding = new UIEdgeInsets ();
     this.child = child;
     var frame = child.Frame;
     frame.Height = frame.Bottom;
     frame.Y = 0;
     Frame = frame;
     this.ContentView.AddSubview (child);
 }
Ejemplo n.º 25
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Caption.TextColor = Theme.CurrentTheme.MainTitleColor;
            Number.TextColor = Theme.CurrentTheme.MainTitleColor;
            AddSubview(new SeperatorIssues {Frame = new CGRect(65f, 5f, 1f, Frame.Height - 10f)});
            Image1.Image = Theme.CurrentTheme.IssueCellImage1;
            Image2.Image = Theme.CurrentTheme.IssueCellImage2;
            Image3.Image = Theme.CurrentTheme.IssueCellImage3;
            Image4.Image = Theme.CurrentTheme.IssueCellImage4;
            SeparatorInset = new UIEdgeInsets(0, 0, 0, 0);
        }
        public FUIShadowedButton(RectangleF frame, UIColor buttonColor, UIColor shadowColor, float shadowHeight = 3f, float cornerRadius = 6f)
            : base(frame)
        {

            _ButtonColor = buttonColor;
            _ShadowColor = shadowColor;
            _ShadowHeight = shadowHeight;
            _CornerRadius = cornerRadius;

            DefaultEdgeInsets = TitleEdgeInsets;
            UpdateEdgeInsets();
            ConfigureFlatButton();
        }
Ejemplo n.º 27
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            MainImageView.Layer.MasksToBounds = true;
            MainImageView.Layer.CornerRadius = MainImageView.Frame.Height / 2f;
            SeparatorInset = new UIEdgeInsets(0, TitleLabel.Frame.Left, 0, 0);

            TitleLabel.TextColor = Theme.CurrentTheme.MainTitleColor;
            TimeLabel.TextColor = UIColor.Gray;
            ContentLabel.TextColor = Theme.CurrentTheme.MainTextColor;
            DefaultContentConstraintSize = ContentConstraint.Constant;
        }
Ejemplo n.º 28
0
		public FlatButton (RectangleF frame):base(frame)
		{
			//Defaults
			this.defaultEdgeInsets = TitleEdgeInsets;
			//TODO: make custom fonts work
			TitleLabel.Font = UIFont.BoldSystemFontOfSize (16);
			SetTitleColor (FlatColors.Clouds, UIControlState.Normal);
			SetTitleColor (FlatColors.Clouds, UIControlState.Highlighted);
			CornerRadius = 6f;
			ShadowHeight = 3f;

			//Create button graphics
			ConfigureFlatButton ();
		}
        public ODRefreshControl(UIScrollView scrollView, UIActivityIndicatorView activity)
            : base(new RectangleF(0, -1 * (kTotalViewHeight + scrollView.ContentInset.Top), scrollView.Frame.Size.Width, kTotalViewHeight))
        {
            this.scrollView = scrollView;
            this.originalContentInset = this.scrollView.ContentInset;

            this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            this.scrollView.AddSubview(this);
            this.scrollView.AddObserver(this, new NSString("contentOffset"), NSKeyValueObservingOptions.New, IntPtr.Zero);
            this.scrollView.AddObserver(this, new NSString("contentInset"), NSKeyValueObservingOptions.New, IntPtr.Zero);

            if (activity == null)
                activity = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);
            this.activity = activity;
            this.activity.Center = new PointF((float)Math.Floor(this.Frame.Size.Width / 2), (float)Math.Floor(this.Frame.Size.Height / 2));
            this.activity.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
            this.activity.Alpha = 0;
            this.activity.StartAnimating();
            this.AddSubview(this.activity);

            _refreshing = false;
            _canRefresh = true;
            _ignoreInset = false;
            _ignoreOffset = false;
            _didSetInset = false;
            _hasSectionHeaders = false;
            TintColor = UIColor.FromRGBA(155 / 255, 162 / 255, 172 / 255, 1.0f);

            _shapeLayer = new CAShapeLayer();
            _shapeLayer.FillColor = TintColor.CGColor;
            _shapeLayer.StrokeColor = UIColor.DarkGray.ColorWithAlpha(0.5f).CGColor;
            _shapeLayer.LineWidth = 0.5f;
            _shapeLayer.ShadowColor = UIColor.Black.CGColor;
            _shapeLayer.ShadowOffset = new SizeF(0, 1);
            _shapeLayer.ShadowOpacity = 0.4f;
            _shapeLayer.ShadowRadius = 0.5f;
            this.Layer.AddSublayer(_shapeLayer);

            _arrowLayer = new CAShapeLayer();
            _arrowLayer.StrokeColor = UIColor.DarkGray.ColorWithAlpha(0.5f).CGColor;
            _arrowLayer.LineWidth = 0.5f;
            _arrowLayer.FillColor = UIColor.White.CGColor;
            _shapeLayer.AddSublayer(_arrowLayer);

            _highlightLayer = new CAShapeLayer();
            _highlightLayer.FillColor = UIColor.White.ColorWithAlpha(0.2f).CGColor;
            _shapeLayer.AddSublayer(_highlightLayer);
        }
Ejemplo n.º 30
0
		static OutgoingCell()
		{
			UIImage mask = UIImage.FromBundle ("MessageBubble");

			var cap = new UIEdgeInsets {
				Top = 17,
				Left = 21,
				Bottom = (float)17.5,
				Right = (float)26.5
			};

			normalBubbleImage = CreateColoredImage (Theme.Current.OutgoingBubbleColor, mask).CreateResizableImage (cap);

			var highlightedColor = Theme.Current.OutgoingBubbleColor;
			highlightedBubbleImage = CreateColoredImage (highlightedColor, mask).CreateResizableImage (cap);
		}
Ejemplo n.º 31
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Skip.SetTitle(Resources.Skip.ToUpper(), UIControlState.Normal);
            Next.SetTitle(Resources.Next.ToUpper(), UIControlState.Normal);
            Previous.SetTitle(Resources.Back.ToUpper(), UIControlState.Normal);

            preparePlaceholders();

            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                var navigationBarHeight = NavigationController.NavigationBar.Frame.Height;
                AdditionalSafeAreaInsets = new UIEdgeInsets(-navigationBarHeight, 0, 0, 0);
            }

            PageControl.Pages    = ViewModel.NumberOfPages;
            FirstPageLabel.Text  = Resources.OnboardingTrackPageCopy;
            SecondPageLabel.Text = Resources.OnboardingMostUsedPageCopy;
            ThirdPageLabel.Text  = Resources.OnboardingReportsPageCopy;

            Skip.Rx()
            .BindAction(ViewModel.SkipOnboarding)
            .DisposedBy(DisposeBag);

            Next.Rx()
            .BindAction(ViewModel.GoToNextPage)
            .DisposedBy(DisposeBag);

            Previous.Rx()
            .BindAction(ViewModel.GoToPreviousPage)
            .DisposedBy(DisposeBag);

            ScrollView.Rx()
            .DecelerationEnded()
            .Select(_ => (int)(ScrollView.ContentOffset.X / ScrollView.Frame.Width))
            .Subscribe(newPage => ViewModel?.ChangePage(newPage))
            .DisposedBy(DisposeBag);

            ViewModel.BackgroundColor
            .Select(color => color.ToNativeColor())
            .Subscribe(View.Rx().AnimatedBackgroundColor())
            .DisposedBy(DisposeBag);

            ViewModel.BorderColor
            .Select(color => color.ToNativeColor())
            .Subscribe(PhoneFrame.Rx().AnimatedBackgroundColor())
            .DisposedBy(DisposeBag);

            ViewModel.CurrentPage
            .Select(backgroundImageForPage)
            .Subscribe(image => BackgroundImage.Image = image)
            .DisposedBy(DisposeBag);

            ViewModel.IsLastPage
            .Invert()
            .Subscribe(Skip.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsFirstPage
            .Invert()
            .Subscribe(Previous.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsTrackPage
            .Subscribe(trackPagePlaceholder.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsReportPage
            .Subscribe(reportsPagePlaceholder.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsSummaryPage
            .Subscribe(mostUsedPagePlaceholder.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.CurrentPage
            .Subscribe(p => PageControl.CurrentPage = p)
            .DisposedBy(DisposeBag);

            ViewModel.CurrentPage
            .Subscribe(p =>
            {
                var scrollPoint = new CGPoint(ScrollView.Frame.Size.Width * p, 0);
                ScrollView.SetContentOffset(scrollPoint, true);
            })
            .DisposedBy(DisposeBag);
        }
Ejemplo n.º 32
0
        private void Initialize(bool baseProperties = true)
        {
            // add the background view
            {
                BackgroundImageView = new UIImageView();
                AddSubview(BackgroundImageView);
            }

            // add the main signature view
            {
                SignaturePadCanvas = new SignaturePadCanvasView();
                SignaturePadCanvas.StrokeCompleted += delegate
                {
                    OnSignatureStrokeCompleted();
                };
                SignaturePadCanvas.Cleared += delegate
                {
                    OnSignatureCleared();
                };
                AddSubview(SignaturePadCanvas);
            }

            // add the caption
            {
                Caption = new UILabel()
                {
                    BackgroundColor = UIColor.Clear,
                    TextAlignment   = UITextAlignment.Center,
                    Font            = UIFont.SystemFontOfSize(DefaultFontSize),
                    Text            = DefaultCaptionText,
                    TextColor       = SignaturePadDarkColor,
                };
                AddSubview(Caption);
            }

            // add the signature line
            {
                SignatureLine = new UIView()
                {
                    BackgroundColor = SignaturePadDarkColor,
                };
                SignatureLineWidth   = DefaultLineThickness;
                SignatureLineSpacing = DefaultNarrowSpacing;
                AddSubview(SignatureLine);
            }

            // add the prompt
            {
                SignaturePrompt = new UILabel()
                {
                    BackgroundColor = UIColor.Clear,
                    Font            = UIFont.BoldSystemFontOfSize(DefaultFontSize),
                    Text            = DefaultPromptText,
                    TextColor       = SignaturePadDarkColor,
                };
                AddSubview(SignaturePrompt);
            }

            // add the clear label
            {
                ClearLabel = UIButton.FromType(UIButtonType.Custom);
                ClearLabel.BackgroundColor = UIColor.Clear;
                ClearLabel.Font            = UIFont.BoldSystemFontOfSize(DefaultFontSize);
                ClearLabel.SetTitle(DefaultClearLabelText, UIControlState.Normal);
                ClearLabel.SetTitleColor(SignaturePadDarkColor, UIControlState.Normal);
                AddSubview(ClearLabel);

                // attach the "clear" command
                ClearLabel.TouchUpInside += delegate
                {
                    OnClearTapped();
                };
            }

            Padding = new UIEdgeInsets(DefaultWideSpacing, DefaultWideSpacing, DefaultNarrowSpacing, DefaultWideSpacing);

            // clear / initialize the view
            UpdateUi();
        }
Ejemplo n.º 33
0
 void UpdateContentEdge(UIButton button, UIEdgeInsets?delta = null)
 {
     _paddingDelta = delta ?? new UIEdgeInsets();
     UpdatePadding(button);
 }
Ejemplo n.º 34
0
        public UIButton ButtonForItemIndex(int index)
        {
            SIAlertItem item   = this._Items[index];
            UIButton    button = UIButton.FromType(UIButtonType.Custom);

            button.Tag = index;
            button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            button.TitleLabel.Font  = (item.Font != null && item.Font != this.ButtonFont) ? item.Font : this.ButtonFont;
            button.SetTitle(item.Title, UIControlState.Normal);
            UIImage normalImage      = null;
            UIImage highlightedImage = null;

            // both custom background images images must be present, otherwise we use the defaults
            if (item.BackgroundImageNormal == null || item.BackgroundImageHighlighted == null)
            {
                switch (item.Type)
                {
                case SIAlertViewButtonType.Cancel:
                    normalImage      = UIImage.FromBundle(@"Images/SIAlertView.bundle/button-cancel");
                    highlightedImage = UIImage.FromBundle(@"Images/SIAlertView.bundle/button-cancel-d");
                    button.SetTitleColor(UIColor.FromWhiteAlpha(0.3f, 1f), UIControlState.Normal);
                    button.SetTitleColor(UIColor.FromWhiteAlpha(0.3f, 1f), UIControlState.Highlighted);
                    break;

                case SIAlertViewButtonType.Destructive:
                    normalImage      = UIImage.FromBundle(@"Images/SIAlertView.bundle/button-destructive");
                    highlightedImage = UIImage.FromBundle(@"Images/SIAlertView.bundle/button-destructive-d");
                    button.SetTitleColor(UIColor.White, UIControlState.Normal);
                    button.SetTitleColor(UIColor.FromWhiteAlpha(1f, 0.8f), UIControlState.Highlighted);
                    break;

                case SIAlertViewButtonType.Default:
                default:
                    normalImage      = UIImage.FromBundle(@"Images/SIAlertView.bundle/button-default");
                    highlightedImage = UIImage.FromBundle(@"Images/SIAlertView.bundle/button-default-d");
                    button.SetTitleColor(UIColor.FromWhiteAlpha(0.4f, 1f), UIControlState.Normal);
                    button.SetTitleColor(UIColor.FromWhiteAlpha(0.4f, 0.8f), UIControlState.Highlighted);
                    break;
                }
            }
            else
            {
                normalImage      = item.BackgroundImageNormal;
                highlightedImage = item.BackgroundImageHighlighted;
            }

            // both images must be present, othrwise we'll fall back to the specified background color
            if (normalImage != null && highlightedImage != null)
            {
                float        hInset = (float)Math.Floor(normalImage.Size.Width / 2);
                float        vInset = (float)Math.Floor(normalImage.Size.Height / 2);
                UIEdgeInsets insets = new UIEdgeInsets(vInset, hInset, vInset, hInset);
                if (normalImage != null)
                {
                    normalImage = normalImage.CreateResizableImage(insets);
                    button.SetBackgroundImage(normalImage, UIControlState.Normal);
                }
                if (highlightedImage != null)
                {
                    highlightedImage = highlightedImage.CreateResizableImage(insets);
                    button.SetBackgroundImage(highlightedImage, UIControlState.Highlighted);
                }
            }
            else if (item.BackgroundColor != null)
            {
                button.BackgroundColor = item.BackgroundColor;
            }

            if (item.TextColorNormal != null)
            {
                button.SetTitleColor(item.TextColorNormal, UIControlState.Normal);
            }
            if (item.TextColorHIghlighted != null)
            {
                button.SetTitleColor(item.TextColorHIghlighted, UIControlState.Highlighted);
            }

            button.TouchUpInside += (o, s) => { ButtonAction(button); };

            return(button);
        }
Ejemplo n.º 35
0
        // http://bugzilla.xamarin.com/show_bug.cgi?id=1387
        public void Bug1387_UIEdgeInsets_ToString()
        {
            var insets = new UIEdgeInsets(1, 2, 3, 4);

            Assert.False(insets.ToString().Contains("UIEdgeInsets"));
        }
Ejemplo n.º 36
0
 public void SetVisibleCoordinates(CLLocationCoordinate2D[] coordinates, nuint count, UIEdgeInsets insets, bool animated)
 {
     SetVisibleCoordinates(GetPointer(coordinates), count, insets, animated);
 }
Ejemplo n.º 37
0
        public void FromString_Null()
        {
            var e = UIEdgeInsets.FromString(null);

            Assert.That(e, Is.EqualTo(UIEdgeInsets.Zero), "roundtrip");
        }
Ejemplo n.º 38
0
        private void CreateView()
        {
            if (Control == null && !Element.IsVisible)
            {
                return;
            }

            if (Control != null && !Element.IsVisible)
            {
                Control.Hidden = true;
                return;
            }
            Element.OnScrollRequested += Element_OnScrollRequested;
            Control?.DataSource?.Dispose();
            Control?.CollectionViewLayout?.Dispose();
            Control?.Dispose();

            var sectionInset = new UIEdgeInsets(
                (nfloat)Element.CollectionPadding.Top,
                (nfloat)Element.CollectionPadding.Left,
                (nfloat)Element.CollectionPadding.Bottom,
                (nfloat)Element.CollectionPadding.Right);

            var layout = Element.ListLayout == HorizontalListViewLayout.Grid
                ? new UICollectionViewFlowLayout
            {
                ScrollDirection         = UICollectionViewScrollDirection.Vertical,
                ItemSize                = new CGSize(Element.ItemWidth, Element.ItemHeight),
                MinimumInteritemSpacing = Element.ItemSpacing,
                MinimumLineSpacing      = Element.ItemSpacing,
                SectionInset            = sectionInset,
            }
                : new SnappingCollectionViewLayout(Element.SnapStyle)
            {
                ScrollDirection         = UICollectionViewScrollDirection.Horizontal,
                ItemSize                = new CGSize(Element.ItemWidth, Element.ItemHeight),
                MinimumInteritemSpacing = Element.ItemSpacing,
                MinimumLineSpacing      = Element.ItemSpacing,
                SectionInset            = sectionInset,
            };

            var rect           = new CGRect(0, 0, Element.ItemWidth, Element.ItemHeight);
            var collectionView = new UICollectionView(rect, layout)
            {
                DecelerationRate = UIScrollView.DecelerationRateFast,
                BackgroundColor  = Element?.BackgroundColor.ToUIColor(),
                ShowsHorizontalScrollIndicator = false,
                ContentInset = new UIEdgeInsets(0, 0, 0, 0),
            };

            // Otherwise the UICollectionView doesn't seem to take enough space
            Element.HeightRequest = Element.ItemHeight
                                    + Element.CollectionPadding.VerticalThickness
                                    + Element.Margin.VerticalThickness;

            SetNativeControl(collectionView);
            UpdateItemsSource();

            if (Element.SnapStyle == SnapStyle.Center)
            {
                Control.DraggingEnded     += OnDraggingEnded;
                Control.DecelerationEnded += OnDecelerationEnded;
            }

            Control.Scrolled             += OnScrolled;
            Control.ScrollAnimationEnded += OnStopScrolling;
            Control.DecelerationEnded    += OnStopScrolling;

            if (Element.EnableDragAndDrop)
            {
                EnableDragAndDrop();
            }

            ScrollToCurrentItem();
            ProcessDisableScroll();
        }
Ejemplo n.º 39
0
 public InputTextField(IntPtr handle)
     : base(handle)
 {
     EdgeInsets = UIEdgeInsets.Zero;
 }
Ejemplo n.º 40
0
        public override void DrawText(CGRect rect)
        {
            var insets = new UIEdgeInsets(TopInset, LeftInset, BottomInset, RightInset);

            base.DrawText(insets.InsetRect(rect));
        }
Ejemplo n.º 41
0
 public override void LayoutSubviews()
 {
     base.LayoutSubviews();
     SeparatorInset = new UIEdgeInsets(0, HiddenSeperator ? Bounds.Width : 0, 0, 0);
 }
Ejemplo n.º 42
0
 public static EdgeInsets ToEdgeInsets(this UIEdgeInsets p)
 {
     return(new EdgeInsets((float)p.Top, (float)p.Left, (float)p.Bottom, (float)p.Right));
 }
Ejemplo n.º 43
0
        public ToolbarView()
        {
            BackgroundColor = new UIColor(1, 0, 0, 0);

            List <String> names = new List <String>()
            {
                "Combat", "Monsters", "Feats", "Spells", "Rules", "Treasure"
            };
            List <String> images = new List <String>()
            {
                "sword", "monster", "star", "scroll", "book", "treasure"
            };

            float pos         = 0;
            float buttonWidth = 110;
            float buttonGap   = -1;
            int   i           = 0;

            foreach (string s in names)
            {
                GradientButton b = new GradientButton();
                b.Frame = (new CGRect(pos, 0, buttonWidth, 50));
                b.SetImage(UIExtensions.GetSmallIcon(images[i]), UIControlState.Normal);

                b.Border      = 1;
                b.CornerRadii = new float[] { 4, 16, 0, 0 };

                b.SetTitle(s, UIControlState.Normal);
                UIEdgeInsets si = b.ImageEdgeInsets;
                si.Right         += 10;
                b.ImageEdgeInsets = si;

                pos += buttonWidth + buttonGap;
                buttons.Add(b);
                b.Tag            = i;
                b.TouchUpInside += HandleBTouchUpInside;
                i++;


                AddSubview(b);
            }

            clickedButton          = buttons[0];
            clickedButton.Gradient = new GradientHelper(CMUIColors.PrimaryColorDarker, CMUIColors.PrimaryColorMedium);

            _SettingsButton = new GradientButton();
            _SettingsButton.SetImage(UIImage.FromFile("Images/settings.png"), UIControlState.Normal);
            //_SettingsButton.Border = 0;
            //_SettingsButton.BackgroundColor = UIColor.Clear;
            //_SettingsButton.Gradient = new GradientHelper(0x00000000.UIColor());
            _SettingsButton.CornerRadius   = 0;
            _SettingsButton.TouchUpInside += SettingsButtonClicked;
            _SettingsButton.Frame          = new CGRect(Bounds.Width - 64, (Bounds.Height - 48.0f) / 2.0f, 48f, 48f);

            AddSubview(_SettingsButton);

            settingsPopover = new ButtonStringPopover(_SettingsButton);
            var pi = new ButtonStringPopoverItem()
            {
                Text = "Import"
            };

            settingsPopover.Items.Add(pi);
            pi = new ButtonStringPopoverItem {
                Text = "Export"
            };
            settingsPopover.Items.Add(pi);
            settingsPopover.Items.Add(new ButtonStringPopoverItem());
            serverItem = new ButtonStringPopoverItem {
                Text = "Run Local Service"
            };
            SetLocalServiceIcon();
            settingsPopover.Items.Add(serverItem);
            pi = new ButtonStringPopoverItem {
                Text = "Local Service Port"
            };
            settingsPopover.Items.Add(pi);
            pi = new ButtonStringPopoverItem {
                Text = "Local Service Passcode"
            };
            settingsPopover.Items.Add(pi);
            settingsPopover.ItemClicked += (sender, eee) =>
            {
                switch (eee.Index)
                {
                case 0:

                    Import();

                    break;

                case 1:

                    Export();

                    break;

                case 2:
                    LocalServiceClicked();
                    break;

                case 4:
                    LocalServicePortClicked();
                    break;

                case 5:
                    LocalServicePasscodeClicked();
                    break;
                }
            };


            _AboutButton = new GradientButton();
            _AboutButton.SetImage(UIImage.FromFile("Images/External/info.png"), UIControlState.Normal);
            // _AboutButton.Border = 0;
            //_AboutButton.BackgroundColor = UIColor.Clear;
            //_AboutButton.Gradient = new GradientHelper(0x00000000.UIColor());
            _AboutButton.CornerRadius   = 0;
            _AboutButton.TouchUpInside += AboutButtonClicked;
            _AboutButton.Frame          = new CGRect(Bounds.Width - 23, (Bounds.Height - 48.0f) / 2.0f, 48f, 48f);

            Add(_AboutButton);
            BackgroundColor = UIColor.Black;

            MobileSettings.Instance.PropertyChanged += MobileSettingsPropertyChanged;
        }
Ejemplo n.º 44
0
        public virtual UIEdgeInsets GetInsetForSection(UICollectionView collectionView, UICollectionViewLayout layout, Int32 section)
        {
            var sectionInsets = new UIEdgeInsets(5, 5, 5, 5);

            return(sectionInsets);
        }
        public static void LeftAlignFrame(this UICollectionViewLayoutAttributes attributes, UIEdgeInsets sectionInsets)
        {
            CGRect frame = attributes.Frame;

            frame.X          = sectionInsets.Left;
            attributes.Frame = frame;
        }
Ejemplo n.º 46
0
        protected virtual void KeyboardWillShowNotification(NSNotification notification)
        {
            UIView activeView = KeyboardGetActiveView();

            if (activeView == null)
            {
                return;
            }

            CGRect keyboardBounds = UIKeyboard.FrameBeginFromNotification(notification);

            if (scrollType == ScrollType.SCROLLVIEW)
            {
                UIScrollView scrollView = activeView.FindSuperviewOfType(parentView, typeof(UIScrollView)) as UIScrollView;
                if (scrollView == null)
                {
                    return;
                }

                nfloat keyboardHeight;
                if (keyboardBounds.Size.Height > keyboardBounds.Size.Width)
                {
                    keyboardHeight = keyboardBounds.Size.Width;
                }
                else
                {
                    keyboardHeight = keyboardBounds.Size.Height;
                }

                UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, keyboardHeight, 0.0f);
                scrollView.ContentInset          = contentInsets;
                scrollView.ScrollIndicatorInsets = contentInsets;

                // If activeField is hidden by keyboard, scroll it so it's visible
                CGRect viewRectAboveKeyboard = new CGRect(parentView.Frame.Location, new CGSize(parentView.Frame.Width, parentView.Frame.Size.Height - keyboardHeight));

                // activeFieldAbsoluteFrame is relative to this.View so does not include any scrollView.ContentOffset
                CGRect activeFieldAbsoluteFrame = activeView.Superview.ConvertRectToView(activeView.Frame, parentView);

                // Check if the activeField will be partially or entirely covered by the keyboard
                if (!viewRectAboveKeyboard.Contains(activeFieldAbsoluteFrame))
                {
                    // Scroll to the activeField Y position + activeField.Height + current scrollView.ContentOffset.Y - the keyboard Height
                    CGPoint scrollPoint = new CGPoint(0.0f, activeFieldAbsoluteFrame.Location.Y + activeFieldAbsoluteFrame.Height + scrollView.ContentOffset.Y - viewRectAboveKeyboard.Height);
                    scrollView.SetContentOffset(scrollPoint, true);
                }
            }
            else if (scrollType == ScrollType.TABLEVIEW)
            {
                UITableView tableView = activeView.FindSuperviewOfType(parentView, typeof(UITableView)) as UITableView;
                if (tableView == null)
                {
                    return;
                }

                nfloat keyboardHeight;
                if (keyboardBounds.Size.Height > keyboardBounds.Size.Width)
                {
                    keyboardHeight = keyboardBounds.Size.Width;
                }
                else
                {
                    keyboardHeight = keyboardBounds.Size.Height;
                }

                UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, keyboardHeight, 0.0f);
                tableView.ContentInset          = contentInsets;
                tableView.ScrollIndicatorInsets = contentInsets;

                // If activeField is hidden by keyboard, scroll it so it's visible
                CGRect viewRectAboveKeyboard = new CGRect(parentView.Frame.Location, new CGSize(parentView.Frame.Width, parentView.Frame.Size.Height - keyboardHeight));

                // activeFieldAbsoluteFrame is relative to this.View so does not include any tableView.ContentOffset
                CGRect activeFieldAbsoluteFrame = activeView.Superview.ConvertRectToView(activeView.Frame, parentView);

                // Check if the activeField will be partially or entirely covered by the keyboard
                if (!viewRectAboveKeyboard.Contains(activeFieldAbsoluteFrame))
                {
                    // Scroll to the activeField Y position + activeField.Height + current tableView.ContentOffset.Y - the keyboard Height
                    CGPoint scrollPoint = new CGPoint(0.0f, activeFieldAbsoluteFrame.Location.Y + activeFieldAbsoluteFrame.Height + tableView.ContentOffset.Y - viewRectAboveKeyboard.Height);
                    tableView.SetContentOffset(scrollPoint, true);
                }
            }
            else if (scrollType == ScrollType.TEXTVIEW)
            {
                UITextView textView = activeView as UITextView;
                if (textView == null)
                {
                    return;
                }

                nfloat keyboardHeight;
                if (keyboardBounds.Size.Height > keyboardBounds.Size.Width)
                {
                    keyboardHeight = keyboardBounds.Size.Width;
                }
                else
                {
                    keyboardHeight = keyboardBounds.Size.Height;
                }

                UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, keyboardHeight, 0.0f);
                textView.ContentInset          = contentInsets;
                textView.ScrollIndicatorInsets = contentInsets;

                // If activeField is hidden by keyboard, scroll it so it's visible
                CGRect viewRectAboveKeyboard = new CGRect(parentView.Frame.Location, new CGSize(parentView.Frame.Width, parentView.Frame.Size.Height - keyboardHeight));

                // activeFieldAbsoluteFrame is relative to this.View so does not include any tableView.ContentOffset
                CGRect activeFieldAbsoluteFrame = activeView.Superview.ConvertRectToView(activeView.Frame, parentView);

                // Check if the activeField will be partially or entirely covered by the keyboard
                if (!viewRectAboveKeyboard.Contains(activeFieldAbsoluteFrame))
                {
                    // Scroll to the activeField Y position + activeField.Height + current tableView.ContentOffset.Y - the keyboard Height
                    CGPoint scrollPoint = new CGPoint(0.0f, activeFieldAbsoluteFrame.Location.Y + activeFieldAbsoluteFrame.Height + textView.ContentOffset.Y - viewRectAboveKeyboard.Height);
                    textView.SetContentOffset(scrollPoint, true);
                }
            }

            if (KeyboardWillShowEvent != null)
            {
                KeyboardWillShowEvent(keyboardBounds);
            }
        }
Ejemplo n.º 47
0
        public MainTabBarController()
        {
            TabBar.Translucent = false;
            TabBar.TintColor   = Constants.R231G72B0;

            var feedTab = new InteractivePopNavigationController(new FeedViewController());

            feedTab.TabBarItem = new UITabBarItem(null, UIImage.FromBundle("ic_home"), 0);

            var browseTab = new InteractivePopNavigationController(new PreSearchViewController());

            browseTab.TabBarItem = new UITabBarItem(null, UIImage.FromBundle("ic_browse"), 1);

            var photoTab = new UIViewController()
            {
            };

            photoTab.TabBarItem = new UITabBarItem(null, null, 2);

            var profileTab = new InteractivePopNavigationController(new ProfileViewController());

            profileTab.TabBarItem = new UITabBarItem(null, null, 3);

            ViewControllers = new UIViewController[] {
                feedTab,
                browseTab,
                photoTab,
                profileTab
            };

            var insets = new UIEdgeInsets(5, 0, -5, 0);

            foreach (UIViewController item in ViewControllers)
            {
                if (item is UINavigationController navController)
                {
                    navController.NavigationBar.Translucent = false;
                }
                item.TabBarItem.ImageInsets = insets;
            }

            var createPhotoImage = new UIImageView(new CGRect(0, -2, TabBar.Frame.Width / 4, TabBar.Frame.Height));

            createPhotoImage.Image       = UIImage.FromBundle("ic_create");
            createPhotoImage.ContentMode = UIViewContentMode.Center;
            TabBar.Subviews[2].AddSubview(createPhotoImage);

            _avatar     = new UIImageView();
            _powerFrame = new CircleFrame(_avatar, new CGRect(TabBar.Frame.Width / 4 / 2 - 16, TabBar.Frame.Height / 2 - 17, 28, 28));

            _powerFrame.UserInteractionEnabled = false;
            _avatar.UserInteractionEnabled     = false;
            _avatar.Frame = new CGRect(3, 3, 22, 22);
            _avatar.Layer.CornerRadius = _avatar.Frame.Width / 2;
            _avatar.ClipsToBounds      = true;
            _avatar.Image       = UIImage.FromBundle("ic_noavatar");
            _avatar.ContentMode = UIViewContentMode.ScaleAspectFill;

            _presenter = new UserProfilePresenter()
            {
                UserName = AppSettings.User.Login
            };
            switch (AppDelegate.MainChain)
            {
            case KnownChains.Golos:
                _presenter.SetClient(AppDelegate.GolosClient);
                break;

            case KnownChains.Steem:
                _presenter.SetClient(AppDelegate.SteemClient);
                break;
            }

            TabBar.Subviews[3].AddSubview(_powerFrame);
            InitializePowerFrame();
            if (!AppSettings.AppInfo.GetModel().Contains("Simulator"))
            {
                InitPushes();
            }
        }
Ejemplo n.º 48
0
 public UIEdgeInsets GetWidgetMarginInsets(UIEdgeInsets defaultMarginInsets)
 {
     Console.WriteLine("GetWidgetMarginInsets");
     return(new UIEdgeInsets(defaultMarginInsets.Top, 27, defaultMarginInsets.Bottom, defaultMarginInsets.Right));
 }
Ejemplo n.º 49
0
 public RepositoryCellView(IntPtr handle)
     : base(handle)
 {
     SeparatorInset = new UIEdgeInsets(0, 56f, 0, 0);
 }
Ejemplo n.º 50
0
        public override void DrawText(RectangleF rect)
        {
            var insets = new UIEdgeInsets(0, 2, 0, 2);

            base.DrawText(insets.InsetRect(rect));
        }
Ejemplo n.º 51
0
        void UpdateEdgeInsets()
        {
            if (_disposed || _renderer == null || _element == null)
            {
                return;
            }

            var control = Control;

            if (control == null)
            {
                return;
            }

            EnsureDefaultInsets();

            _paddingAdjustments = new UIEdgeInsets();

            var imageInsets = new UIEdgeInsets();
            var titleInsets = new UIEdgeInsets();

            // adjust for the border
            if (_borderAdjustsPadding && _element is IBorderElement borderElement && borderElement.IsBorderWidthSet() && borderElement.BorderWidth != borderElement.BorderWidthDefaultValue)
            {
                var width = (nfloat)_element.BorderWidth;
                _paddingAdjustments.Top    += width;
                _paddingAdjustments.Bottom += width;
                _paddingAdjustments.Left   += width;
                _paddingAdjustments.Right  += width;
            }

            var layout = _element.ContentLayout;

            var spacing     = (nfloat)layout.Spacing;
            var halfSpacing = spacing / 2;

            var image = control.CurrentImage;

            if (image != null && !string.IsNullOrEmpty(control.CurrentTitle))
            {
                // TODO: Do not use the title label as it is not yet updated and
                //       if we move the image, then we technically have more
                //       space and will require a new layout pass.

                var title =
                    control.CurrentAttributedTitle ??
                    new NSAttributedString(control.CurrentTitle, new UIStringAttributes {
                    Font = control.TitleLabel.Font
                });
                var titleRect = title.GetBoundingRect(
                    control.Bounds.Size,
                    NSStringDrawingOptions.UsesLineFragmentOrigin | NSStringDrawingOptions.UsesFontLeading,
                    null);

                var titleWidth  = titleRect.Width;
                var titleHeight = titleRect.Height;
                var imageWidth  = image.Size.Width;
                var imageHeight = image.Size.Height;

                // adjust the padding for the spacing
                if (layout.IsHorizontal())
                {
                    var adjustment = _spacingAdjustsPadding ? halfSpacing * 2 : halfSpacing;
                    _paddingAdjustments.Left  += adjustment;
                    _paddingAdjustments.Right += adjustment;
                }
                else
                {
                    var adjustment = _spacingAdjustsPadding ? halfSpacing * 2 : halfSpacing;

                    _paddingAdjustments.Top    += adjustment;
                    _paddingAdjustments.Bottom += adjustment;
                }

                // move the images according to the layout
                if (layout.Position == Button.ButtonContentLayout.ImagePosition.Left)
                {
                    // add a bit of spacing
                    imageInsets.Left  -= halfSpacing;
                    imageInsets.Right += halfSpacing;
                    titleInsets.Left  += halfSpacing;
                    titleInsets.Right -= halfSpacing;
                }
                else if (layout.Position == Button.ButtonContentLayout.ImagePosition.Right)
                {
                    // swap the elements and add spacing
                    imageInsets.Left  += titleWidth + halfSpacing;
                    imageInsets.Right -= titleWidth + halfSpacing;
                    titleInsets.Left  -= imageWidth + halfSpacing;
                    titleInsets.Right += imageWidth + halfSpacing;
                }
                else
                {
                    // we will move the image and title vertically
                    var imageVertical = (titleHeight / 2) + halfSpacing;
                    var titleVertical = (imageHeight / 2) + halfSpacing;

                    // the width will be different now that the image is no longer next to the text
                    nfloat horizontalAdjustment = 0;
                    if (_collapseHorizontalPadding)
                    {
                        horizontalAdjustment = (nfloat)(titleWidth + imageWidth - Math.Max(titleWidth, imageWidth)) / 2;
                    }
                    _paddingAdjustments.Left  -= horizontalAdjustment;
                    _paddingAdjustments.Right -= horizontalAdjustment;

                    // the height will also be different
                    var verticalAdjustment = (nfloat)Math.Min(imageVertical, titleVertical);
                    _paddingAdjustments.Top    += verticalAdjustment;
                    _paddingAdjustments.Bottom += verticalAdjustment;

                    // if the image is at the bottom, swap the direction
                    if (layout.Position == Button.ButtonContentLayout.ImagePosition.Bottom)
                    {
                        imageVertical = -imageVertical;
                        titleVertical = -titleVertical;
                    }

                    // move the image and title vertically
                    imageInsets.Top    -= imageVertical;
                    imageInsets.Bottom += imageVertical;
                    titleInsets.Top    += titleVertical;
                    titleInsets.Bottom -= titleVertical;

                    // center the elements horizontally
                    var imageHorizontal = titleWidth / 2;
                    var titleHorizontal = imageWidth / 2;
                    imageInsets.Left  += imageHorizontal;
                    imageInsets.Right -= imageHorizontal;
                    titleInsets.Left  -= titleHorizontal;
                    titleInsets.Right += titleHorizontal;
                }
            }

            UpdatePadding();
            control.ImageEdgeInsets = imageInsets;
            control.TitleEdgeInsets = titleInsets;
        }
Ejemplo n.º 52
0
        public static void UpdateContentLayout(this UIButton platformButton, Button button)
        {
            if (platformButton.Bounds.Width == 0)
            {
                return;
            }

            var imageInsets = new UIEdgeInsets();
            var titleInsets = new UIEdgeInsets();

            var layout  = button.ContentLayout;
            var spacing = (nfloat)layout.Spacing;

            var image = platformButton.CurrentImage;


            // if the image is too large then we just position at the edge of the button
            // depending on the position the user has picked
            // This makes the behavior consistent with android
            var contentMode = UIViewContentMode.Center;

            if (image != null && !string.IsNullOrEmpty(platformButton.CurrentTitle))
            {
                // TODO: Do not use the title label as it is not yet updated and
                //       if we move the image, then we technically have more
                //       space and will require a new layout pass.

                var titleRect    = platformButton.GetTitleBoundingRect();
                var titleWidth   = titleRect.Width;
                var imageWidth   = image.Size.Width;
                var imageHeight  = image.Size.Height;
                var buttonWidth  = platformButton.Bounds.Width;
                var buttonHeight = platformButton.Bounds.Height;

                // These are just used to shift the image and title to center
                // Which makes the later math easier to follow
                imageInsets.Left  += titleWidth / 2;
                imageInsets.Right -= titleWidth / 2;
                titleInsets.Left  -= imageWidth / 2;
                titleInsets.Right += imageWidth / 2;

                if (layout.Position == ButtonContentLayout.ImagePosition.Top)
                {
                    if (imageHeight > buttonHeight)
                    {
                        contentMode = UIViewContentMode.Top;
                    }
                    else
                    {
                        imageInsets.Top    -= (buttonHeight - imageHeight) / 2;
                        imageInsets.Bottom += (buttonHeight - imageHeight) / 2;

                        titleInsets.Top    += (imageHeight / 2 + spacing);
                        titleInsets.Bottom -= imageHeight / 2;
                    }
                }
                else if (layout.Position == ButtonContentLayout.ImagePosition.Bottom)
                {
                    if (imageHeight > buttonHeight)
                    {
                        contentMode = UIViewContentMode.Bottom;
                    }
                    else
                    {
                        imageInsets.Top    += (buttonHeight - imageHeight) / 2;
                        imageInsets.Bottom -= (buttonHeight - imageHeight) / 2;
                    }

                    titleInsets.Top    -= (imageHeight / 2 + spacing);
                    titleInsets.Bottom += imageHeight / 2;
                }
                else if (layout.Position == ButtonContentLayout.ImagePosition.Left)
                {
                    if (imageWidth > buttonWidth)
                    {
                        contentMode = UIViewContentMode.Left;
                    }
                    else
                    {
                        imageInsets.Left  -= (buttonWidth - imageWidth) / 2;
                        imageInsets.Right += (buttonWidth - imageWidth) / 2;
                    }

                    titleInsets.Left  += (imageWidth / 2);
                    titleInsets.Right -= (imageWidth / 2 + spacing);
                }
                else if (layout.Position == ButtonContentLayout.ImagePosition.Right)
                {
                    if (imageWidth > buttonWidth)
                    {
                        contentMode = UIViewContentMode.Right;
                    }
                    else
                    {
                        imageInsets.Left  += (buttonWidth - imageWidth) / 2;
                        imageInsets.Right -= (buttonWidth - imageWidth) / 2;
                    }

                    titleInsets.Left  -= (imageWidth / 2 + spacing);
                    titleInsets.Right += (imageWidth / 2);
                }
            }

            platformButton.ImageView.ContentMode = contentMode;

            // This is used to match the behavior between platforms.
            // If the image is too big then we just hide the label because
            // the image is pushing the title out of the visible view.
            // We can't use insets because then the title shows up outside the
            // bounds of the UIButton. We could set the UIButton to clip bounds
            // but that feels like it might cause confusing side effects
            if (contentMode == UIViewContentMode.Center)
            {
                platformButton.TitleLabel.Layer.Hidden = false;
            }
            else
            {
                platformButton.TitleLabel.Layer.Hidden = true;
            }

            platformButton.UpdatePadding(button);

#pragma warning disable CA1416 // TODO: [UnsupportedOSPlatform("ios15.0")]
            if (platformButton.ImageEdgeInsets != imageInsets ||
                platformButton.TitleEdgeInsets != titleInsets)
            {
                platformButton.ImageEdgeInsets = imageInsets;
                platformButton.TitleEdgeInsets = titleInsets;
                platformButton.Superview?.SetNeedsLayout();
            }
#pragma warning restore CA1416
        }
Ejemplo n.º 53
0
        public void Update(UITableView tableView, Cell cell, UITableViewCell nativeCell)
        {
            var parentListView = cell.RealParent as ListView;
            var recycling      = parentListView != null &&
                                 ((parentListView.CachingStrategy & ListViewCachingStrategy.RecycleElement) != 0);

            if (_cell != cell && recycling)
            {
                if (_cell != null)
                {
                    ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged;
                }

                ((INotifyCollectionChanged)cell.ContextActions).CollectionChanged += OnContextItemsChanged;
            }

            var height = Frame.Height + (parentListView != null && parentListView.SeparatorVisibility == SeparatorVisibility.None ? 0.5f : 0f);
            var width  = ContentView.Frame.Width;

            nativeCell.Frame = new RectangleF(0, 0, width, height);
            nativeCell.SetNeedsLayout();

            var handler = new PropertyChangedEventHandler(OnMenuItemPropertyChanged);

            _tableView = tableView;

            if (_cell != null)
            {
                if (!recycling)
                {
                    _cell.PropertyChanged -= OnCellPropertyChanged;
                }
                if (_menuItems.Count > 0)
                {
                    if (!recycling)
                    {
                        ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged;
                    }

                    foreach (var item in _menuItems)
                    {
                        item.PropertyChanged -= handler;
                    }
                }

                _menuItems.Clear();
            }

            _menuItems.AddRange(cell.ContextActions);

            _cell = cell;
            if (!recycling)
            {
                cell.PropertyChanged += OnCellPropertyChanged;
                ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged += OnContextItemsChanged;
            }

            var isOpen = false;

            if (_scroller == null)
            {
                _scroller = new UIScrollView(new RectangleF(0, 0, width, height));
                _scroller.ScrollsToTop = false;
                _scroller.ShowsHorizontalScrollIndicator = false;

                _scroller.PreservesSuperviewLayoutMargins = true;

                ContentView.AddSubview(_scroller);
            }
            else
            {
                _scroller.Frame = new RectangleF(0, 0, width, height);
                isOpen          = ScrollDelegate.IsOpen;

                for (var i = 0; i < _buttons.Count; i++)
                {
                    var b = _buttons[i];
                    b.RemoveFromSuperview();
                    b.Dispose();
                }

                _buttons.Clear();

                ScrollDelegate.Unhook(_scroller);
                ScrollDelegate.Dispose();
            }

            if (ContentCell != nativeCell)
            {
                if (ContentCell != null)
                {
                    ContentCell.RemoveFromSuperview();
                    ContentCell = null;
                }

                ContentCell = nativeCell;

                //Hack: if we have a ImageCell the insets are slightly different,
                //the inset numbers user below were taken using the Reveal app from the default cells
                if ((ContentCell as CellTableViewCell)?.Cell is ImageCell)
                {
                    nfloat imageCellInsetLeft  = 57;
                    nfloat imageCellInsetRight = 0;
                    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        imageCellInsetLeft  = 89;
                        imageCellInsetRight = imageCellInsetLeft / 2;
                    }
                    SeparatorInset = new UIEdgeInsets(0, imageCellInsetLeft, 0, imageCellInsetRight);
                }

                _scroller.AddSubview(nativeCell);
            }

            SetupButtons(width, height);

            UIView container = null;

            var totalWidth = width;

            for (var i = _buttons.Count - 1; i >= 0; i--)
            {
                var b = _buttons[i];
                totalWidth += b.Frame.Width;
                _scroller.AddSubview(b);
            }

            _scroller.Delegate    = new ContextScrollViewDelegate(container, _buttons, isOpen);
            _scroller.ContentSize = new SizeF(totalWidth, height);

            if (isOpen)
            {
                _scroller.SetContentOffset(new PointF(ScrollDelegate.ButtonsWidth, 0), false);
            }
            else
            {
                _scroller.SetContentOffset(new PointF(0, 0), false);
            }

            if (ContentCell != null)
            {
                SelectionStyle = ContentCell.SelectionStyle;
            }
        }
Ejemplo n.º 54
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            preparePlaceholders();

            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                var navigationBarHeight = NavigationController.NavigationBar.Frame.Height;
                AdditionalSafeAreaInsets = new UIEdgeInsets(-navigationBarHeight, 0, 0, 0);
            }

            PageControl.Pages    = ViewModel.NumberOfPages;
            FirstPageLabel.Text  = Resources.OnboardingTrackPageCopy;
            SecondPageLabel.Text = Resources.OnboardingMostUsedPageCopy;
            ThirdPageLabel.Text  = Resources.OnboardingReportsPageCopy;

            var visibilityConverter         = new MvxVisibilityValueConverter();
            var invertedVisibilityConverter = new MvxInvertedVisibilityValueConverter();
            var colorConverter = new MvxNativeColorValueConverter();
            var bindingSet     = this.CreateBindingSet <OnboardingViewController, OnboardingViewModel>();

            var pagedBackgroundImageColorConverter = new PaginationValueConverter <UIImage>(new[]
            {
                UIImage.FromBundle("bgNoiseBlue"),
                UIImage.FromBundle("bgNoisePurple"),
                UIImage.FromBundle("bgNoiseYellow")
            });

            //Commands
            bindingSet.Bind(Skip).To(vm => vm.SkipCommand);
            bindingSet.Bind(Next).To(vm => vm.NextCommand);
            bindingSet.Bind(Previous).To(vm => vm.PreviousCommand);

            //Color
            bindingSet.Bind(View)
            .For(v => v.BindAnimatedBackground())
            .To(vm => vm.BackgroundColor)
            .WithConversion(colorConverter);

            bindingSet.Bind(PhoneFrame)
            .For(v => v.BindAnimatedBackground())
            .To(vm => vm.BorderColor)
            .WithConversion(colorConverter);

            //Noise image
            bindingSet.Bind(BackgroundImage)
            .For(v => v.BindAnimatedImage())
            .To(vm => vm.CurrentPage)
            .WithConversion(pagedBackgroundImageColorConverter);

            //Visibility
            bindingSet.Bind(Skip)
            .For(v => v.BindVisibility())
            .To(vm => vm.IsLastPage)
            .WithConversion(invertedVisibilityConverter);

            bindingSet.Bind(Previous)
            .For(v => v.BindVisibility())
            .To(vm => vm.IsFirstPage)
            .WithConversion(invertedVisibilityConverter);

            bindingSet.Bind(trackPagePlaceholder)
            .For(v => v.BindVisibility())
            .To(vm => vm.IsTrackPage)
            .WithConversion(visibilityConverter);

            bindingSet.Bind(mostUsedPagePlaceholder)
            .For(v => v.BindVisibility())
            .To(vm => vm.IsMostUsedPage)
            .WithConversion(visibilityConverter);

            bindingSet.Bind(reportsPagePlaceholder)
            .For(v => v.BindVisibility())
            .To(vm => vm.IsSummaryPage)
            .WithConversion(visibilityConverter);


            //Current Page
            bindingSet.Bind(ScrollView)
            .For(v => v.BindAnimatedCurrentPage())
            .To(vm => vm.CurrentPage);

            bindingSet.Bind(PageControl)
            .For(v => v.CurrentPage)
            .To(vm => vm.CurrentPage);

            bindingSet.Apply();
        }
Ejemplo n.º 55
0
 public LabelControlRenderer()
 {
     m_padding = new UIEdgeInsets();
 }