diff --git a/src/Controls/src/Core/Application/Application.Mapper.cs b/src/Controls/src/Core/Application/Application.Mapper.cs index 95ae7fe97631..bfcbf1b82b54 100644 --- a/src/Controls/src/Core/Application/Application.Mapper.cs +++ b/src/Controls/src/Core/Application/Application.Mapper.cs @@ -1,22 +1,22 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class Application { + [Obsolete("Use ApplicationHandler.Mapper instead.")] public static IPropertyMapper ControlsApplicationMapper = - new PropertyMapper(ApplicationHandler.Mapper) - { -#if ANDROID - // There is also a mapper on Window for this property since this property is relevant at the window level for - // Android not the application level - [PlatformConfiguration.AndroidSpecific.Application.WindowSoftInputModeAdjustProperty.PropertyName] = MapWindowSoftInputModeAdjust, -#endif - }; + new PropertyMapper(ApplicationHandler.Mapper); - internal static void RemapForControls() + internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.Application legacy behaviors - ApplicationHandler.Mapper = ControlsApplicationMapper; +#if ANDROID + // There is also a mapper on Window for this property since this property is relevant at the window level for + // Android not the application level + ApplicationHandler.Mapper.ReplaceMapping(PlatformConfiguration.AndroidSpecific.Application.WindowSoftInputModeAdjustProperty.PropertyName, MapWindowSoftInputModeAdjust); +#endif } } } diff --git a/src/Controls/src/Core/Button/Button.Mapper.cs b/src/Controls/src/Core/Button/Button.Mapper.cs index bdaa308ccaaa..6023f9dfb434 100644 --- a/src/Controls/src/Core/Button/Button.Mapper.cs +++ b/src/Controls/src/Core/Button/Button.Mapper.cs @@ -14,24 +14,22 @@ public partial class Button /// /// The property mapper that maps the abstract properties to the platform-specific methods for further processing. /// - public static IPropertyMapper ControlsButtonMapper = new PropertyMapper(ButtonHandler.Mapper) + [Obsolete("Use ButtonHandler.Mapper instead.")] + public static IPropertyMapper ControlsButtonMapper = new PropertyMapper(ButtonHandler.Mapper); + + internal new static void RemapForControls() { - [nameof(ContentLayout)] = MapContentLayout, + ButtonHandler.Mapper.ReplaceMapping(nameof(ContentLayout), MapContentLayout); #if IOS - [nameof(Padding)] = MapPadding, + ButtonHandler.Mapper.ReplaceMapping(nameof(Padding), MapPadding); #endif #if WINDOWS - [nameof(IText.Text)] = MapText, - [nameof(ImageSource)] = MapImageSource, + ButtonHandler.Mapper.ReplaceMapping(nameof(ImageSource), MapImageSource); #endif - [nameof(TextTransform)] = MapText, - [nameof(Text)] = MapText, - [nameof(Button.LineBreakMode)] = MapLineBreakMode, - }; + ButtonHandler.Mapper.ReplaceMapping(nameof(Text), MapText); - internal new static void RemapForControls() - { - ButtonHandler.Mapper = ControlsButtonMapper; + ButtonHandler.Mapper.ReplaceMapping(nameof(TextTransform), MapText); + ButtonHandler.Mapper.ReplaceMapping(nameof(Button.LineBreakMode), MapLineBreakMode); } /// diff --git a/src/Controls/src/Core/CheckBox/CheckBox.Mapper.cs b/src/Controls/src/Core/CheckBox/CheckBox.Mapper.cs index 329657297759..cff12f89bc8a 100644 --- a/src/Controls/src/Core/CheckBox/CheckBox.Mapper.cs +++ b/src/Controls/src/Core/CheckBox/CheckBox.Mapper.cs @@ -9,18 +9,14 @@ namespace Microsoft.Maui.Controls { public partial class CheckBox { - // TODO Make public for NET8 - internal static IPropertyMapper ControlsCheckBoxMapper = new PropertyMapper(CheckBoxHandler.Mapper) + internal new static void RemapForControls() { - [nameof(Color)] = (handler, view) => - { - handler?.UpdateValue(nameof(ICheckBox.Foreground)); - } - }; + CheckBoxHandler.Mapper.ReplaceMapping(nameof(Color), MapColor); + } - internal new static void RemapForControls() + internal static void MapColor(ICheckBoxHandler handler, ICheckBox view) { - CheckBoxHandler.Mapper = ControlsCheckBoxMapper; + handler?.UpdateValue(nameof(ICheckBox.Foreground)); } } } diff --git a/src/Controls/src/Core/DatePicker/DatePicker.Mapper.cs b/src/Controls/src/Core/DatePicker/DatePicker.Mapper.cs index 9e4a1430fb43..178f69c5b71c 100644 --- a/src/Controls/src/Core/DatePicker/DatePicker.Mapper.cs +++ b/src/Controls/src/Core/DatePicker/DatePicker.Mapper.cs @@ -1,19 +1,19 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class DatePicker { - public static IPropertyMapper ControlsDatePickerMapper = new PropertyMapper(DatePickerHandler.Mapper) - { -#if IOS - [PlatformConfiguration.iOSSpecific.DatePicker.UpdateModeProperty.PropertyName] = MapUpdateMode, -#endif - }; + [Obsolete("Use DatePickerHandler.Mapper instead.")] + public static IPropertyMapper ControlsDatePickerMapper = new PropertyMapper(DatePickerHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.DatePicker legacy behaviors - DatePickerHandler.Mapper = ControlsDatePickerMapper; +#if IOS + DatePickerHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.DatePicker.UpdateModeProperty.PropertyName, MapUpdateMode); +#endif } } } \ No newline at end of file diff --git a/src/Controls/src/Core/Editor/Editor.Android.cs b/src/Controls/src/Core/Editor/Editor.Android.cs index d67d92fd03d0..2f746734b8aa 100644 --- a/src/Controls/src/Core/Editor/Editor.Android.cs +++ b/src/Controls/src/Core/Editor/Editor.Android.cs @@ -5,19 +5,17 @@ namespace Microsoft.Maui.Controls { public partial class Editor { - public static void MapText(EditorHandler handler, Editor editor) + public static void MapText(EditorHandler handler, Editor editor) => + MapText((IEditorHandler)handler, editor); + + public static void MapText(IEditorHandler handler, Editor editor) { - if (handler.DataFlowDirection == DataFlowDirection.FromPlatform) + if (handler is ViewHandler viewHandler && viewHandler.DataFlowDirection == DataFlowDirection.FromPlatform) { Platform.EditTextExtensions.UpdateTextFromPlatform(handler.PlatformView, editor); return; } - MapText((IEditorHandler)handler, editor); - } - - public static void MapText(IEditorHandler handler, Editor editor) - { Platform.EditTextExtensions.UpdateText(handler.PlatformView, editor); } diff --git a/src/Controls/src/Core/Editor/Editor.Mapper.cs b/src/Controls/src/Core/Editor/Editor.Mapper.cs index 2eb66320065c..cebba14ce2cc 100644 --- a/src/Controls/src/Core/Editor/Editor.Mapper.cs +++ b/src/Controls/src/Core/Editor/Editor.Mapper.cs @@ -1,22 +1,22 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class Editor { + [Obsolete("Use EditorHandler.Mapper instead.")] public static IPropertyMapper ControlsEditorMapper = - new PropertyMapper(EditorHandler.Mapper) - { -#if WINDOWS - [PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName] = MapDetectReadingOrderFromContent, -#endif - [nameof(Text)] = MapText, - [nameof(TextTransform)] = MapText, - }; + new PropertyMapper(EditorHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.Editor legacy behaviors - EditorHandler.Mapper = ControlsEditorMapper; +#if WINDOWS + EditorHandler.Mapper.ReplaceMapping(PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName, MapDetectReadingOrderFromContent); +#endif + EditorHandler.Mapper.ReplaceMapping(nameof(Text), MapText); + EditorHandler.Mapper.ReplaceMapping(nameof(TextTransform), MapText); #if ANDROID EditorHandler.CommandMapper.PrependToMapping(nameof(IEditor.Focus), MapFocus); diff --git a/src/Controls/src/Core/Element/Element.Mapper.cs b/src/Controls/src/Core/Element/Element.Mapper.cs index 3472ad5c2d09..079dcfe9d3d1 100644 --- a/src/Controls/src/Core/Element/Element.Mapper.cs +++ b/src/Controls/src/Core/Element/Element.Mapper.cs @@ -13,5 +13,9 @@ public partial class Element [AutomationProperties.IsInAccessibleTreeProperty.PropertyName] = MapAutomationPropertiesIsInAccessibleTree, [AutomationProperties.ExcludedWithChildrenProperty.PropertyName] = MapAutomationPropertiesExcludedWithChildren, }; + + internal static void RemapForControls() + { + } } } diff --git a/src/Controls/src/Core/Entry/Entry.Android.cs b/src/Controls/src/Core/Entry/Entry.Android.cs index 267969957b3b..632cb653cb8d 100644 --- a/src/Controls/src/Core/Entry/Entry.Android.cs +++ b/src/Controls/src/Core/Entry/Entry.Android.cs @@ -11,16 +11,8 @@ public partial class Entry public static void MapImeOptions(EntryHandler handler, Entry entry) => MapImeOptions((IEntryHandler)handler, entry); - public static void MapText(EntryHandler handler, Entry entry) - { - if (handler.DataFlowDirection == DataFlowDirection.FromPlatform) - { - Platform.EditTextExtensions.UpdateTextFromPlatform(handler.PlatformView, entry); - return; - } - + public static void MapText(EntryHandler handler, Entry entry) => MapText((IEntryHandler)handler, entry); - } public static void MapImeOptions(IEntryHandler handler, Entry entry) { @@ -29,6 +21,12 @@ public static void MapImeOptions(IEntryHandler handler, Entry entry) public static void MapText(IEntryHandler handler, Entry entry) { + if (handler is ViewHandler viewHandler && viewHandler.DataFlowDirection == DataFlowDirection.FromPlatform) + { + Platform.EditTextExtensions.UpdateTextFromPlatform(handler.PlatformView, entry); + return; + } + Platform.EditTextExtensions.UpdateText(handler.PlatformView, entry); } diff --git a/src/Controls/src/Core/Entry/Entry.Mapper.cs b/src/Controls/src/Core/Entry/Entry.Mapper.cs index 6d6d2224257c..5194ca0e85b7 100644 --- a/src/Controls/src/Core/Entry/Entry.Mapper.cs +++ b/src/Controls/src/Core/Entry/Entry.Mapper.cs @@ -1,27 +1,27 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class Entry { + [Obsolete("Use EntryHandler.Mapper instead.")] public static IPropertyMapper ControlsEntryMapper = - new PropertyMapper(EntryHandler.Mapper) - { -#if ANDROID - [PlatformConfiguration.AndroidSpecific.Entry.ImeOptionsProperty.PropertyName] = MapImeOptions, -#elif WINDOWS - [PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName] = MapDetectReadingOrderFromContent, -#elif IOS - [PlatformConfiguration.iOSSpecific.Entry.CursorColorProperty.PropertyName] = MapCursorColor, - [PlatformConfiguration.iOSSpecific.Entry.AdjustsFontSizeToFitWidthProperty.PropertyName] = MapAdjustsFontSizeToFitWidth, -#endif - [nameof(Text)] = MapText, - [nameof(TextTransform)] = MapText, - }; + new PropertyMapper(EntryHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.Entry legacy behaviors - EntryHandler.Mapper = ControlsEntryMapper; +#if ANDROID + EntryHandler.Mapper.ReplaceMapping(PlatformConfiguration.AndroidSpecific.Entry.ImeOptionsProperty.PropertyName, MapImeOptions); +#elif WINDOWS + EntryHandler.Mapper.ReplaceMapping(PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName, MapDetectReadingOrderFromContent); +#elif IOS + EntryHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.Entry.CursorColorProperty.PropertyName, MapCursorColor); + EntryHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.Entry.AdjustsFontSizeToFitWidthProperty.PropertyName, MapAdjustsFontSizeToFitWidth); +#endif + EntryHandler.Mapper.ReplaceMapping(nameof(Text), MapText); + EntryHandler.Mapper.ReplaceMapping(nameof(TextTransform), MapText); #if ANDROID EntryHandler.CommandMapper.PrependToMapping(nameof(IEntry.Focus), MapFocus); diff --git a/src/Controls/src/Core/FlyoutPage/FlyoutPage.Mapper.cs b/src/Controls/src/Core/FlyoutPage/FlyoutPage.Mapper.cs index 312d10568048..21d6e8cff3e9 100644 --- a/src/Controls/src/Core/FlyoutPage/FlyoutPage.Mapper.cs +++ b/src/Controls/src/Core/FlyoutPage/FlyoutPage.Mapper.cs @@ -1,16 +1,21 @@ +using System; + namespace Microsoft.Maui.Controls { /// public partial class FlyoutPage { - public static IPropertyMapper ControlsFlyoutPageMapper = new PropertyMapper(FlyoutViewHandler.Mapper) - { - [nameof(FlyoutLayoutBehavior)] = (handler, __) => handler.UpdateValue(nameof(IFlyoutView.FlyoutBehavior)), - }; + [Obsolete("Use FlyoutViewHandler.Mapper instead.")] + public static IPropertyMapper ControlsFlyoutPageMapper = new PropertyMapper(FlyoutViewHandler.Mapper); internal new static void RemapForControls() { - FlyoutViewHandler.Mapper = ControlsFlyoutPageMapper; + FlyoutViewHandler.Mapper.ReplaceMapping(nameof(FlyoutLayoutBehavior), MapFlyoutLayoutBehavior); + } + + internal static void MapFlyoutLayoutBehavior(IFlyoutViewHandler handler, IFlyoutView view) + { + handler.UpdateValue(nameof(IFlyoutView.FlyoutBehavior)); } } } diff --git a/src/Controls/src/Core/Label/Label.Mapper.cs b/src/Controls/src/Core/Label/Label.Mapper.cs index 8295b7fb1486..21c452602254 100644 --- a/src/Controls/src/Core/Label/Label.Mapper.cs +++ b/src/Controls/src/Core/Label/Label.Mapper.cs @@ -1,4 +1,5 @@ #nullable disable +using System; using Microsoft.Maui.Handlers; namespace Microsoft.Maui.Controls @@ -6,25 +7,8 @@ namespace Microsoft.Maui.Controls /// public partial class Label { - public static IPropertyMapper ControlsLabelMapper = new PropertyMapper(LabelHandler.Mapper) - { - [nameof(TextType)] = MapTextType, - [nameof(Text)] = MapText, - [nameof(FormattedText)] = MapText, - [nameof(TextTransform)] = MapText, -#if WINDOWS - [PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName] = MapDetectReadingOrderFromContent, -#endif -#if IOS - [nameof(TextDecorations)] = MapTextDecorations, - [nameof(CharacterSpacing)] = MapCharacterSpacing, - [nameof(LineHeight)] = MapLineHeight, - [nameof(ILabel.Font)] = MapFont, - [nameof(TextColor)] = MapTextColor, -#endif - [nameof(Label.LineBreakMode)] = MapLineBreakMode, - [nameof(Label.MaxLines)] = MapMaxLines, - }; + [Obsolete("Use LabelHandler.Mapper instead.")] + public static IPropertyMapper ControlsLabelMapper = new PropertyMapper(LabelHandler.Mapper); internal static new void RemapForControls() { @@ -32,7 +16,22 @@ public partial class Label // ILabel does not include the TextType property, so we map it here to handle HTML text // And we map some of the other property handlers to Controls-specific versions that avoid stepping on HTML text settings - LabelHandler.Mapper = ControlsLabelMapper; + LabelHandler.Mapper.ReplaceMapping(nameof(TextType), MapTextType); + LabelHandler.Mapper.ReplaceMapping(nameof(Text), MapText); + LabelHandler.Mapper.ReplaceMapping(nameof(FormattedText), MapText); + LabelHandler.Mapper.ReplaceMapping(nameof(TextTransform), MapText); +#if WINDOWS + LabelHandler.Mapper.ReplaceMapping(PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName, MapDetectReadingOrderFromContent); +#endif +#if IOS + LabelHandler.Mapper.ModifyMapping(nameof(TextDecorations), MapTextDecorations); + LabelHandler.Mapper.ModifyMapping(nameof(CharacterSpacing), MapCharacterSpacing); + LabelHandler.Mapper.ModifyMapping(nameof(LineHeight), MapLineHeight); + LabelHandler.Mapper.ModifyMapping(nameof(ILabel.Font), MapFont); + LabelHandler.Mapper.ModifyMapping(nameof(TextColor), MapTextColor); +#endif + LabelHandler.Mapper.ReplaceMapping(nameof(Label.LineBreakMode), MapLineBreakMode); + LabelHandler.Mapper.ReplaceMapping(nameof(Label.MaxLines), MapMaxLines); } } } diff --git a/src/Controls/src/Core/Label/Label.iOS.cs b/src/Controls/src/Core/Label/Label.iOS.cs index e8a2bd4c41a9..9fbc97a15943 100644 --- a/src/Controls/src/Core/Label/Label.iOS.cs +++ b/src/Controls/src/Core/Label/Label.iOS.cs @@ -14,6 +14,20 @@ public partial class Label public static void MapFont(LabelHandler handler, Label label) => MapFont((ILabelHandler)handler, label); public static void MapTextColor(LabelHandler handler, Label label) => MapTextColor((ILabelHandler)handler, label); + public static void MapTextDecorations(ILabelHandler handler, Label label) => + MapTextDecorations(handler, label, (h, v) => LabelHandler.MapTextDecorations(handler, label)); + + public static void MapCharacterSpacing(ILabelHandler handler, Label label) => + MapCharacterSpacing(handler, label, (h, v) => LabelHandler.MapCharacterSpacing(handler, label)); + + public static void MapLineHeight(ILabelHandler handler, Label label) => + MapLineHeight(handler, label, (h, v) => LabelHandler.MapLineHeight(handler, label)); + + public static void MapFont(ILabelHandler handler, Label label) => + MapFont(handler, label, (h, v) => LabelHandler.MapFont(handler, label)); + + public static void MapTextColor(ILabelHandler handler, Label label) => + MapTextColor(handler, label, (h, v) => LabelHandler.MapTextColor(handler, label)); public static void MapTextType(ILabelHandler handler, Label label) { @@ -27,31 +41,31 @@ public static void MapText(ILabelHandler handler, Label label) MapFormatting(handler, label); } - public static void MapTextDecorations(ILabelHandler handler, Label label) + static void MapTextDecorations(ILabelHandler handler, Label label, Action baseMethod) { if (!IsPlainText(label)) return; - LabelHandler.MapTextDecorations(handler, label); + baseMethod?.Invoke(handler, label); } - public static void MapCharacterSpacing(ILabelHandler handler, Label label) + static void MapCharacterSpacing(ILabelHandler handler, Label label, Action baseMethod) { if (!IsPlainText(label)) return; - LabelHandler.MapCharacterSpacing(handler, label); + baseMethod?.Invoke(handler, label); } - public static void MapLineHeight(ILabelHandler handler, Label label) + static void MapLineHeight(ILabelHandler handler, Label label, Action baseMethod) { if (!IsPlainText(label)) return; - LabelHandler.MapLineHeight(handler, label); + baseMethod?.Invoke(handler, label); } - public static void MapFont(ILabelHandler handler, Label label) + static void MapFont(ILabelHandler handler, Label label, Action baseMethod) { if (label.HasFormattedTextSpans) return; @@ -63,10 +77,10 @@ public static void MapFont(ILabelHandler handler, Label label) return; } - LabelHandler.MapFont(handler, label); + baseMethod?.Invoke(handler, label); } - public static void MapTextColor(ILabelHandler handler, Label label) + static void MapTextColor(ILabelHandler handler, Label label, Action baseMethod) { if (label.HasFormattedTextSpans) return; @@ -78,7 +92,7 @@ public static void MapTextColor(ILabelHandler handler, Label label) return; } - LabelHandler.MapTextColor(handler, label); + baseMethod?.Invoke(handler, label); } public static void MapLineBreakMode(ILabelHandler handler, Label label) diff --git a/src/Controls/src/Core/Layout/Layout.Android.cs b/src/Controls/src/Core/Layout/Layout.Android.cs index 9051d3efff17..7358c05ccf40 100644 --- a/src/Controls/src/Core/Layout/Layout.Android.cs +++ b/src/Controls/src/Core/Layout/Layout.Android.cs @@ -7,6 +7,7 @@ namespace Microsoft.Maui.Controls { public partial class Layout { + [Obsolete] public static void MapInputTransparent(LayoutHandler handler, Layout layout) { } public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { } diff --git a/src/Controls/src/Core/Layout/Layout.Mapper.cs b/src/Controls/src/Core/Layout/Layout.Mapper.cs index 30ab4848e259..6a2f92c6a311 100644 --- a/src/Controls/src/Core/Layout/Layout.Mapper.cs +++ b/src/Controls/src/Core/Layout/Layout.Mapper.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Text; +using Microsoft.Maui.Layouts; namespace Microsoft.Maui.Controls { @@ -10,11 +11,9 @@ public abstract partial class Layout { internal static new void RemapForControls() { - ViewHandler.ViewMapper = ControlsLayoutMapper; } - public static IPropertyMapper ControlsLayoutMapper = new PropertyMapper(ControlsVisualElementMapper) - { - }; + [Obsolete("Use LayoutHandler.Mapper instead.")] + public static IPropertyMapper ControlsLayoutMapper = new PropertyMapper(ControlsVisualElementMapper); } } diff --git a/src/Controls/src/Core/Layout/Layout.Standard.cs b/src/Controls/src/Core/Layout/Layout.Standard.cs index 10e9d7de1a2f..b7524e857b4b 100644 --- a/src/Controls/src/Core/Layout/Layout.Standard.cs +++ b/src/Controls/src/Core/Layout/Layout.Standard.cs @@ -1,12 +1,17 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class Layout { + [Obsolete] public static void MapInputTransparent(LayoutHandler handler, Layout layout) { } + [Obsolete] public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { } + [Obsolete] static void MapInputTransparent(IViewHandler handler, IView layout) { } } } diff --git a/src/Controls/src/Core/Layout/Layout.Tizen.cs b/src/Controls/src/Core/Layout/Layout.Tizen.cs index 079d21ba8bda..fa9abdbe690d 100644 --- a/src/Controls/src/Core/Layout/Layout.Tizen.cs +++ b/src/Controls/src/Core/Layout/Layout.Tizen.cs @@ -1,10 +1,14 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class Layout { + [Obsolete] public static void MapInputTransparent(LayoutHandler handler, Layout layout) { } + [Obsolete] public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { } } } diff --git a/src/Controls/src/Core/Layout/Layout.Windows.cs b/src/Controls/src/Core/Layout/Layout.Windows.cs index 1c2001468d15..c153a143cb8b 100644 --- a/src/Controls/src/Core/Layout/Layout.Windows.cs +++ b/src/Controls/src/Core/Layout/Layout.Windows.cs @@ -1,12 +1,15 @@ #nullable disable +using System; using Microsoft.UI.Xaml; namespace Microsoft.Maui.Controls { public partial class Layout { + [Obsolete] public static void MapInputTransparent(LayoutHandler handler, Layout layout) { } + [Obsolete] public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { } } } \ No newline at end of file diff --git a/src/Controls/src/Core/Layout/Layout.iOS.cs b/src/Controls/src/Core/Layout/Layout.iOS.cs index 079d21ba8bda..fa9abdbe690d 100644 --- a/src/Controls/src/Core/Layout/Layout.iOS.cs +++ b/src/Controls/src/Core/Layout/Layout.iOS.cs @@ -1,10 +1,14 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class Layout { + [Obsolete] public static void MapInputTransparent(LayoutHandler handler, Layout layout) { } + [Obsolete] public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { } } } diff --git a/src/Controls/src/Core/NavigationPage/NavigationPage.Mapper.cs b/src/Controls/src/Core/NavigationPage/NavigationPage.Mapper.cs index 3eb4b0a92acf..7a769911ccbb 100644 --- a/src/Controls/src/Core/NavigationPage/NavigationPage.Mapper.cs +++ b/src/Controls/src/Core/NavigationPage/NavigationPage.Mapper.cs @@ -1,21 +1,21 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class NavigationPage { + [Obsolete("Use NavigationViewHandler.Mapper instead.")] public static IPropertyMapper ControlsNavigationPageMapper = - new PropertyMapper(NavigationViewHandler.Mapper) - { -#if IOS - [PlatformConfiguration.iOSSpecific.NavigationPage.PrefersLargeTitlesProperty.PropertyName] = MapPrefersLargeTitles, - [PlatformConfiguration.iOSSpecific.NavigationPage.IsNavigationBarTranslucentProperty.PropertyName] = MapIsNavigationBarTranslucent, -#endif - }; + new PropertyMapper(NavigationViewHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.NavigationPage legacy behaviors - NavigationViewHandler.Mapper = ControlsNavigationPageMapper; +#if IOS + NavigationViewHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.NavigationPage.PrefersLargeTitlesProperty.PropertyName, MapPrefersLargeTitles); + NavigationViewHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.NavigationPage.IsNavigationBarTranslucentProperty.PropertyName, MapIsNavigationBarTranslucent); +#endif } } } diff --git a/src/Controls/src/Core/Picker/Picker.Mapper.cs b/src/Controls/src/Core/Picker/Picker.Mapper.cs index b57f62536b7d..2e11e934603a 100644 --- a/src/Controls/src/Core/Picker/Picker.Mapper.cs +++ b/src/Controls/src/Core/Picker/Picker.Mapper.cs @@ -1,23 +1,28 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class Picker { - public static IPropertyMapper ControlsPickerMapper = new PropertyMapper(PickerHandler.Mapper) + [Obsolete("Use PickerHandler.Mapper instead.")] + public static IPropertyMapper ControlsPickerMapper = new PropertyMapper(PickerHandler.Mapper); + + internal static new void RemapForControls() { + // Adjust the mappings to preserve Controls.Picker legacy behaviors #if IOS - [PlatformConfiguration.iOSSpecific.Picker.UpdateModeProperty.PropertyName] = MapUpdateMode, + PickerHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.Picker.UpdateModeProperty.PropertyName, MapUpdateMode); #elif WINDOWS - [nameof(Picker.HorizontalOptions)] = MapHorizontalOptions, - [nameof(Picker.VerticalOptions)] = MapVerticalOptions, + PickerHandler.Mapper.ReplaceMapping(nameof(Picker.HorizontalOptions), MapHorizontalOptions); + PickerHandler.Mapper.ReplaceMapping(nameof(Picker.VerticalOptions), MapVerticalOptions); #endif - [nameof(Picker.ItemsSource)] = (handler, _) => handler.UpdateValue(nameof(IPicker.Items)) - }; + PickerHandler.Mapper.ReplaceMapping(nameof(Picker.ItemsSource), MapItemsSource); + } - internal static new void RemapForControls() + internal static void MapItemsSource(IPickerHandler handler, IPicker view) { - // Adjust the mappings to preserve Controls.Picker legacy behaviors - PickerHandler.Mapper = ControlsPickerMapper; + handler.UpdateValue(nameof(IPicker.Items)); } } } \ No newline at end of file diff --git a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt index 8a0d3b8c5b95..c7acb47b46e0 100644 --- a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt @@ -43,6 +43,8 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool ~override Microsoft.Maui.Controls.LayoutOptions.Equals(object obj) -> bool ~override Microsoft.Maui.Controls.Region.Equals(object obj) -> bool ~override Microsoft.Maui.Controls.Shapes.Matrix.Equals(object obj) -> bool +~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.IRadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void +~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.RadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void ~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable rectangles) -> Microsoft.Maui.Controls.Region ~static readonly Microsoft.Maui.Controls.InputView.IsTextPredictionEnabledProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.WebView.UserAgentProperty -> Microsoft.Maui.Controls.BindableProperty diff --git a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt index e7cdaebd6c32..d8de2c97dc8c 100644 --- a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -77,6 +77,8 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool ~override Microsoft.Maui.Controls.LayoutOptions.Equals(object obj) -> bool ~override Microsoft.Maui.Controls.Region.Equals(object obj) -> bool ~override Microsoft.Maui.Controls.Shapes.Matrix.Equals(object obj) -> bool +~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.IRadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void +~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.RadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void ~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable rectangles) -> Microsoft.Maui.Controls.Region ~static readonly Microsoft.Maui.Controls.InputView.IsTextPredictionEnabledProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.WebView.UserAgentProperty -> Microsoft.Maui.Controls.BindableProperty diff --git a/src/Controls/src/Core/RadioButton/RadioButton.Android.cs b/src/Controls/src/Core/RadioButton/RadioButton.Android.cs index 0f26e3932f39..e39c5e5bc415 100644 --- a/src/Controls/src/Core/RadioButton/RadioButton.Android.cs +++ b/src/Controls/src/Core/RadioButton/RadioButton.Android.cs @@ -28,7 +28,7 @@ public static void MapContent(IRadioButtonHandler handler, RadioButton radioButt static AView? CreatePlatformView(ViewHandler radioButton) { - // If someone is using a completely different type for IRadioButton + // If someone is using a completely different type for IRadioButton if (radioButton.VirtualView is not RadioButton rb) return null; diff --git a/src/Controls/src/Core/RadioButton/RadioButton.Mapper.cs b/src/Controls/src/Core/RadioButton/RadioButton.Mapper.cs index 1a28b7e86d44..dbaa2c718b97 100644 --- a/src/Controls/src/Core/RadioButton/RadioButton.Mapper.cs +++ b/src/Controls/src/Core/RadioButton/RadioButton.Mapper.cs @@ -8,17 +8,13 @@ public partial class RadioButton { IMauiContext MauiContext => Handler?.MauiContext ?? throw new InvalidOperationException("MauiContext not set"); + [Obsolete("Use RadioButtonHandler.Mapper instead.")] public static IPropertyMapper ControlsRadioButtonMapper = - new PropertyMapper(RadioButtonHandler.Mapper) - { -#if IOS || ANDROID || WINDOWS || TIZEN - [nameof(IRadioButton.Content)] = MapContent -#endif - }; + new PropertyMapper(RadioButtonHandler.Mapper); internal new static void RemapForControls() { - RadioButtonHandler.Mapper = ControlsRadioButtonMapper; + RadioButtonHandler.Mapper.ReplaceMapping(nameof(IRadioButton.Content), MapContent); #if ANDROID RadioButtonHandler.PlatformViewFactory = CreatePlatformView; diff --git a/src/Controls/src/Core/RadioButton/RadioButton.Standard.cs b/src/Controls/src/Core/RadioButton/RadioButton.Standard.cs new file mode 100644 index 000000000000..8f2613404714 --- /dev/null +++ b/src/Controls/src/Core/RadioButton/RadioButton.Standard.cs @@ -0,0 +1,13 @@ +#nullable disable +namespace Microsoft.Maui.Controls +{ + public partial class RadioButton + { + public static void MapContent(RadioButtonHandler handler, RadioButton radioButton) + => MapContent((IRadioButtonHandler)handler, radioButton); + + public static void MapContent(IRadioButtonHandler handler, RadioButton radioButton) + { + } + } +} diff --git a/src/Controls/src/Core/RefreshView/RefreshView.Mapper.cs b/src/Controls/src/Core/RefreshView/RefreshView.Mapper.cs index 8d748b184f83..9e0a24aff513 100644 --- a/src/Controls/src/Core/RefreshView/RefreshView.Mapper.cs +++ b/src/Controls/src/Core/RefreshView/RefreshView.Mapper.cs @@ -1,19 +1,19 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class RefreshView { - public static IPropertyMapper ControlsRefreshViewMapper = new PropertyMapper(RefreshViewHandler.Mapper) - { -#if WINDOWS - [PlatformConfiguration.WindowsSpecific.RefreshView.RefreshPullDirectionProperty.PropertyName] = MapRefreshPullDirection, -#endif - }; + [Obsolete("Use RefreshViewHandler.Mapper instead.")] + public static IPropertyMapper ControlsRefreshViewMapper = new PropertyMapper(RefreshViewHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.RefreshView legacy behaviors - RefreshViewHandler.Mapper = ControlsRefreshViewMapper; +#if WINDOWS + RefreshViewHandler.Mapper.ReplaceMapping(PlatformConfiguration.WindowsSpecific.RefreshView.RefreshPullDirectionProperty.PropertyName, MapRefreshPullDirection); +#endif } } } \ No newline at end of file diff --git a/src/Controls/src/Core/ScrollView/ScrollView.Mapper.cs b/src/Controls/src/Core/ScrollView/ScrollView.Mapper.cs index aee9e1bbad72..7025aef607af 100644 --- a/src/Controls/src/Core/ScrollView/ScrollView.Mapper.cs +++ b/src/Controls/src/Core/ScrollView/ScrollView.Mapper.cs @@ -1,20 +1,20 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class ScrollView { + [Obsolete("Use ScrollViewHandler.Mapper instead.")] public static IPropertyMapper ControlsScrollViewMapper = - new PropertyMapper(ScrollViewHandler.Mapper) - { -#if IOS - [PlatformConfiguration.iOSSpecific.ScrollView.ShouldDelayContentTouchesProperty.PropertyName] = MapShouldDelayContentTouches, -#endif - }; + new PropertyMapper(ScrollViewHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.ScrollView legacy behaviors - ScrollViewHandler.Mapper = ControlsScrollViewMapper; +#if IOS + ScrollViewHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.ScrollView.ShouldDelayContentTouchesProperty.PropertyName, MapShouldDelayContentTouches); +#endif } } } diff --git a/src/Controls/src/Core/SearchBar/SearchBar.Mapper.cs b/src/Controls/src/Core/SearchBar/SearchBar.Mapper.cs index b562e8aaeb5f..8333bf5d11b0 100644 --- a/src/Controls/src/Core/SearchBar/SearchBar.Mapper.cs +++ b/src/Controls/src/Core/SearchBar/SearchBar.Mapper.cs @@ -1,22 +1,22 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class SearchBar { + [Obsolete("Use SearchBarHandler.Mapper instead.")] public static IPropertyMapper ControlsSearchBarMapper = - new PropertyMapper(SearchBarHandler.Mapper) - { -#if IOS - [PlatformConfiguration.iOSSpecific.SearchBar.SearchBarStyleProperty.PropertyName] = MapSearchBarStyle, -#endif - [nameof(Text)] = MapText, - [nameof(TextTransform)] = MapText, - }; + new PropertyMapper(SearchBarHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.SearchBar legacy behaviors - SearchBarHandler.Mapper = ControlsSearchBarMapper; +#if IOS + SearchBarHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.SearchBar.SearchBarStyleProperty.PropertyName, MapSearchBarStyle); +#endif + SearchBarHandler.Mapper.ReplaceMapping(nameof(Text), MapText); + SearchBarHandler.Mapper.ReplaceMapping(nameof(TextTransform), MapText); #if ANDROID SearchBarHandler.CommandMapper.PrependToMapping(nameof(ISearchBar.Focus), MapFocus); diff --git a/src/Controls/src/Core/Shape/Shape.Mapper.cs b/src/Controls/src/Core/Shape/Shape.Mapper.cs index e02007797ab7..6614ba9d39f9 100644 --- a/src/Controls/src/Core/Shape/Shape.Mapper.cs +++ b/src/Controls/src/Core/Shape/Shape.Mapper.cs @@ -10,14 +10,12 @@ namespace Microsoft.Maui.Controls.Shapes { public partial class Shape { - public static IPropertyMapper ControlsShapeViewMapper = new PropertyMapper(ShapeViewHandler.Mapper) - { - [nameof(StrokeDashArray)] = MapStrokeDashArray, - }; + [Obsolete("Use ShapeViewHandler.Mapper instead.")] + public static IPropertyMapper ControlsShapeViewMapper = new PropertyMapper(ShapeViewHandler.Mapper); internal new static void RemapForControls() { - ShapeViewHandler.Mapper = ControlsShapeViewMapper; + ShapeViewHandler.Mapper.ReplaceMapping(nameof(StrokeDashArray), MapStrokeDashArray); } } } diff --git a/src/Controls/src/Core/TabbedPage/TabbedPage.Mapper.cs b/src/Controls/src/Core/TabbedPage/TabbedPage.Mapper.cs index 1da6ecd2f905..e1fe6c1b39b9 100644 --- a/src/Controls/src/Core/TabbedPage/TabbedPage.Mapper.cs +++ b/src/Controls/src/Core/TabbedPage/TabbedPage.Mapper.cs @@ -7,25 +7,23 @@ namespace Microsoft.Maui.Controls { public partial class TabbedPage { - public static IPropertyMapper ControlsTabbedPageMapper = new PropertyMapper(TabbedViewHandler.Mapper) - { - [nameof(BarBackground)] = MapBarBackground, - [nameof(BarBackgroundColor)] = MapBarBackgroundColor, - [nameof(BarTextColor)] = MapBarTextColor, - [nameof(UnselectedTabColor)] = MapUnselectedTabColor, - [nameof(SelectedTabColor)] = MapSelectedTabColor, - [nameof(MultiPage.ItemsSource)] = MapItemsSource, - [nameof(MultiPage.ItemTemplate)] = MapItemTemplate, - [nameof(MultiPage.SelectedItem)] = MapSelectedItem, - [nameof(CurrentPage)] = MapCurrentPage, -#if ANDROID - [PlatformConfiguration.AndroidSpecific.TabbedPage.IsSwipePagingEnabledProperty.PropertyName] = MapIsSwipePagingEnabled -#endif - }; + [Obsolete("Use TabbedViewHandler.Mapper instead.")] + public static IPropertyMapper ControlsTabbedPageMapper = new PropertyMapper(TabbedViewHandler.Mapper); internal new static void RemapForControls() { - TabbedViewHandler.Mapper = ControlsTabbedPageMapper; + TabbedViewHandler.Mapper.ReplaceMapping(nameof(BarBackground), MapBarBackground); + TabbedViewHandler.Mapper.ReplaceMapping(nameof(BarBackgroundColor), MapBarBackgroundColor); + TabbedViewHandler.Mapper.ReplaceMapping(nameof(BarTextColor), MapBarTextColor); + TabbedViewHandler.Mapper.ReplaceMapping(nameof(UnselectedTabColor), MapUnselectedTabColor); + TabbedViewHandler.Mapper.ReplaceMapping(nameof(SelectedTabColor), MapSelectedTabColor); + TabbedViewHandler.Mapper.ReplaceMapping(nameof(MultiPage.ItemsSource), MapItemsSource); + TabbedViewHandler.Mapper.ReplaceMapping(nameof(MultiPage.ItemTemplate), MapItemTemplate); + TabbedViewHandler.Mapper.ReplaceMapping(nameof(MultiPage.SelectedItem), MapSelectedItem); + TabbedViewHandler.Mapper.ReplaceMapping(nameof(CurrentPage), MapCurrentPage); +#if ANDROID + TabbedViewHandler.Mapper.ReplaceMapping(PlatformConfiguration.AndroidSpecific.TabbedPage.IsSwipePagingEnabledProperty.PropertyName, MapIsSwipePagingEnabled); +#endif #if WINDOWS || ANDROID || TIZEN TabbedViewHandler.PlatformViewFactory = OnCreatePlatformView; diff --git a/src/Controls/src/Core/TimePicker/TimePicker.Mapper.cs b/src/Controls/src/Core/TimePicker/TimePicker.Mapper.cs index 82592ea83e1f..ff07314cb681 100644 --- a/src/Controls/src/Core/TimePicker/TimePicker.Mapper.cs +++ b/src/Controls/src/Core/TimePicker/TimePicker.Mapper.cs @@ -1,19 +1,19 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class TimePicker { - public static IPropertyMapper ControlsTimePickerMapper = new PropertyMapper(TimePickerHandler.Mapper) - { -#if IOS - [PlatformConfiguration.iOSSpecific.TimePicker.UpdateModeProperty.PropertyName] = MapUpdateMode, -#endif - }; + [Obsolete("Use TimePickerHandler.Mapper instead.")] + public static IPropertyMapper ControlsTimePickerMapper = new PropertyMapper(TimePickerHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.TimePicker legacy behaviors - TimePickerHandler.Mapper = ControlsTimePickerMapper; +#if IOS + TimePickerHandler.Mapper.ReplaceMapping(PlatformConfiguration.iOSSpecific.TimePicker.UpdateModeProperty.PropertyName, MapUpdateMode); +#endif } } } \ No newline at end of file diff --git a/src/Controls/src/Core/Toolbar/Toolbar.Mapper.cs b/src/Controls/src/Core/Toolbar/Toolbar.Mapper.cs index 700bd0865702..f1c7a0e18410 100644 --- a/src/Controls/src/Core/Toolbar/Toolbar.Mapper.cs +++ b/src/Controls/src/Core/Toolbar/Toolbar.Mapper.cs @@ -12,30 +12,28 @@ public partial class Toolbar { IMauiContext MauiContext => Handler?.MauiContext ?? throw new InvalidOperationException("MauiContext not set"); + [Obsolete("Use ToolbarHandler.Mapper instead.")] public static IPropertyMapper ControlsToolbarMapper = - new PropertyMapper(ToolbarHandler.Mapper) - { + new PropertyMapper(ToolbarHandler.Mapper); + + internal static void RemapForControls() + { #if ANDROID || WINDOWS || TIZEN - [nameof(IToolbar.IsVisible)] = MapIsVisible, - [nameof(IToolbar.BackButtonVisible)] = MapBackButtonVisible, - [nameof(Toolbar.TitleIcon)] = MapTitleIcon, - [nameof(Toolbar.TitleView)] = MapTitleView, - [nameof(Toolbar.IconColor)] = MapIconColor, - [nameof(Toolbar.ToolbarItems)] = MapToolbarItems, - [nameof(Toolbar.BackButtonTitle)] = MapBackButtonTitle, - [nameof(Toolbar.BarBackground)] = MapBarBackground, - [nameof(Toolbar.BarTextColor)] = MapBarTextColor, + ToolbarHandler.Mapper.ReplaceMapping(nameof(IToolbar.IsVisible), MapIsVisible); + ToolbarHandler.Mapper.ReplaceMapping(nameof(IToolbar.BackButtonVisible), MapBackButtonVisible); + ToolbarHandler.Mapper.ReplaceMapping(nameof(Toolbar.TitleIcon), MapTitleIcon); + ToolbarHandler.Mapper.ReplaceMapping(nameof(Toolbar.TitleView), MapTitleView); + ToolbarHandler.Mapper.ReplaceMapping(nameof(Toolbar.IconColor), MapIconColor); + ToolbarHandler.Mapper.ReplaceMapping(nameof(Toolbar.ToolbarItems), MapToolbarItems); + ToolbarHandler.Mapper.ReplaceMapping(nameof(Toolbar.BackButtonTitle), MapBackButtonTitle); + ToolbarHandler.Mapper.ReplaceMapping(nameof(Toolbar.BarBackground), MapBarBackground); + ToolbarHandler.Mapper.ReplaceMapping(nameof(Toolbar.BarTextColor), MapBarTextColor); #endif #if WINDOWS - [nameof(Toolbar.BackButtonEnabled)] = MapBackButtonEnabled, - [PlatformConfiguration.WindowsSpecific.Page.ToolbarPlacementProperty.PropertyName] = MapToolbarPlacement, - [PlatformConfiguration.WindowsSpecific.Page.ToolbarDynamicOverflowEnabledProperty.PropertyName] = MapToolbarDynamicOverflowEnabled, + ToolbarHandler.Mapper.ReplaceMapping(nameof(Toolbar.BackButtonEnabled), MapBackButtonEnabled); + ToolbarHandler.Mapper.ReplaceMapping(PlatformConfiguration.WindowsSpecific.Page.ToolbarPlacementProperty.PropertyName, MapToolbarPlacement); + ToolbarHandler.Mapper.ReplaceMapping(PlatformConfiguration.WindowsSpecific.Page.ToolbarDynamicOverflowEnabledProperty.PropertyName, MapToolbarDynamicOverflowEnabled); #endif - }; - - internal static void RemapForControls() - { - ToolbarHandler.Mapper = ControlsToolbarMapper; } } } diff --git a/src/Controls/src/Core/VisualElement/VisualElement.Mapper.cs b/src/Controls/src/Core/VisualElement/VisualElement.Mapper.cs index f702843fbb8a..22f955171bf5 100644 --- a/src/Controls/src/Core/VisualElement/VisualElement.Mapper.cs +++ b/src/Controls/src/Core/VisualElement/VisualElement.Mapper.cs @@ -24,7 +24,7 @@ public partial class VisualElement [nameof(IViewHandler.ContainerView)] = MapContainerView, }; - internal static void RemapForControls() + internal static new void RemapForControls() { ViewHandler.ViewMapper = ControlsVisualElementMapper; @@ -68,7 +68,7 @@ static void MapContainerView(IViewHandler arg1, IView arg2) static void MapFocus(IViewHandler handler, VisualElement view, object args, Action baseMethod) { - if (args is not FocusRequest fr) + if (args is not FocusRequest fr || view is not VisualElement element) return; view.MapFocus(fr, baseMethod is null ? null : () => baseMethod?.Invoke(handler, view, args)); diff --git a/src/Controls/src/Core/WebView/WebView.Mapper.cs b/src/Controls/src/Core/WebView/WebView.Mapper.cs index c894feb9718d..094606d3b971 100644 --- a/src/Controls/src/Core/WebView/WebView.Mapper.cs +++ b/src/Controls/src/Core/WebView/WebView.Mapper.cs @@ -1,21 +1,21 @@ #nullable disable +using System; + namespace Microsoft.Maui.Controls { public partial class WebView { - public static IPropertyMapper ControlsWebViewMapper = new PropertyMapper(WebViewHandler.Mapper) - { -#if ANDROID - [PlatformConfiguration.AndroidSpecific.WebView.DisplayZoomControlsProperty.PropertyName] = MapDisplayZoomControls, - [PlatformConfiguration.AndroidSpecific.WebView.EnableZoomControlsProperty.PropertyName] = MapEnableZoomControls, - [PlatformConfiguration.AndroidSpecific.WebView.MixedContentModeProperty.PropertyName] = MapMixedContentMode, -#endif - }; + [Obsolete("Use WebViewHandler.Mapper instead.")] + public static IPropertyMapper ControlsWebViewMapper = new PropertyMapper(WebViewHandler.Mapper); internal static new void RemapForControls() { // Adjust the mappings to preserve Controls.WebView legacy behaviors - WebViewHandler.Mapper = ControlsWebViewMapper; +#if ANDROID + WebViewHandler.Mapper.ReplaceMapping(PlatformConfiguration.AndroidSpecific.WebView.DisplayZoomControlsProperty.PropertyName, MapDisplayZoomControls); + WebViewHandler.Mapper.ReplaceMapping(PlatformConfiguration.AndroidSpecific.WebView.EnableZoomControlsProperty.PropertyName, MapEnableZoomControls); + WebViewHandler.Mapper.ReplaceMapping(PlatformConfiguration.AndroidSpecific.WebView.MixedContentModeProperty.PropertyName, MapMixedContentMode); +#endif } } } diff --git a/src/Controls/src/Core/Window/Window.Mapper.cs b/src/Controls/src/Core/Window/Window.Mapper.cs index e9c563ab01c6..0472a0945e79 100644 --- a/src/Controls/src/Core/Window/Window.Mapper.cs +++ b/src/Controls/src/Core/Window/Window.Mapper.cs @@ -10,7 +10,7 @@ public partial class Window public static IPropertyMapper ControlsWindowMapper = new PropertyMapper(WindowHandler.Mapper); - internal static void RemapForControls() + internal static new void RemapForControls() { #if ANDROID // This property is also on the Application Mapper since that's where the attached property exists diff --git a/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs b/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs index 660d439c98cd..2516936b494e 100644 --- a/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs +++ b/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs @@ -218,6 +218,7 @@ internal static MauiAppBuilder ConfigureImageSourceHandlers(this MauiAppBuilder internal static MauiAppBuilder RemapForControls(this MauiAppBuilder builder) { // Update the mappings for IView/View to work specifically for Controls + Element.RemapForControls(); Application.RemapForControls(); VisualElement.RemapForControls(); Label.RemapForControls(); diff --git a/src/Controls/tests/DeviceTests/Elements/Application/ApplicationTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Application/ApplicationTests.Android.cs index a35c8021c6e6..874dfac2e9fc 100644 --- a/src/Controls/tests/DeviceTests/Elements/Application/ApplicationTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Application/ApplicationTests.Android.cs @@ -100,7 +100,7 @@ await InvokeOnMainThreadAsync(async () => class SoftInputApplicationHandlerStub : ApplicationHandler { - public SoftInputApplicationHandlerStub() : base(Application.ControlsApplicationMapper) + public SoftInputApplicationHandlerStub() : base(ApplicationHandler.Mapper) { } diff --git a/src/Controls/tests/DeviceTests/MapperTests.cs b/src/Controls/tests/DeviceTests/MapperTests.cs index cfa53f16a85e..581aa2de9642 100644 --- a/src/Controls/tests/DeviceTests/MapperTests.cs +++ b/src/Controls/tests/DeviceTests/MapperTests.cs @@ -28,8 +28,10 @@ class MapperGenericTypeCases : IEnumerable { private readonly List _data = new() { +#pragma warning disable CS0618 // Type or member is obsolete new object[] { VisualElement.ControlsVisualElementMapper, typeof(IView), typeof(IViewHandler) }, new object[] { Element.ControlsElementMapper, typeof(IElement), typeof(IElementHandler) }, +#pragma warning restore CS0618 // Type or member is obsolete new object[] { ViewHandler.ViewMapper, typeof(IView), typeof(IViewHandler) }, new object[] { ElementHandler.ElementMapper, typeof(IElement), typeof(IElementHandler) }, }; diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Android.cs b/src/Core/src/Handlers/Entry/EntryHandler.Android.cs index 15c87ac0906f..9080ba0da3b8 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Android.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Android.cs @@ -154,6 +154,7 @@ void OnTextChanged(object? sender, TextChangedEventArgs e) // Let the mapping know that the update is coming from changes to the platform control DataFlowDirection = DataFlowDirection.FromPlatform; + VirtualView.UpdateText(e); // Reset to the default direction