From f1660e85f520c8c6ac4fa212bd46bf34e7fcb535 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Fri, 1 Mar 2019 20:15:08 -0700 Subject: [PATCH] fix changed apis (#5426) * fix changed apis * increment language version * bring some back * update font * VisualElement fixes fixes #4644 fixes #5170 --- Xamarin.Forms.Core/HandlerAttribute.cs | 6 +++++- Xamarin.Forms.Core/VisualElement.cs | 5 +++++ .../MaterialEntryRenderer.cs | 15 +++++++++++---- Xamarin.Forms.Material.iOS/MaterialEntryRenderer.cs | 6 +++--- .../Renderers/EntryRenderer.cs | 20 +++++++++++++------- .../Renderers/PickerEditText.cs | 5 +++++ Xamarin.Forms.Platform.iOS/Extensions/Extensions.cs | 6 ++++++ .../Extensions/ToolbarItemExtensions.cs | 5 +++++ .../Renderers/EntryRenderer.cs | 6 +++--- 9 files changed, 56 insertions(+), 18 deletions(-) diff --git a/Xamarin.Forms.Core/HandlerAttribute.cs b/Xamarin.Forms.Core/HandlerAttribute.cs index a34f009..591ebaa 100644 --- a/Xamarin.Forms.Core/HandlerAttribute.cs +++ b/Xamarin.Forms.Core/HandlerAttribute.cs @@ -5,7 +5,11 @@ namespace Xamarin.Forms [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] public abstract class HandlerAttribute : Attribute { - protected HandlerAttribute(Type handler, Type target, Type[] supportedVisuals = null) + protected HandlerAttribute(Type handler, Type target) : this(handler, target, null) + { + } + + protected HandlerAttribute(Type handler, Type target, Type[] supportedVisuals) { SupportedVisuals = supportedVisuals ?? new[] { typeof(VisualMarker.DefaultVisual) }; TargetType = target; diff --git a/Xamarin.Forms.Core/VisualElement.cs b/Xamarin.Forms.Core/VisualElement.cs index cc9a739..cb7826c 100644 --- a/Xamarin.Forms.Core/VisualElement.cs +++ b/Xamarin.Forms.Core/VisualElement.cs @@ -8,6 +8,11 @@ namespace Xamarin.Forms { public partial class VisualElement : NavigableElement, IAnimatable, IVisualElementController, IResourcesProvider, IStyleElement, IFlowDirectionController, IPropertyPropagationController, IVisualController { + + public new static readonly BindableProperty NavigationProperty = NavigableElement.NavigationProperty; + + public new static readonly BindableProperty StyleProperty = NavigableElement.StyleProperty; + public static readonly BindableProperty InputTransparentProperty = BindableProperty.Create("InputTransparent", typeof(bool), typeof(VisualElement), default(bool)); public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create("IsEnabled", typeof(bool), diff --git a/Xamarin.Forms.Material.Android/MaterialEntryRenderer.cs b/Xamarin.Forms.Material.Android/MaterialEntryRenderer.cs index ef305ba..b7afe87 100644 --- a/Xamarin.Forms.Material.Android/MaterialEntryRenderer.cs +++ b/Xamarin.Forms.Material.Android/MaterialEntryRenderer.cs @@ -36,7 +36,7 @@ namespace Xamarin.Forms.Material.Android UpdateBackgroundColor(); } - protected override void UpdateTextColor() => ApplyTheme(); + protected override void UpdateColor() => ApplyTheme(); protected override void UpdateBackgroundColor() { @@ -46,17 +46,24 @@ namespace Xamarin.Forms.Material.Android _textInputLayout.BoxBackgroundColor = MaterialColors.CreateEntryFilledInputBackgroundColor(Element.BackgroundColor, Element.TextColor); } - protected internal override void UpdatePlaceHolderText() => _textInputLayout.SetHint(Element.Placeholder, Element); + protected override void UpdatePlaceHolderText() => _textInputLayout.SetHint(Element.Placeholder, Element); protected override EditText EditText => _textInputEditText; protected override void UpdatePlaceholderColor() => ApplyTheme(); - void ApplyTheme() => _textInputLayout?.ApplyTheme(Element.TextColor, Element.PlaceholderColor); + void ApplyTheme(Color textColor) => _textInputLayout?.ApplyTheme(textColor, Element.PlaceholderColor); + void ApplyTheme() => ApplyTheme(Element.TextColor); - protected internal override void UpdateFont() + protected override void UpdateTextColor(Color color) + { + ApplyTheme(color); + } + + protected override void UpdateFont() { base.UpdateFont(); _textInputLayout.Typeface = Element.ToTypeface(); _textInputEditText.SetTextSize(ComplexUnitType.Sp, (float)Element.FontSize); } + } } #endif \ No newline at end of file diff --git a/Xamarin.Forms.Material.iOS/MaterialEntryRenderer.cs b/Xamarin.Forms.Material.iOS/MaterialEntryRenderer.cs index 367701c..ee35dce 100644 --- a/Xamarin.Forms.Material.iOS/MaterialEntryRenderer.cs +++ b/Xamarin.Forms.Material.iOS/MaterialEntryRenderer.cs @@ -8,11 +8,11 @@ namespace Xamarin.Forms.Material.iOS { protected override MaterialTextField CreateNativeControl() => new MaterialTextField(this, Element); protected override void SetBackgroundColor(Color color) => ApplyTheme(); - protected internal override void UpdateColor() => Control?.UpdateTextColor(this); + protected override void UpdateColor() => Control?.UpdateTextColor(this); protected virtual void ApplyTheme() => Control?.ApplyTheme(this); - protected internal override void UpdatePlaceholder() => Control?.UpdatePlaceholder(this); + protected override void UpdatePlaceholder() => Control?.UpdatePlaceholder(this); - protected internal override void UpdateFont() + protected override void UpdateFont() { base.UpdateFont(); Control?.ApplyTypographyScheme(Element); diff --git a/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs index c64da8e..75acb2e 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs @@ -49,10 +49,15 @@ namespace Xamarin.Forms.Platform.Android _hintColorSwitcher.UpdateTextColor(EditText, Element.PlaceholderColor, EditText.SetHintTextColor); } - protected override void UpdateTextColor() + protected override void UpdateColor() + { + UpdateTextColor(Element.TextColor); + } + + protected override void UpdateTextColor(Color color) { _textColorSwitcher = _textColorSwitcher ?? new TextColorSwitcher(EditText.TextColors, Element.UseLegacyColorManagement()); - _textColorSwitcher.UpdateTextColor(EditText, Element.TextColor); + _textColorSwitcher.UpdateTextColor(EditText, color); } } @@ -155,7 +160,7 @@ namespace Xamarin.Forms.Platform.Android EditText.Text = Element.Text; UpdateInputType(); - UpdateTextColor(); + UpdateColor(); UpdateAlignment(); UpdateFont(); UpdatePlaceholderColor(); @@ -190,7 +195,7 @@ namespace Xamarin.Forms.Platform.Android } - internal protected virtual void UpdatePlaceHolderText() => EditText.Hint = Element.Placeholder; + protected virtual void UpdatePlaceHolderText() => EditText.Hint = Element.Placeholder; protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { @@ -211,7 +216,7 @@ namespace Xamarin.Forms.Platform.Android } } else if (e.PropertyName == Entry.TextColorProperty.PropertyName) - UpdateTextColor(); + UpdateColor(); else if (e.PropertyName == InputView.KeyboardProperty.PropertyName) UpdateInputType(); else if (e.PropertyName == InputView.IsSpellCheckEnabledProperty.PropertyName) @@ -268,9 +273,10 @@ namespace Xamarin.Forms.Platform.Android EditText.UpdateHorizontalAlignment(Element.HorizontalTextAlignment, Context.HasRtlSupport()); } - abstract protected void UpdateTextColor(); + protected abstract void UpdateColor(); + protected abstract void UpdateTextColor(Color color); - protected internal virtual void UpdateFont() + protected virtual void UpdateFont() { EditText.Typeface = Element.ToTypeface(); EditText.SetTextSize(ComplexUnitType.Sp, (float)Element.FontSize); diff --git a/Xamarin.Forms.Platform.Android/Renderers/PickerEditText.cs b/Xamarin.Forms.Platform.Android/Renderers/PickerEditText.cs index 5ac6558..c7a7a1a 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/PickerEditText.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/PickerEditText.cs @@ -16,6 +16,11 @@ namespace Xamarin.Forms.Platform.Android PickerManager.Init(this); } + public PickerEditText(Context context, IPickerRenderer pickerRenderer) : this(context) + { + + } + public override bool OnTouchEvent(MotionEvent e) { PickerManager.OnTouchEvent(this, e); diff --git a/Xamarin.Forms.Platform.iOS/Extensions/Extensions.cs b/Xamarin.Forms.Platform.iOS/Extensions/Extensions.cs index 807ab8e..828f206 100644 --- a/Xamarin.Forms.Platform.iOS/Extensions/Extensions.cs +++ b/Xamarin.Forms.Platform.iOS/Extensions/Extensions.cs @@ -5,6 +5,12 @@ namespace Xamarin.Forms.Platform.iOS { public static class Extensions { + public static void ApplyKeyboard(this IUITextInput textInput, Keyboard keyboard) + { + if(textInput is IUITextInputTraits traits) + ApplyKeyboard(traits, keyboard); + } + public static void ApplyKeyboard(this IUITextInputTraits textInput, Keyboard keyboard) { textInput.AutocapitalizationType = UITextAutocapitalizationType.None; diff --git a/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs b/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs index c581c26..98006be 100644 --- a/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs +++ b/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs @@ -9,6 +9,11 @@ namespace Xamarin.Forms.Platform.iOS { public static class ToolbarItemExtensions { + public static UIKit.UIBarButtonItem ToUIBarButtonItem(this Xamarin.Forms.ToolbarItem item, bool forceName) + { + return ToUIBarButtonItem(item, false, false); + } + public static UIBarButtonItem ToUIBarButtonItem(this ToolbarItem item, bool forceName = false, bool forcePrimary = false) { if (item.Order == ToolbarItemOrder.Secondary && !forcePrimary) diff --git a/Xamarin.Forms.Platform.iOS/Renderers/EntryRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/EntryRenderer.cs index 8b6780a..118e59a 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/EntryRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/EntryRenderer.cs @@ -239,7 +239,7 @@ namespace Xamarin.Forms.Platform.iOS Control.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment(((IVisualElementController)Element).EffectiveFlowDirection); } - protected internal virtual void UpdateColor() + protected virtual void UpdateColor() { var textColor = Element.TextColor; @@ -258,7 +258,7 @@ namespace Xamarin.Forms.Platform.iOS Control.AdjustsFontSizeToFitWidth = Element.OnThisPlatform().AdjustsFontSizeToFitWidth(); } - protected internal virtual void UpdateFont() + protected virtual void UpdateFont() { if (initialSize == CGSize.Empty) { @@ -306,7 +306,7 @@ namespace Xamarin.Forms.Platform.iOS Control.SecureTextEntry = Element.IsPassword; } - protected internal virtual void UpdatePlaceholder() + protected virtual void UpdatePlaceholder() { var formatted = (FormattedString)Element.Placeholder; -- 2.7.4