예제 #1
0
        internal static void UpdateFlowDirection(this AView view, IVisualElementController controller)
        {
            if (view == null || controller == null || (int)Forms.SdkInt < 17)
            {
                return;
            }

            // if android:targetSdkVersion < 17 setting these has no effect
            if (controller.EffectiveFlowDirection.IsRightToLeft())
            {
                view.LayoutDirection = ALayoutDirection.Rtl;

                if (view is TextView textView)
                {
                    textView.TextDirection = ATextDirection.Rtl;
                }
            }
            else if (controller.EffectiveFlowDirection.IsLeftToRight())
            {
                view.LayoutDirection = ALayoutDirection.Ltr;

                if (view is TextView textView)
                {
                    textView.TextDirection = ATextDirection.Ltr;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Updates the value of the corner radius when flow direction is changed.
        /// </summary>
        /// <param name="view">The view</param>
        private static void UpdateCornerRadius(View view)
        {
            IVisualElementController controller = view;
            var cornerRadius = GetCornerRadius(view);

            if (cornerRadius != ZeroThickness)
            {
                if (controller.EffectiveFlowDirection == EffectiveFlowDirection.RightToLeft)
                {
                    cornerRadius = new Thickness(cornerRadius.Top, cornerRadius.Left, cornerRadius.Bottom,
                                                 cornerRadius.Right);
                }

                if (view is SfCardView)
                {
                    view.SetValue(SfCardView.CornerRadiusProperty, cornerRadius);
                }
                else if (view is SfBorder)
                {
                    view.SetValue(SfBorder.CornerRadiusProperty, cornerRadius);
                }
            }
            else
            {
                if (view is SfCardView)
                {
                    view.ClearValue(SfCardView.CornerRadiusProperty);
                }
                else if (view is SfBorder)
                {
                    view.ClearValue(SfBorder.CornerRadiusProperty);
                }
            }
        }
예제 #3
0
        internal static void UpdateFlowDirection(this AView view, IVisualElementController controller)
        {
            if (view == null || controller == null)
            {
                return;
            }

            if (controller is IView v)
            {
                view.UpdateFlowDirection(v);
                return;
            }

            if (controller.EffectiveFlowDirection.IsRightToLeft())
            {
                view.LayoutDirection = ALayoutDirection.Rtl;

                if (view is TextView textView)
                {
                    textView.TextDirection = ATextDirection.Rtl;
                }
            }
            else if (controller.EffectiveFlowDirection.IsLeftToRight())
            {
                view.LayoutDirection = ALayoutDirection.Ltr;

                if (view is TextView textView)
                {
                    textView.TextDirection = ATextDirection.Ltr;
                }
            }
        }
        internal static bool UpdateFlowDirection(this UIView view, IVisualElementController controller)
        {
            if (controller == null || view == null || !Forms.IsiOS9OrNewer)
            {
                return(false);
            }

            if (controller is IView v)
            {
                var current = view.SemanticContentAttribute;
                view.UpdateFlowDirection(v);
                return(current != view.SemanticContentAttribute);
            }

            UISemanticContentAttribute updateValue = view.SemanticContentAttribute;

            if (controller.EffectiveFlowDirection.IsRightToLeft())
            {
                updateValue = UISemanticContentAttribute.ForceRightToLeft;
            }
            else if (controller.EffectiveFlowDirection.IsLeftToRight())
            {
                updateValue = UISemanticContentAttribute.ForceLeftToRight;
            }

            if (updateValue != view.SemanticContentAttribute)
            {
                view.SemanticContentAttribute = updateValue;
                return(true);
            }

            return(false);
        }
예제 #5
0
        void UpdateFlowDirection(CellTableViewCell cell, SwitchCell switchCell)
        {
            IVisualElementController controller = switchCell.Parent as View;

            var uiSwitch = cell.AccessoryView as UISwitch;

            uiSwitch.UpdateFlowDirection(controller);
        }
예제 #6
0
		internal static void UpdateTextAlignment(this UITextView control, IVisualElementController controller)
		{
			if (controller == null || control == null)
				return;

			if (controller.EffectiveFlowDirection.IsRightToLeft())
				control.TextAlignment = UITextAlignment.Right;
			else if (controller.EffectiveFlowDirection.IsLeftToRight())
				control.TextAlignment = UITextAlignment.Left;
		}
예제 #7
0
        void UpdateHorizontalTextAlignment(CellNSView cell, EntryCell entryCell)
        {
            IVisualElementController viewController = entryCell.Parent as VisualElement;

            var nsTextField = cell.AccessoryView.Subviews[0] as NSTextField;

            if (nsTextField != null)
            {
                nsTextField.Alignment = entryCell.HorizontalTextAlignment.ToNativeTextAlignment(viewController?.EffectiveFlowDirection ?? default(EffectiveFlowDirection));
            }
        }
예제 #8
0
        internal static void UpdateFlowDirection(this NSTextField control, IVisualElementController controller)
        {
            if (controller == null || control == null)
            {
                return;
            }

            if (controller.EffectiveFlowDirection.IsRightToLeft())
            {
                control.Alignment = NSTextAlignment.Right;
            }
            else if (controller.EffectiveFlowDirection.IsLeftToRight())
            {
                control.Alignment = NSTextAlignment.Left;
            }
        }
예제 #9
0
        internal static void UpdateFlowDirection(this AView view, IVisualElementController controller)
        {
            if (view == null || controller == null || (int)Build.VERSION.SdkInt < 17)
            {
                return;
            }

            if (controller.EffectiveFlowDirection.IsRightToLeft())
            {
                view.LayoutDirection = ALayoutDirection.Rtl;
            }
            else if (controller.EffectiveFlowDirection.IsLeftToRight())
            {
                view.LayoutDirection = ALayoutDirection.Ltr;
            }
        }
예제 #10
0
        internal static void UpdateFlowDirection(this NSView view, IVisualElementController controller)
        {
            if (controller == null || view == null)
            {
                return;
            }

            if (controller.EffectiveFlowDirection.IsRightToLeft())
            {
                view.UserInterfaceLayoutDirection = NSUserInterfaceLayoutDirection.RightToLeft;
            }
            else if (controller.EffectiveFlowDirection.IsLeftToRight())
            {
                view.UserInterfaceLayoutDirection = NSUserInterfaceLayoutDirection.LeftToRight;
            }
        }
        internal static void UpdateFlowDirection(this FrameworkElement control, IVisualElementController controller)
        {
            if (controller == null || control == null)
            {
                return;
            }

            if (controller.EffectiveFlowDirection.IsRightToLeft())
            {
                control.FlowDirection = WFlowDirection.RightToLeft;
            }
            else if (controller.EffectiveFlowDirection.IsLeftToRight())
            {
                control.FlowDirection = WFlowDirection.LeftToRight;
            }
        }
예제 #12
0
		internal static void UpdateTextAlignment(this UITextField control, IVisualElementController controller)
		{
			if (controller == null || control == null)
				return;

			if (controller.EffectiveFlowDirection.IsRightToLeft())
			{
				control.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
				control.TextAlignment = UITextAlignment.Right;
			}
			else if (controller.EffectiveFlowDirection.IsLeftToRight())
			{
				control.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
				control.TextAlignment = UITextAlignment.Left;
			}
		}
예제 #13
0
        internal static void UpdateFlowDirection(this UIView view, IVisualElementController controller)
        {
            if (controller == null || view == null || !Forms.IsiOS9OrNewer)
            {
                return;
            }


            if (controller.EffectiveFlowDirection.IsRightToLeft())
            {
                view.SemanticContentAttribute = UISemanticContentAttribute.ForceRightToLeft;
            }
            else if (controller.EffectiveFlowDirection.IsLeftToRight())
            {
                view.SemanticContentAttribute = UISemanticContentAttribute.ForceLeftToRight;
            }
        }
예제 #14
0
        bool UpdateFlowDirection(UIView view, IVisualElementController controller)
        {
            if (controller != null && view != null && Forms_iOS.IsiOS9OrNewer)
            {
                if (controller.EffectiveFlowDirection.IsRightToLeft())
                {
                    view.SemanticContentAttribute = UISemanticContentAttribute.ForceRightToLeft;
                }
                else
                {
                    view.SemanticContentAttribute = UISemanticContentAttribute.ForceLeftToRight;
                }

                return(true);
            }

            return(false);
        }
예제 #15
0
        /// <summary>
        /// Updates the margin value when the flow direction is changed.
        /// </summary>
        /// <param name="view">The view</param>
        private static void UpdateMargin(VisualElement view)
        {
            IVisualElementController controller = view;
            var margin = GetMargin(view);

            if (margin != ZeroThickness)
            {
                if (controller.EffectiveFlowDirection == EffectiveFlowDirection.RightToLeft)
                {
                    margin = new Thickness(margin.Right, margin.Top, margin.Left, margin.Bottom);
                }

                view.SetValue(View.MarginProperty, margin);
            }
            else
            {
                view.ClearValue(View.MarginProperty);
            }
        }
예제 #16
0
        /// <summary>
        /// Updates padding when the the flow direction is changed.
        /// </summary>
        /// <param name="layout">The layout</param>
        private static void UpdatePadding(View layout)
        {
            IVisualElementController controller = layout;
            var padding = GetPadding(layout);

            if (padding != ZeroThickness)
            {
                if (controller.EffectiveFlowDirection == EffectiveFlowDirection.RightToLeft)
                {
                    padding = new Thickness(padding.Right, padding.Top, padding.Left, padding.Bottom);
                }

                layout.SetValue(Layout.PaddingProperty, padding);
            }
            else
            {
                layout.ClearValue(Layout.PaddingProperty);
            }
        }
예제 #17
0
		internal static bool UpdateFlowDirection(this UIView view, IVisualElementController controller)
		{
			if (controller == null || view == null || !Forms.IsiOS9OrNewer)
				return false;

			UISemanticContentAttribute updateValue = view.SemanticContentAttribute;

			if (controller.EffectiveFlowDirection.IsRightToLeft())
				updateValue = UISemanticContentAttribute.ForceRightToLeft;
			else if (controller.EffectiveFlowDirection.IsLeftToRight())
				updateValue = UISemanticContentAttribute.ForceLeftToRight;

			if (updateValue != view.SemanticContentAttribute)
			{
				view.SemanticContentAttribute = updateValue;
				return true;
			}

			return false;
		}
예제 #18
0
 internal VisualElementController(IVisualElementController cntrlr)
     : base(cntrlr)
 {
     controller = cntrlr;
 }