Example #1
0
        public static void UpdateFrom(this View nativeControl, Abstractions.RoundedBoxView formsControl,
                                      string propertyChanged)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            if (propertyChanged == Abstractions.RoundedBoxView.CornerRadiusProperty.PropertyName)
            {
                nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
            }
            if (propertyChanged == VisualElement.BackgroundColorProperty.PropertyName)
            {
                var background = nativeControl.Background as GradientDrawable;

                if (background != null)
                {
                    background.SetColor(formsControl.BackgroundColor.ToAndroid());
                }
            }

            if (propertyChanged == Abstractions.RoundedBoxView.BorderColorProperty.PropertyName)
            {
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }

            if (propertyChanged == Abstractions.RoundedBoxView.BorderThicknessProperty.PropertyName)
            {
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }
        }
        public static void InitializeFrom(this Rectangle nativeControl, Abstractions.RoundedBoxView formsControl)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
            nativeControl.UpdateBackgroundColor(formsControl.BackgroundColor);
            nativeControl.UpdateBorderThickness(formsControl.BorderThickness, formsControl.HeightRequest, formsControl.WidthRequest);
        }
Example #3
0
        public static void InitializeFrom(this UIView nativeControl, Abstractions.RoundedBoxView formsControl)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            nativeControl.Layer.MasksToBounds = true;
            nativeControl.Layer.CornerRadius  = (float)formsControl.CornerRadius;
            nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
        }
Example #4
0
        public static void InitializeFrom(this Border nativeControl, Abstractions.RoundedBoxView formsControl)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            nativeControl.Height = formsControl.HeightRequest;
            nativeControl.Width  = formsControl.WidthRequest;
            nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
            nativeControl.UpdateBorderColor(formsControl.BorderColor);

            var rectangle = new Rectangle();

            rectangle.InitializeFrom(formsControl);

            nativeControl.Child = rectangle;
        }
Example #5
0
        public static void UpdateFrom(this Border nativeControl, Abstractions.RoundedBoxView formsControl,
                                      string propertyChanged)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            if (propertyChanged == Abstractions.RoundedBoxView.CornerRadiusProperty.PropertyName)
            {
                nativeControl.UpdateCornerRadius(formsControl.CornerRadius);

                var rect = nativeControl.Child as Rectangle;

                if (rect != null)
                {
                    rect.UpdateCornerRadius(formsControl.CornerRadius);
                }
            }
            if (propertyChanged == VisualElement.BackgroundColorProperty.PropertyName)
            {
                var rect = nativeControl.Child as Rectangle;

                if (rect != null)
                {
                    rect.UpdateBackgroundColor(formsControl.BackgroundColor);
                }
            }

            if (propertyChanged == Abstractions.RoundedBoxView.BorderColorProperty.PropertyName)
            {
                nativeControl.Background = formsControl.BorderColor.ToBrush();
            }

            if (propertyChanged == Abstractions.RoundedBoxView.BorderThicknessProperty.PropertyName)
            {
                var rect = nativeControl.Child as Rectangle;

                if (rect != null)
                {
                    rect.UpdateBorderThickness(formsControl.BorderThickness, formsControl.HeightRequest, formsControl.WidthRequest);
                }
            }
        }
Example #6
0
        public static void InitializeFrom(this View nativeControl, Abstractions.RoundedBoxView formsControl)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            var background = new GradientDrawable();

            background.SetColor(formsControl.BackgroundColor.ToAndroid());

            if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
            {
                nativeControl.Background = background;
            }
            else
            {
                nativeControl.SetBackgroundDrawable(background);
            }

            nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
            nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
        }
Example #7
0
        public static void UpdateFrom(this UIView nativeControl, Abstractions.RoundedBoxView formsControl,
                                      string propertyChanged)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            if (propertyChanged == Abstractions.RoundedBoxView.CornerRadiusProperty.PropertyName)
            {
                nativeControl.Layer.CornerRadius = (float)formsControl.CornerRadius;
            }

            if (propertyChanged == Abstractions.RoundedBoxView.BorderColorProperty.PropertyName)
            {
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }

            if (propertyChanged == Abstractions.RoundedBoxView.BorderThicknessProperty.PropertyName)
            {
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }
        }