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; } } }
/// <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); } } }
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); }
void UpdateFlowDirection(CellTableViewCell cell, SwitchCell switchCell) { IVisualElementController controller = switchCell.Parent as View; var uiSwitch = cell.AccessoryView as UISwitch; uiSwitch.UpdateFlowDirection(controller); }
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; }
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)); } }
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; } }
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; } }
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; } }
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; } }
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; } }
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); }
/// <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); } }
/// <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); } }
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; }
internal VisualElementController(IVisualElementController cntrlr) : base(cntrlr) { controller = cntrlr; }