зеркало из https://github.com/DeGsoft/maui-linux.git
ITextAlignmentElement VerticalTextAlignment (Entry, SearchBar, EntryCell) (#6463)
This commit is contained in:
Родитель
0debd4a493
Коммит
6ee4ec6974
|
@ -52,6 +52,20 @@ namespace Xamarin.Forms.Controls
|
|||
var xAlignPlaceholderStart = new ViewContainer<Entry> (Test.Entry.HorizontalTextAlignmentPlaceholderStart,
|
||||
new Entry { Placeholder = "Should be aligned start", HorizontalTextAlignment = TextAlignment.Start });
|
||||
|
||||
var yAlignCenterContainer = new ViewContainer<Entry>(Test.Entry.VerticalTextAlignmentCenter,
|
||||
new Entry { Text = "Should be centered!", VerticalTextAlignment = TextAlignment.Center, BackgroundColor = Color.Pink, HeightRequest = 100 });
|
||||
var yAlignEndContainer = new ViewContainer<Entry>(Test.Entry.VerticalTextAlignmentEnd,
|
||||
new Entry { Text = "Should be aligned end!", VerticalTextAlignment = TextAlignment.End, BackgroundColor = Color.Pink, HeightRequest = 100 });
|
||||
var yAlignStartContainer = new ViewContainer<Entry>(Test.Entry.VerticalTextAlignmentStart,
|
||||
new Entry { Text = "Should be aligned start!", VerticalTextAlignment = TextAlignment.Start, BackgroundColor = Color.Pink, HeightRequest = 100 });
|
||||
|
||||
var yAlignPlaceholderCenter = new ViewContainer<Entry>(Test.Entry.VerticalTextAlignmentPlaceholderCenter,
|
||||
new Entry { Placeholder = "Should be centered!", VerticalTextAlignment = TextAlignment.Center, BackgroundColor = Color.Pink, HeightRequest = 100 });
|
||||
var yAlignPlaceholderEnd = new ViewContainer<Entry>(Test.Entry.VerticalTextAlignmentPlaceholderEnd,
|
||||
new Entry { Placeholder = "Should be aligned end!", VerticalTextAlignment = TextAlignment.End, BackgroundColor = Color.Pink, HeightRequest = 100 });
|
||||
var yAlignPlaceholderStart = new ViewContainer<Entry>(Test.Entry.VerticalTextAlignmentPlaceholderStart,
|
||||
new Entry { Placeholder = "Should be aligned start!", VerticalTextAlignment = TextAlignment.Start, BackgroundColor = Color.Pink, HeightRequest = 100 });
|
||||
|
||||
var placeholderColorContainer = new ViewContainer<Entry> (Test.Entry.PlaceholderColor,
|
||||
new Entry { Placeholder = "Hi, I should be red", PlaceholderColor = Color.Red });
|
||||
|
||||
|
@ -104,6 +118,12 @@ namespace Xamarin.Forms.Controls
|
|||
Add (xAlignEndContainer);
|
||||
Add (xAlignPlaceholderStart);
|
||||
Add (xAlignStartContainer);
|
||||
Add (yAlignPlaceholderCenter);
|
||||
Add (yAlignCenterContainer);
|
||||
Add (yAlignPlaceholderEnd);
|
||||
Add (yAlignEndContainer);
|
||||
Add (yAlignPlaceholderStart);
|
||||
Add (yAlignStartContainer);
|
||||
Add (textFontAttributesContainer);
|
||||
Add (textFamilyContainer1);
|
||||
Add (textFamilyContainer2);
|
||||
|
|
|
@ -107,7 +107,8 @@ namespace Xamarin.Forms.Controls
|
|||
Text = "VerticalTextAlignment Start",
|
||||
VerticalTextAlignment = TextAlignment.Center,
|
||||
HeightRequest = alignmentTestsHeightRequest,
|
||||
WidthRequest = alignmentTestsWidthRequest
|
||||
WidthRequest = alignmentTestsWidthRequest,
|
||||
BackgroundColor = Color.Pink
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -116,7 +117,8 @@ namespace Xamarin.Forms.Controls
|
|||
Text = "VerticalTextAlignment End",
|
||||
VerticalTextAlignment = TextAlignment.End,
|
||||
HeightRequest = alignmentTestsHeightRequest,
|
||||
WidthRequest = alignmentTestsWidthRequest
|
||||
WidthRequest = alignmentTestsWidthRequest,
|
||||
BackgroundColor = Color.Pink
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -125,7 +127,8 @@ namespace Xamarin.Forms.Controls
|
|||
Text = "VerticalTextAlignment Start",
|
||||
VerticalTextAlignment = TextAlignment.Start,
|
||||
HeightRequest = alignmentTestsHeightRequest,
|
||||
WidthRequest = alignmentTestsWidthRequest
|
||||
WidthRequest = alignmentTestsWidthRequest,
|
||||
BackgroundColor = Color.Pink
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -52,6 +52,13 @@ namespace Xamarin.Forms.Controls
|
|||
var textAlignmentEndContainer = new ViewContainer<SearchBar> (Test.SearchBar.TextAlignmentEnd,
|
||||
new SearchBar { Text = "I should be at the end", HorizontalTextAlignment = TextAlignment.End });
|
||||
|
||||
var textVerticalAlignmentStartContainer = new ViewContainer<SearchBar>(Test.SearchBar.TextVerticalAlignmentStart,
|
||||
new SearchBar { Text = "I should be at the start", VerticalTextAlignment = TextAlignment.Start });
|
||||
var textVerticalAlignmentCenterContainer = new ViewContainer<SearchBar>(Test.SearchBar.TextVerticalAlignmentCenter,
|
||||
new SearchBar { Text = "I should be centered", VerticalTextAlignment = TextAlignment.Center });
|
||||
var textVerticalAlignmentEndContainer = new ViewContainer<SearchBar>(Test.SearchBar.TextVerticalAlignmentEnd,
|
||||
new SearchBar { Text = "I should be at the end", VerticalTextAlignment = TextAlignment.End });
|
||||
|
||||
var placeholderAlignmentStartContainer = new ViewContainer<SearchBar> (Test.SearchBar.PlaceholderAlignmentStart,
|
||||
new SearchBar { Placeholder = "I should be at the start", HorizontalTextAlignment = TextAlignment.Start });
|
||||
var placeholderAlignmentCenterContainer = new ViewContainer<SearchBar> (Test.SearchBar.PlaceholderAlignmentCenter,
|
||||
|
@ -59,6 +66,13 @@ namespace Xamarin.Forms.Controls
|
|||
var placeholderAlignmentEndContainer = new ViewContainer<SearchBar> (Test.SearchBar.PlaceholderAlignmentEnd,
|
||||
new SearchBar { Placeholder = "I should be at the end", HorizontalTextAlignment = TextAlignment.End });
|
||||
|
||||
var placeholderVerticalAlignmentStartContainer = new ViewContainer<SearchBar>(Test.SearchBar.PlaceholderVerticalAlignmentStart,
|
||||
new SearchBar { Placeholder = "I should be at the start", VerticalTextAlignment = TextAlignment.Start });
|
||||
var placeholderVerticalAlignmentCenterContainer = new ViewContainer<SearchBar>(Test.SearchBar.PlaceholderVerticalAlignmentCenter,
|
||||
new SearchBar { Placeholder = "I should be centered", VerticalTextAlignment = TextAlignment.Center });
|
||||
var placeholderVerticalAlignmentEndContainer = new ViewContainer<SearchBar>(Test.SearchBar.PlaceholderVerticalAlignmentEnd,
|
||||
new SearchBar { Placeholder = "I should be at the end", VerticalTextAlignment = TextAlignment.End });
|
||||
|
||||
var textColorContainer = new ViewContainer<SearchBar> (Test.SearchBar.TextColor,
|
||||
new SearchBar { Text = "I should be red", TextColor = Color.Red });
|
||||
|
||||
|
@ -89,6 +103,12 @@ namespace Xamarin.Forms.Controls
|
|||
Add (placeholderAlignmentStartContainer);
|
||||
Add (placeholderAlignmentCenterContainer);
|
||||
Add (placeholderAlignmentEndContainer);
|
||||
Add (textVerticalAlignmentStartContainer);
|
||||
Add (textVerticalAlignmentCenterContainer);
|
||||
Add (textVerticalAlignmentEndContainer);
|
||||
Add (placeholderVerticalAlignmentStartContainer);
|
||||
Add (placeholderVerticalAlignmentCenterContainer);
|
||||
Add (placeholderVerticalAlignmentEndContainer);
|
||||
Add (textColorContainer);
|
||||
Add (placeholderColorContainer);
|
||||
Add (keyboardContainer);
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty HorizontalTextAlignmentProperty = TextAlignmentElement.HorizontalTextAlignmentProperty;
|
||||
|
||||
public static readonly BindableProperty VerticalTextAlignmentProperty = TextAlignmentElement.VerticalTextAlignmentProperty;
|
||||
|
||||
[Obsolete("XAlignProperty is obsolete as of version 2.0.0. Please use HorizontalTextAlignmentProperty instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static readonly BindableProperty XAlignProperty = HorizontalTextAlignmentProperty;
|
||||
|
@ -27,6 +29,12 @@ namespace Xamarin.Forms
|
|||
set { SetValue(TextAlignmentElement.HorizontalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
public TextAlignment VerticalTextAlignment
|
||||
{
|
||||
get { return (TextAlignment)GetValue(TextAlignmentElement.VerticalTextAlignmentProperty); }
|
||||
set { SetValue(TextAlignmentElement.VerticalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
public Keyboard Keyboard
|
||||
{
|
||||
get { return (Keyboard)GetValue(KeyboardProperty); }
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty HorizontalTextAlignmentProperty = TextAlignmentElement.HorizontalTextAlignmentProperty;
|
||||
|
||||
public static readonly BindableProperty VerticalTextAlignmentProperty = TextAlignmentElement.VerticalTextAlignmentProperty;
|
||||
|
||||
public static readonly BindableProperty FontFamilyProperty = FontElement.FontFamilyProperty;
|
||||
|
||||
public static readonly BindableProperty FontSizeProperty = FontElement.FontSizeProperty;
|
||||
|
@ -54,6 +56,12 @@ namespace Xamarin.Forms
|
|||
set { SetValue(TextAlignmentElement.HorizontalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
public TextAlignment VerticalTextAlignment
|
||||
{
|
||||
get { return (TextAlignment)GetValue(TextAlignmentElement.VerticalTextAlignmentProperty); }
|
||||
set { SetValue(TextAlignmentElement.VerticalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsPassword
|
||||
{
|
||||
get { return (bool)GetValue(IsPasswordProperty); }
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
//note to implementor: implement the properties publicly
|
||||
TextAlignment HorizontalTextAlignment { get; }
|
||||
|
||||
TextAlignment VerticalTextAlignment { get; }
|
||||
|
||||
//note to implementor: but implement the methods explicitly
|
||||
void OnHorizontalTextAlignmentPropertyChanged(TextAlignment oldValue, TextAlignment newValue);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace Xamarin.Forms
|
|||
get { return (TextAlignment)GetValue(TextAlignmentElement.HorizontalTextAlignmentProperty); }
|
||||
set { SetValue(TextAlignmentElement.HorizontalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public LineBreakMode LineBreakMode
|
||||
{
|
||||
get { return (LineBreakMode)GetValue(LineBreakModeProperty); }
|
||||
|
@ -141,12 +141,13 @@ namespace Xamarin.Forms
|
|||
get { return (Color)GetValue(TextElement.TextColorProperty); }
|
||||
set { SetValue(TextElement.TextColorProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double CharacterSpacing
|
||||
{
|
||||
get { return (double)GetValue(TextElement.CharacterSpacingProperty); }
|
||||
set { SetValue(TextElement.CharacterSpacingProperty, value); }
|
||||
}
|
||||
|
||||
public TextAlignment VerticalTextAlignment
|
||||
{
|
||||
get { return (TextAlignment)GetValue(VerticalTextAlignmentProperty); }
|
||||
|
|
|
@ -76,7 +76,7 @@ using Xamarin.Forms.StyleSheets;
|
|||
[assembly: StyleProperty("text-decoration", typeof(IDecorableTextElement), nameof(DecorableTextElement.TextDecorationsProperty))]
|
||||
[assembly: StyleProperty("transform", typeof(VisualElement), nameof(VisualElement.TransformProperty))]
|
||||
[assembly: StyleProperty("transform-origin", typeof(VisualElement), nameof(VisualElement.TransformOriginProperty))]
|
||||
//[assembly: StyleProperty("vertical-align", /*typeof(Label), nameof(Label.VerticalTextAlignmentProperty)*/)]
|
||||
[assembly: StyleProperty("vertical-align", typeof(ITextAlignmentElement), nameof(TextAlignmentElement.VerticalTextAlignmentProperty))]
|
||||
[assembly: StyleProperty("visibility", typeof(VisualElement), nameof(VisualElement.IsVisibleProperty), Inherited = true)]
|
||||
[assembly: StyleProperty("width", typeof(VisualElement), nameof(VisualElement.WidthRequestProperty))]
|
||||
[assembly: StyleProperty("line-height", typeof(ILineHeightElement), nameof(LineHeightElement.LineHeightProperty), Inherited = true)]
|
||||
|
@ -109,7 +109,7 @@ using Xamarin.Forms.StyleSheets;
|
|||
[assembly: StyleProperty("-xf-spacing", typeof(StackLayout), nameof(StackLayout.SpacingProperty))]
|
||||
[assembly: StyleProperty("-xf-orientation", typeof(StackLayout), nameof(StackLayout.OrientationProperty))]
|
||||
[assembly: StyleProperty("-xf-visual", typeof(VisualElement), nameof(VisualElement.VisualProperty))]
|
||||
[assembly: StyleProperty("-xf-vertical-text-alignment", typeof(Label), nameof(Label.VerticalTextAlignmentProperty))]
|
||||
[assembly: StyleProperty("-xf-vertical-text-alignment", typeof(Label), nameof(TextAlignmentElement.VerticalTextAlignmentProperty))]
|
||||
[assembly: StyleProperty("-xf-thumb-color", typeof(Switch), nameof(Switch.ThumbColorProperty))]
|
||||
|
||||
//shell
|
||||
|
|
|
@ -36,6 +36,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty HorizontalTextAlignmentProperty = TextAlignmentElement.HorizontalTextAlignmentProperty;
|
||||
|
||||
public static readonly BindableProperty VerticalTextAlignmentProperty = TextAlignmentElement.VerticalTextAlignmentProperty;
|
||||
|
||||
public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
|
||||
|
||||
public static readonly BindableProperty CharacterSpacingProperty = TextElement.CharacterSpacingProperty;
|
||||
|
@ -54,6 +56,12 @@ namespace Xamarin.Forms
|
|||
set { SetValue(TextAlignmentElement.HorizontalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
public TextAlignment VerticalTextAlignment
|
||||
{
|
||||
get { return (TextAlignment)GetValue(TextAlignmentElement.VerticalTextAlignmentProperty); }
|
||||
set { SetValue(TextAlignmentElement.VerticalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
public string Placeholder {
|
||||
get => (string)GetValue(PlaceholderElement.PlaceholderProperty);
|
||||
set => SetValue(PlaceholderElement.PlaceholderProperty, value);
|
||||
|
|
|
@ -96,6 +96,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty HorizontalTextAlignmentProperty = TextAlignmentElement.HorizontalTextAlignmentProperty;
|
||||
|
||||
public static readonly BindableProperty VerticalTextAlignmentProperty = TextAlignmentElement.VerticalTextAlignmentProperty;
|
||||
|
||||
void ITextAlignmentElement.OnHorizontalTextAlignmentPropertyChanged(TextAlignment oldValue, TextAlignment newValue)
|
||||
{
|
||||
}
|
||||
|
@ -106,6 +108,12 @@ namespace Xamarin.Forms
|
|||
set { SetValue(TextAlignmentElement.HorizontalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
public TextAlignment VerticalTextAlignment
|
||||
{
|
||||
get { return (TextAlignment)GetValue(TextAlignmentElement.VerticalTextAlignmentProperty); }
|
||||
set { SetValue(TextAlignmentElement.VerticalTextAlignmentProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
|
||||
|
||||
public static readonly BindableProperty CharacterSpacingProperty = TextElement.CharacterSpacingProperty;
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
static class TextAlignmentElement
|
||||
{
|
||||
public static readonly BindableProperty HorizontalTextAlignmentProperty =
|
||||
BindableProperty.Create(nameof(ITextAlignmentElement.HorizontalTextAlignment), typeof(TextAlignment), typeof(EntryCell), TextAlignment.Start,
|
||||
BindableProperty.Create(nameof(ITextAlignmentElement.HorizontalTextAlignment), typeof(TextAlignment), typeof(ITextAlignmentElement), TextAlignment.Start,
|
||||
propertyChanged: OnHorizontalTextAlignmentPropertyChanged);
|
||||
|
||||
public static readonly BindableProperty VerticalTextAlignmentProperty =
|
||||
BindableProperty.Create(nameof(ITextAlignmentElement.VerticalTextAlignment), typeof(TextAlignment), typeof(ITextAlignmentElement), TextAlignment.Center);
|
||||
|
||||
static void OnHorizontalTextAlignmentPropertyChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
((ITextAlignmentElement)bindable).OnHorizontalTextAlignmentPropertyChanged((TextAlignment)oldValue, (TextAlignment)newValue);
|
||||
|
|
|
@ -526,6 +526,12 @@ namespace Xamarin.Forms.CustomAttributes
|
|||
HorizontalTextAlignmentPlaceholderStart,
|
||||
HorizontalTextAlignmentPlaceholderCenter,
|
||||
HorizontalTextAlignmentPlaceholderEnd,
|
||||
VerticalTextAlignmentStart,
|
||||
VerticalTextAlignmentCenter,
|
||||
VerticalTextAlignmentEnd,
|
||||
VerticalTextAlignmentPlaceholderStart,
|
||||
VerticalTextAlignmentPlaceholderCenter,
|
||||
VerticalTextAlignmentPlaceholderEnd,
|
||||
FontAttributes,
|
||||
FontFamily,
|
||||
FontSize,
|
||||
|
@ -680,9 +686,15 @@ namespace Xamarin.Forms.CustomAttributes
|
|||
TextAlignmentStart,
|
||||
TextAlignmentCenter,
|
||||
TextAlignmentEnd,
|
||||
TextVerticalAlignmentStart,
|
||||
TextVerticalAlignmentCenter,
|
||||
TextVerticalAlignmentEnd,
|
||||
PlaceholderAlignmentStart,
|
||||
PlaceholderAlignmentCenter,
|
||||
PlaceholderAlignmentEnd,
|
||||
PlaceholderVerticalAlignmentStart,
|
||||
PlaceholderVerticalAlignmentCenter,
|
||||
PlaceholderVerticalAlignmentEnd,
|
||||
TextColor,
|
||||
PlaceholderColor
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
UpdatePlaceholder();
|
||||
UpdateKeyboard();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateText();
|
||||
UpdateIsEnabled();
|
||||
UpdateHeight();
|
||||
|
@ -53,6 +54,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
UpdateLabelColor();
|
||||
else if (e.PropertyName == EntryCell.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == EntryCell.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == Cell.IsEnabledProperty.PropertyName)
|
||||
UpdateIsEnabled();
|
||||
else if (e.PropertyName == "RenderHeight")
|
||||
|
@ -95,6 +98,12 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_view.EditText.UpdateHorizontalAlignment(entryCell.HorizontalTextAlignment, _view.Context.HasRtlSupport());
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
var entryCell = (EntryCell)Cell;
|
||||
_view.EditText.UpdateVerticalAlignment(entryCell.VerticalTextAlignment);
|
||||
}
|
||||
|
||||
void UpdateIsEnabled()
|
||||
{
|
||||
var entryCell = (EntryCell)Cell;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using Android.OS;
|
||||
using Android.Widget;
|
||||
using Xamarin.Forms.Internals;
|
||||
using ALayoutDirection = Android.Views.LayoutDirection;
|
||||
using AView = Android.Views.View;
|
||||
using AGravityFlags = Android.Views.GravityFlags;
|
||||
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
|
@ -34,13 +31,5 @@ namespace Xamarin.Forms.Platform.Android
|
|||
else if (controller.EffectiveFlowDirection.IsLeftToRight())
|
||||
view.LayoutDirection = ALayoutDirection.Ltr;
|
||||
}
|
||||
|
||||
internal static void UpdateHorizontalAlignment(this EditText view, TextAlignment alignment, bool hasRtlSupport, AGravityFlags orMask = AGravityFlags.NoGravity)
|
||||
{
|
||||
if ((int)Build.VERSION.SdkInt < 17 || !hasRtlSupport)
|
||||
view.Gravity = alignment.ToHorizontalGravityFlags() | orMask;
|
||||
else
|
||||
view.TextAlignment = alignment.ToTextAlignment();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using Android.OS;
|
||||
using Android.Widget;
|
||||
using AGravityFlags = Android.Views.GravityFlags;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
{
|
||||
internal static class TextAlignmentExtensions
|
||||
{
|
||||
internal static void UpdateHorizontalAlignment(this EditText view, TextAlignment alignment, bool hasRtlSupport, AGravityFlags orMask = AGravityFlags.NoGravity)
|
||||
{
|
||||
if ((int)Build.VERSION.SdkInt < 17 || !hasRtlSupport)
|
||||
view.Gravity = alignment.ToHorizontalGravityFlags() | orMask;
|
||||
else
|
||||
view.TextAlignment = alignment.ToTextAlignment();
|
||||
}
|
||||
|
||||
internal static void UpdateVerticalAlignment(this EditText view, TextAlignment alignment, AGravityFlags orMask = AGravityFlags.NoGravity)
|
||||
{
|
||||
view.Gravity = alignment.ToVerticalGravityFlags() | orMask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -179,7 +179,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
UpdateInputType();
|
||||
UpdateColor();
|
||||
UpdateCharacterSpacing();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateFont();
|
||||
UpdatePlaceholderColor();
|
||||
UpdateMaxLength();
|
||||
|
@ -242,7 +243,9 @@ namespace Xamarin.Forms.Platform.Android
|
|||
else if (e.PropertyName == Entry.IsTextPredictionEnabledProperty.PropertyName)
|
||||
UpdateInputType();
|
||||
else if (e.PropertyName == Entry.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if(e.PropertyName == Entry.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == Entry.CharacterSpacingProperty.PropertyName)
|
||||
UpdateCharacterSpacing();
|
||||
else if (e.PropertyName == Entry.FontAttributesProperty.PropertyName)
|
||||
|
@ -254,7 +257,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
else if (e.PropertyName == Entry.PlaceholderColorProperty.PropertyName)
|
||||
UpdatePlaceholderColor();
|
||||
else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == InputView.MaxLengthProperty.PropertyName)
|
||||
UpdateMaxLength();
|
||||
else if (e.PropertyName == PlatformConfiguration.AndroidSpecific.Entry.ImeOptionsProperty.PropertyName)
|
||||
|
@ -288,11 +291,16 @@ namespace Xamarin.Forms.Platform.Android
|
|||
EditText.ImeOptions = _currentInputImeFlag;
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
EditText.UpdateHorizontalAlignment(Element.HorizontalTextAlignment, Context.HasRtlSupport());
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
EditText.UpdateVerticalAlignment(Element.VerticalTextAlignment);
|
||||
}
|
||||
|
||||
protected abstract void UpdateColor();
|
||||
protected abstract void UpdateTextColor(Color color);
|
||||
|
||||
|
|
|
@ -111,7 +111,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
UpdateEnabled();
|
||||
UpdateCancelButtonColor();
|
||||
UpdateFont();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateTextColor();
|
||||
UpdateCharacterSpacing();
|
||||
UpdatePlaceholderColor();
|
||||
|
@ -145,13 +146,15 @@ namespace Xamarin.Forms.Platform.Android
|
|||
else if (e.PropertyName == SearchBar.FontSizeProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == SearchBar.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == SearchBar.VerticalOptionsProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == SearchBar.TextColorProperty.PropertyName)
|
||||
UpdateTextColor();
|
||||
else if (e.PropertyName == SearchBar.PlaceholderColorProperty.PropertyName)
|
||||
UpdatePlaceholderColor();
|
||||
else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == InputView.MaxLengthProperty.PropertyName)
|
||||
UpdateMaxLength();
|
||||
else if(e.PropertyName == InputView.KeyboardProperty.PropertyName)
|
||||
|
@ -166,7 +169,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
ClearFocus(Control);
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
_editText = _editText ?? Control.GetChildrenOfType<EditText>().FirstOrDefault();
|
||||
|
||||
|
@ -176,6 +179,16 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_editText.UpdateHorizontalAlignment(Element.HorizontalTextAlignment, Context.HasRtlSupport(), Xamarin.Forms.TextAlignment.Center.ToVerticalGravityFlags());
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
_editText = _editText ?? Control.GetChildrenOfType<EditText>().FirstOrDefault();
|
||||
|
||||
if (_editText == null)
|
||||
return;
|
||||
|
||||
_editText.UpdateVerticalAlignment(Element.VerticalTextAlignment, Xamarin.Forms.TextAlignment.Center.ToVerticalGravityFlags());
|
||||
}
|
||||
|
||||
void UpdateCancelButtonColor()
|
||||
{
|
||||
int searchViewCloseButtonId = Control.Resources.GetIdentifier("android:id/search_close_btn", null, null);
|
||||
|
@ -329,4 +342,4 @@ namespace Xamarin.Forms.Platform.Android
|
|||
return LocalizedDigitsKeyListener.Create(inputTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_hintColorSwitcher = new TextColorSwitcher(_editText.HintTextColors, false);
|
||||
UpdateSearchBarColors();
|
||||
UpdateFont();
|
||||
UpdateTextAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateInputType();
|
||||
}
|
||||
|
||||
|
@ -87,7 +88,11 @@ namespace Xamarin.Forms.Platform.Android
|
|||
}
|
||||
else if (e.Is(SearchHandler.HorizontalTextAlignmentProperty))
|
||||
{
|
||||
UpdateTextAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
}
|
||||
else if (e.Is(SearchHandler.VerticalTextAlignmentProperty))
|
||||
{
|
||||
UpdateVerticalTextAlignment();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,11 +115,16 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_hintColorSwitcher?.UpdateTextColor(_editText, _searchHandler.PlaceholderColor, _editText.SetHintTextColor);
|
||||
}
|
||||
|
||||
void UpdateTextAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
_editText.UpdateHorizontalAlignment(_searchHandler.HorizontalTextAlignment, _control.Context.HasRtlSupport(), Xamarin.Forms.TextAlignment.Center.ToVerticalGravityFlags());
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
_editText.UpdateVerticalAlignment(_searchHandler.VerticalTextAlignment, Xamarin.Forms.TextAlignment.Center.ToVerticalGravityFlags());
|
||||
}
|
||||
|
||||
void UpdateBackgroundColor()
|
||||
{
|
||||
var linearLayout = (_control as ViewGroup).GetChildrenOfType<LinearLayout>().FirstOrDefault();
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
<Compile Include="Extensions\EntryRendererExtensions.cs" />
|
||||
<Compile Include="Extensions\FragmentManagerExtensions.cs" />
|
||||
<Compile Include="Extensions\ScrollViewExtensions.cs" />
|
||||
<Compile Include="Extensions\TextAlignmentExtensions.cs" />
|
||||
<Compile Include="FastRenderers\AutomationPropertiesProvider.cs" />
|
||||
<Compile Include="AppCompat\PageExtensions.cs" />
|
||||
<Compile Include="Extensions\JavaObjectExtensions.cs" />
|
||||
|
|
|
@ -58,7 +58,8 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
UpdateTextColor();
|
||||
UpdateFont();
|
||||
UpdateCharacterSpacing();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdatePlaceholderColor();
|
||||
UpdateMaxLength();
|
||||
UpdateDetectReadingOrderFromContent();
|
||||
|
@ -128,11 +129,13 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
else if (e.PropertyName == Entry.FontSizeProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == Entry.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == Entry.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == Entry.PlaceholderColorProperty.PropertyName)
|
||||
UpdatePlaceholderColor();
|
||||
else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == InputView.MaxLengthProperty.PropertyName)
|
||||
UpdateMaxLength();
|
||||
else if (e.PropertyName == Specifics.DetectReadingOrderFromContentProperty.PropertyName)
|
||||
|
@ -184,11 +187,16 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
((IEntryController)Element).SendCompleted();
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
Control.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment(((IVisualElementController)Element).EffectiveFlowDirection);
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
Control.VerticalContentAlignment = Element.VerticalTextAlignment.ToNativeVerticalAlignment();
|
||||
}
|
||||
|
||||
void UpdateFont()
|
||||
{
|
||||
if (Control == null)
|
||||
|
|
|
@ -220,7 +220,8 @@
|
|||
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||
Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Grid.Row="1"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="Disabled" />
|
||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="Disabled"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
<ContentControl x:Name="PlaceholderTextContentPresenter" Grid.ColumnSpan="2"
|
||||
Content="{TemplateBinding PlaceholderText}"
|
||||
Foreground="{TemplateBinding PlaceholderForegroundBrush}" IsHitTestVisible="False"
|
||||
|
@ -228,7 +229,8 @@
|
|||
Grid.Row="1"
|
||||
HorizontalAlignment="{Binding TextAlignment,
|
||||
RelativeSource={RelativeSource Mode=TemplatedParent},
|
||||
Converter={StaticResource AlignmentConverter}}" />
|
||||
Converter={StaticResource AlignmentConverter}}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Button x:Name="DeleteButton" BorderThickness="{TemplateBinding BorderThickness}" Grid.Column="1"
|
||||
FontSize="{TemplateBinding FontSize}" IsTabStop="False" Margin="{ThemeResource HelperButtonThemePadding}"
|
||||
MinWidth="34" Grid.Row="1" Style="{StaticResource DeleteButtonStyle}" Visibility="Collapsed"
|
||||
|
|
|
@ -39,7 +39,8 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
UpdateText();
|
||||
UpdatePlaceholder();
|
||||
UpdateCancelButtonColor();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateCharacterSpacing();
|
||||
UpdateFont();
|
||||
UpdateTextColor();
|
||||
|
@ -61,7 +62,9 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
else if (e.PropertyName == SearchBar.CancelButtonColorProperty.PropertyName)
|
||||
UpdateCancelButtonColor();
|
||||
else if (e.PropertyName == SearchBar.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == SearchBar.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == SearchBar.FontAttributesProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == SearchBar.CharacterSpacingProperty.PropertyName)
|
||||
|
@ -75,7 +78,7 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
else if (e.PropertyName == SearchBar.PlaceholderColorProperty.PropertyName)
|
||||
UpdatePlaceholderColor();
|
||||
else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == Specifics.IsSpellCheckEnabledProperty.PropertyName)
|
||||
UpdateIsSpellCheckEnabled();
|
||||
else if(e.PropertyName == InputView.MaxLengthProperty.PropertyName)
|
||||
|
@ -96,7 +99,8 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
_cancelButton.ReadyChanged += (o, args) => UpdateCancelButtonColor();
|
||||
}
|
||||
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateTextColor();
|
||||
UpdatePlaceholderColor();
|
||||
UpdateBackgroundColor();
|
||||
|
@ -129,7 +133,7 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
((IElementController)Element).SetValueFromRenderer(SearchBar.TextProperty, sender.Text);
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
if (_queryTextBox == null)
|
||||
return;
|
||||
|
@ -137,6 +141,14 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
_queryTextBox.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment(((IVisualElementController)Element).EffectiveFlowDirection);
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
if (_queryTextBox == null)
|
||||
return;
|
||||
|
||||
_queryTextBox.VerticalContentAlignment = Element.VerticalTextAlignment.ToNativeVerticalAlignment();
|
||||
}
|
||||
|
||||
void UpdateCancelButtonColor()
|
||||
{
|
||||
if (_cancelButton == null || !_cancelButton.IsReady)
|
||||
|
|
|
@ -18,6 +18,21 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
}
|
||||
}
|
||||
|
||||
internal static VerticalAlignment ToNativeVerticalAlignment(this TextAlignment alignment)
|
||||
{
|
||||
switch (alignment)
|
||||
{
|
||||
case TextAlignment.Start:
|
||||
return VerticalAlignment.Top;
|
||||
case TextAlignment.Center:
|
||||
return VerticalAlignment.Center;
|
||||
case TextAlignment.End:
|
||||
return VerticalAlignment.Bottom;
|
||||
default:
|
||||
return VerticalAlignment.Top;
|
||||
}
|
||||
}
|
||||
|
||||
internal static VerticalAlignment ToNativeVerticalAlignment(this LayoutOptions alignment)
|
||||
{
|
||||
switch (alignment.Alignment)
|
||||
|
|
|
@ -32,7 +32,8 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
UpdatePlaceholder();
|
||||
UpdateColor();
|
||||
UpdateFont();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdatePlaceholderColor();
|
||||
UpdateMaxLength();
|
||||
UpdateIsReadOnly();
|
||||
|
@ -62,7 +63,9 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
else if (e.PropertyName == Entry.FontSizeProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == Entry.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == Entry.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == Entry.PlaceholderColorProperty.PropertyName)
|
||||
UpdatePlaceholderColor();
|
||||
else if (e.PropertyName == InputView.MaxLengthProperty.PropertyName)
|
||||
|
@ -117,7 +120,7 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
_ignoreTextChange = false;
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
if (Control == null)
|
||||
return;
|
||||
|
@ -125,6 +128,14 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
Control.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment();
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
if (Control == null)
|
||||
return;
|
||||
|
||||
Control.VerticalContentAlignment = Element.VerticalTextAlignment.ToNativeVerticalAlignment();
|
||||
}
|
||||
|
||||
void UpdateColor()
|
||||
{
|
||||
if (Control == null)
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
UpdateText();
|
||||
UpdateTextDecorations();
|
||||
UpdateColor();
|
||||
UpdateAlign();
|
||||
UpdateHorizontalTextAlign();
|
||||
UpdateVerticalTextAlign();
|
||||
UpdateFont();
|
||||
UpdateLineBreakMode();
|
||||
UpdatePadding();
|
||||
|
@ -54,8 +55,10 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
UpdateTextDecorations();
|
||||
else if (e.PropertyName == Label.TextColorProperty.PropertyName)
|
||||
UpdateColor();
|
||||
else if (e.PropertyName == Label.HorizontalTextAlignmentProperty.PropertyName || e.PropertyName == Label.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlign();
|
||||
else if (e.PropertyName == Label.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateHorizontalTextAlign();
|
||||
else if (e.PropertyName == Label.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlign();
|
||||
else if (e.PropertyName == Label.FontProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == Label.LineBreakModeProperty.PropertyName)
|
||||
|
@ -92,7 +95,7 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
}
|
||||
|
||||
|
||||
void UpdateAlign()
|
||||
void UpdateHorizontalTextAlign()
|
||||
{
|
||||
if (Control == null)
|
||||
return;
|
||||
|
@ -104,6 +107,18 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
Control.TextAlignment = label.HorizontalTextAlignment.ToNativeTextAlignment();
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlign()
|
||||
{
|
||||
if (Control == null)
|
||||
return;
|
||||
|
||||
Label label = Element;
|
||||
if (label == null)
|
||||
return;
|
||||
|
||||
Control.VerticalAlignment = label.VerticalTextAlignment.ToNativeVerticalAlignment();
|
||||
}
|
||||
|
||||
void UpdateColor()
|
||||
{
|
||||
if (Control == null || Element == null)
|
||||
|
|
|
@ -31,7 +31,8 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
// Update control property
|
||||
UpdateText();
|
||||
UpdatePlaceholder();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateFont();
|
||||
UpdatePlaceholderColor();
|
||||
UpdateTextColor();
|
||||
|
@ -55,7 +56,9 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
else if (e.PropertyName == SearchBar.FontSizeProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == SearchBar.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == SearchBar.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == SearchBar.PlaceholderColorProperty.PropertyName)
|
||||
UpdatePlaceholderColor();
|
||||
else if (e.PropertyName == SearchBar.TextColorProperty.PropertyName)
|
||||
|
@ -73,11 +76,16 @@ namespace Xamarin.Forms.Platform.WPF
|
|||
((IElementController)Element).SetValueFromRenderer(SearchBar.TextProperty, Control.Text);
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
Control.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment();
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
Control.VerticalContentAlignment = Element.VerticalTextAlignment.ToNativeVerticalAlignment();
|
||||
}
|
||||
|
||||
void UpdateFont()
|
||||
{
|
||||
if (Control == null)
|
||||
|
|
|
@ -24,5 +24,20 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
return UITextAlignment.Natural;
|
||||
}
|
||||
}
|
||||
|
||||
internal static UIControlContentVerticalAlignment ToNativeTextAlignment(this TextAlignment alignment)
|
||||
{
|
||||
switch (alignment)
|
||||
{
|
||||
case TextAlignment.Center:
|
||||
return UIControlContentVerticalAlignment.Center;
|
||||
case TextAlignment.End:
|
||||
return UIControlContentVerticalAlignment.Bottom;
|
||||
case TextAlignment.Start:
|
||||
return UIControlContentVerticalAlignment.Top;
|
||||
default:
|
||||
return UIControlContentVerticalAlignment.Top;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -135,7 +135,8 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
UpdateCharacterSpacing();
|
||||
UpdateColor();
|
||||
UpdateKeyboard();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateAdjustsFontSizeToFitWidth();
|
||||
UpdateMaxLength();
|
||||
UpdateReturnType();
|
||||
|
@ -169,7 +170,9 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
else if (e.PropertyName == Entry.IsTextPredictionEnabledProperty.PropertyName)
|
||||
UpdateKeyboard();
|
||||
else if (e.PropertyName == Entry.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == Entry.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == Entry.FontAttributesProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == Entry.FontFamilyProperty.PropertyName)
|
||||
|
@ -184,7 +187,7 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
else if (e.PropertyName == Specifics.AdjustsFontSizeToFitWidthProperty.PropertyName)
|
||||
UpdateAdjustsFontSizeToFitWidth();
|
||||
else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == Xamarin.Forms.InputView.MaxLengthProperty.PropertyName)
|
||||
UpdateMaxLength();
|
||||
else if (e.PropertyName == Entry.ReturnTypeProperty.PropertyName)
|
||||
|
@ -246,11 +249,16 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
return false;
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
Control.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment(((IVisualElementController)Element).EffectiveFlowDirection);
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
Control.VerticalAlignment = Element.VerticalTextAlignment.ToNativeTextAlignment();
|
||||
}
|
||||
|
||||
protected virtual void UpdateColor()
|
||||
{
|
||||
var textColor = Element.TextColor;
|
||||
|
|
|
@ -166,7 +166,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
}
|
||||
|
||||
UpdateLineBreakMode();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateText();
|
||||
UpdateTextDecorations();
|
||||
UpdateTextColor();
|
||||
|
@ -184,7 +184,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
base.OnElementPropertyChanged(sender, e);
|
||||
|
||||
if (e.PropertyName == Label.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == Label.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateLayout();
|
||||
else if (e.PropertyName == Label.TextColorProperty.PropertyName)
|
||||
|
@ -209,7 +209,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
else if (e.PropertyName == Label.LineBreakModeProperty.PropertyName)
|
||||
UpdateLineBreakMode();
|
||||
else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == Label.LineHeightProperty.PropertyName)
|
||||
UpdateText();
|
||||
else if (e.PropertyName == Label.MaxLinesProperty.PropertyName)
|
||||
|
@ -311,7 +311,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
#if __MOBILE__
|
||||
Control.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment(((IVisualElementController)Element).EffectiveFlowDirection);
|
||||
|
|
|
@ -75,7 +75,8 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
UpdateFont();
|
||||
UpdateIsEnabled();
|
||||
UpdateCancelButton();
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
UpdateVerticalTextAlignment();
|
||||
UpdateTextColor();
|
||||
UpdateCharacterSpacing();
|
||||
UpdateMaxLength();
|
||||
|
@ -117,9 +118,11 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
else if (e.PropertyName == SearchBar.FontSizeProperty.PropertyName)
|
||||
UpdateFont();
|
||||
else if (e.PropertyName == SearchBar.HorizontalTextAlignmentProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if (e.PropertyName == SearchBar.VerticalTextAlignmentProperty.PropertyName)
|
||||
UpdateVerticalTextAlignment();
|
||||
else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
|
||||
UpdateAlignment();
|
||||
UpdateHorizontalTextAlignment();
|
||||
else if(e.PropertyName == Xamarin.Forms.InputView.MaxLengthProperty.PropertyName)
|
||||
UpdateMaxLength();
|
||||
else if(e.PropertyName == Xamarin.Forms.InputView.KeyboardProperty.PropertyName)
|
||||
|
@ -204,7 +207,7 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
_textField.AttributedPlaceholder = _textField.AttributedPlaceholder.AddCharacterSpacing(Element.Placeholder, Element.CharacterSpacing);
|
||||
}
|
||||
|
||||
void UpdateAlignment()
|
||||
void UpdateHorizontalTextAlignment()
|
||||
{
|
||||
_textField = _textField ?? Control.FindDescendantView<UITextField>();
|
||||
|
||||
|
@ -214,6 +217,16 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
_textField.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment(((IVisualElementController)Element).EffectiveFlowDirection);
|
||||
}
|
||||
|
||||
void UpdateVerticalTextAlignment()
|
||||
{
|
||||
_textField = _textField ?? Control.FindDescendantView<UITextField>();
|
||||
|
||||
if (_textField == null)
|
||||
return;
|
||||
|
||||
_textField.VerticalAlignment = Element.VerticalTextAlignment.ToNativeTextAlignment();
|
||||
}
|
||||
|
||||
void UpdateCancelButton()
|
||||
{
|
||||
Control.ShowsCancelButton = !string.IsNullOrEmpty(Control.Text);
|
||||
|
|
|
@ -34,7 +34,8 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
GetDefaultSearchBarColors(_uiSearchBar);
|
||||
var uiTextField = searchBar.FindDescendantView<UITextField>();
|
||||
UpdateSearchBarColors();
|
||||
UpdateSearchBarTextAlignment(uiTextField);
|
||||
UpdateSearchBarHorizontalTextAlignment(uiTextField);
|
||||
UpdateSearchBarVerticalTextAlignment(uiTextField);
|
||||
UpdateFont(uiTextField);
|
||||
UpdateKeyboard();
|
||||
}
|
||||
|
@ -84,7 +85,11 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
}
|
||||
else if (e.Is(SearchHandler.HorizontalTextAlignmentProperty))
|
||||
{
|
||||
UpdateSearchBarTextAlignment(_uiSearchBar.FindDescendantView<UITextField>());
|
||||
UpdateSearchBarHorizontalTextAlignment(_uiSearchBar.FindDescendantView<UITextField>());
|
||||
}
|
||||
else if (e.Is(SearchHandler.VerticalTextAlignmentProperty))
|
||||
{
|
||||
UpdateSearchBarVerticalTextAlignment(_uiSearchBar.FindDescendantView<UITextField>());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +247,7 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
|
||||
}
|
||||
|
||||
void UpdateSearchBarTextAlignment(UITextField textField)
|
||||
void UpdateSearchBarHorizontalTextAlignment(UITextField textField)
|
||||
{
|
||||
if (textField == null)
|
||||
return;
|
||||
|
@ -250,6 +255,14 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
textField.TextAlignment = _searchHandler.HorizontalTextAlignment.ToNativeTextAlignment(EffectiveFlowDirection.Explicit);
|
||||
}
|
||||
|
||||
void UpdateSearchBarVerticalTextAlignment(UITextField textField)
|
||||
{
|
||||
if (textField == null)
|
||||
return;
|
||||
|
||||
textField.VerticalAlignment = _searchHandler.VerticalTextAlignment.ToNativeTextAlignment();
|
||||
}
|
||||
|
||||
void UpdateKeyboard()
|
||||
{
|
||||
var keyboard = _searchHandler.Keyboard;
|
||||
|
|
Загрузка…
Ссылка в новой задаче