private static UIView GetNestedStackContainer(string title, UIView stackView)
        {
            var view = new RoundedView {
                BackgroundColor = UIColor.LightGray
            };

            view.Layer.BorderColor = UIColor.Gray.CGColor;
            view.HeightAnchor.ConstraintEqualTo(110).Active = true;

            var label = new UILabel
            {
                Text = title,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            view.Add(label);
            view.Add(stackView);

            NSLayoutConstraint.ActivateConstraints(new []
            {
                label.LeadingAnchor.ConstraintEqualTo(view.LeadingAnchor, 10),
                label.TrailingAnchor.ConstraintEqualTo(view.TrailingAnchor, -10),
                label.TopAnchor.ConstraintEqualTo(view.TopAnchor, 8),
                label.HeightAnchor.ConstraintEqualTo(22),

                stackView.LeadingAnchor.ConstraintEqualTo(label.LeadingAnchor),
                stackView.TrailingAnchor.ConstraintEqualTo(label.TrailingAnchor),
                stackView.TopAnchor.ConstraintEqualTo(label.BottomAnchor, 5),
                stackView.BottomAnchor.ConstraintEqualTo(view.BottomAnchor, -8)
            });

            return(view);
        }
Esempio n. 2
0
        private void UpdateBackground(RoundedView RView)
        {
            if (_renderer != null)
            {
                _renderer.Dispose();
                _renderer = null;
            }
            _renderer = new LabelBorderRenderer();

            Control.Background = _renderer.GetBorderBackground(RView.BorderColor, RView.BorderColor, RView.BorderWidth, RView.BorderRadius);
        }
        private static UIView GetRandomView(float width = 50, float?height = null)
        {
            var view = new RoundedView {
                BackgroundColor = ColorUtil.GetRandomColor()
            };

            view.WidthAnchor.ConstraintEqualTo(width).Active = true;

            if (height != null)
            {
                view.HeightAnchor.ConstraintEqualTo(height.Value).Active = true;
            }

            return(view);
        }
Esempio n. 4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var box = new RoundedView {
                BackgroundColor = UIColor.Blue
            };

            View.Add(box);
            box.CenterIn(View);

            _small = box.ConstraintSize(50, 50);
            _big   = box.ConstraintSize(150, 300, false);

            box.AddGestureRecognizer(new UITapGestureRecognizer(ChangeState)
            {
                CancelsTouchesInView = false
            });
        }
Esempio n. 5
0
        private void UpdateTextAlighnment(RoundedView RView)
        {
            var gravity = DefaultGravity;

            switch (RView.HorizontalTextAlignment)
            {
            case Xamarin.Forms.TextAlignment.Start:
                gravity |= GravityFlags.Start;
                break;

            case Xamarin.Forms.TextAlignment.Center:
                gravity |= GravityFlags.CenterHorizontal;
                break;

            case Xamarin.Forms.TextAlignment.End:
                gravity |= GravityFlags.End;
                break;
            }
            Control.Gravity = gravity;
        }
Esempio n. 6
0
 private void UpdatePadding(RoundedView entryEx)
 {
     Control.SetPadding((int)Forms.Context.ToPixels(entryEx.LeftPadding), 0,
                        (int)Forms.Context.ToPixels(entryEx.RightPadding), 0);
 }
Esempio n. 7
0
        public static View CreateBreadcrumbView(this IRokredListChildDataSource context, ICommand command = null)
        {
            //if there is no command, this is the outside most view
            var mainStackLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal, Spacing = 0,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Fill
            };

            var insideView = new RoundedView {
                CornerRadius = 5
            };

            // this stack contains the bordered text of the item plus the chevron
            var insideStack = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Spacing     = 0, VerticalOptions = LayoutOptions.Center
            };

            var label = new RokredLabel
            {
                FontSize        = 16, IsBold = true,
                Margin          = new Thickness(15, 5, 15, 5),
                VerticalOptions = LayoutOptions.Center
            };
            var chevron = new SvgCachedImage
            {
                Source = "chevron-dark.svg", WidthRequest = 10, HeightRequest = 15,
                Margin = new Thickness(15, 5, 0, 5)
            };

            if (context is CategoryVmi category)
            {
                insideView.BackgroundColor = Color.White;
                label.TextColor            = Color.Black;
                label.Text     = category.Name;
                label.Margin   = new Thickness(5, 5, 10, 5);
                label.FontSize = 12;

                // category has an icon
                var categoryIcon = new SvgCachedImage
                {
                    WidthRequest = 15, HeightRequest = 20, Margin = new Thickness(10, 5, 5, 5),
                    Source       = context.GetImageBasedOnContext(false)
                };

                insideStack.Children.Add(categoryIcon);
            }
            else if (context is SubjectVmi)
            {
                insideView.BackgroundColor = Color.FromHex("4A44F2");
                label.TextColor            = Color.White;
                label.Text = "S";
            }
            else if (context is OpinionVmi && !(context as OpinionVmi).IsDirty)
            {
                insideView.BackgroundColor = Color.FromHex("F2BE22");
                label.TextColor            = Color.Black;
                label.Text = "O";
            }
            else if (context is OpinionVmi && (context as OpinionVmi).IsDirty)
            {
                chevron.IsVisible = false;
                label.IsVisible   = false;

                insideView.BackgroundColor = Color.Transparent;

                var star = new SvgCachedImage
                {
                    Source = "star-icon.svg", WidthRequest = 35, HeightRequest = 35,
                    Margin = new Thickness(0, 0, 0, 0)
                };

                insideStack.Children.Add(star);
            }

            insideStack.Children.Add(label);

            mainStackLayout.HorizontalOptions = LayoutOptions.Start;
            mainStackLayout.VerticalOptions   = LayoutOptions.Center;
            mainStackLayout.Margin            = new Thickness(10);

            insideView.Content = insideStack;
            mainStackLayout.Children.Add(insideView);
            mainStackLayout.Children.Add(chevron);

            if (command != null)
            {
                var button = new RokredButton();
                button.Content          = mainStackLayout;
                button.Command          = command;
                button.CommandParameter = context;

                return(button);
            }

            return(mainStackLayout);
        }