diff --git a/src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.Windows.cs b/src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.Windows.cs index 9a3192e8bf7e..6f6b5928e346 100644 --- a/src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.Windows.cs +++ b/src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.Windows.cs @@ -11,11 +11,9 @@ public partial class ActivityIndicatorHandler : ViewHandler protected override MauiButton CreateNativeView() => new MauiButton(); - protected override void SetupDefaults(MauiButton nativeView) + void SetupDefaults(MauiButton nativeView) { DefaultPadding = (UI.Xaml.Thickness)MauiWinUIApplication.Current.Resources["ButtonPadding"]; DefaultForeground = (UI.Xaml.Media.Brush)MauiWinUIApplication.Current.Resources["ButtonForegroundThemeBrush"]; DefaultBackground = (UI.Xaml.Media.Brush)MauiWinUIApplication.Current.Resources["ButtonBackgroundThemeBrush"]; - - base.SetupDefaults(nativeView); } protected override void ConnectHandler(MauiButton nativeView) diff --git a/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs b/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs index b92659930b12..d83dd96059a1 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs @@ -37,13 +37,11 @@ protected override void DisconnectHandler(UIButton nativeView) base.DisconnectHandler(nativeView); } - protected override void SetupDefaults(UIButton nativeView) + void SetupDefaults(UIButton nativeView) { ButtonTextColorDefaultNormal = nativeView.TitleColor(UIControlState.Normal); ButtonTextColorDefaultHighlighted = nativeView.TitleColor(UIControlState.Highlighted); ButtonTextColorDefaultDisabled = nativeView.TitleColor(UIControlState.Disabled); - - base.SetupDefaults(nativeView); } public static void MapText(ButtonHandler handler, IButton button) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.Android.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.Android.cs index 92a13e8e20eb..395cbd845b3c 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.Android.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.Android.cs @@ -27,12 +27,12 @@ protected override MauiDatePicker CreateNativeView() return mauiDatePicker; } - protected override void SetupDefaults(MauiDatePicker nativeView) + void SetupDefaults(MauiDatePicker nativeView) { _defaultBackground = nativeView.Background; _defaultTextColors = nativeView.TextColors; - base.SetupDefaults(nativeView); + } internal DatePickerDialog? DatePickerDialog { get { return _dialog; } } diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs index adea668ddcf7..b10377839c93 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs @@ -20,11 +20,11 @@ protected override void DisconnectHandler(CalendarDatePicker nativeView) nativeView.DateChanged -= DateChanged; } - protected override void SetupDefaults(CalendarDatePicker nativeView) + void SetupDefaults(CalendarDatePicker nativeView) { _defaultForeground = nativeView.Foreground; - base.SetupDefaults(nativeView); + } public static void MapFormat(DatePickerHandler handler, IDatePicker datePicker) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs index 6e7519ba0d98..8302bd70b992 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs @@ -64,11 +64,9 @@ protected override void DisconnectHandler(MauiDatePicker nativeView) base.DisconnectHandler(nativeView); } - protected override void SetupDefaults(MauiDatePicker nativeView) + void SetupDefaults(MauiDatePicker nativeView) { _defaultTextColor = nativeView.TextColor; - - base.SetupDefaults(nativeView); } public static void MapFormat(DatePickerHandler handler, IDatePicker datePicker) diff --git a/src/Core/src/Handlers/Defaults.cs b/src/Core/src/Handlers/Defaults.cs deleted file mode 100644 index a0f793fb8533..000000000000 --- a/src/Core/src/Handlers/Defaults.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Microsoft.Maui -{ - class Defaults - { - public static bool HasSetDefaults; - } -} \ No newline at end of file diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Android.cs b/src/Core/src/Handlers/Editor/EditorHandler.Android.cs index 50fd26fbf0b6..0120952240c3 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.Android.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.Android.cs @@ -44,9 +44,9 @@ protected override void DisconnectHandler(AppCompatEditText nativeView) FocusChangeListener.Handler = null; } - protected override void SetupDefaults(AppCompatEditText nativeView) + void SetupDefaults(AppCompatEditText nativeView) { - base.SetupDefaults(nativeView); + DefaultTextColors = nativeView.TextColors; DefaultPlaceholderTextColors = nativeView.HintTextColors; diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs b/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs index 5857c2a18dd4..970c99bf866a 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs @@ -28,12 +28,12 @@ protected override void DisconnectHandler(MauiTextBox nativeView) nativeView.LostFocus -= OnLostFocus; } - protected override void SetupDefaults(MauiTextBox nativeView) + void SetupDefaults(MauiTextBox nativeView) { _placeholderDefaultBrush = nativeView.PlaceholderForeground; _defaultPlaceholderColorFocusBrush = nativeView.PlaceholderForegroundFocusBrush; - base.SetupDefaults(nativeView); + } public static void MapText(EditorHandler handler, IEditor editor) diff --git a/src/Core/src/Handlers/Element/ElementHandler.cs b/src/Core/src/Handlers/Element/ElementHandler.cs index 2b771df6c3ac..07615601b038 100644 --- a/src/Core/src/Handlers/Element/ElementHandler.cs +++ b/src/Core/src/Handlers/Element/ElementHandler.cs @@ -8,8 +8,6 @@ public abstract partial class ElementHandler : IElementHandler { }; - protected abstract bool HasSetDefaults { get; set; } - protected PropertyMapper _mapper; protected readonly PropertyMapper _defaultMapper; @@ -54,13 +52,6 @@ public virtual void SetVirtualView(IElement view) ConnectHandler(NativeView); } - if (!HasSetDefaults) - { - SetupDefaults(NativeView); - - HasSetDefaults = true; - } - _mapper = _defaultMapper; if (VirtualView is IPropertyMapperView imv) @@ -89,11 +80,6 @@ public virtual void UpdateValue(string property) object CreateNativeElement() => OnCreateNativeElement(); - private protected abstract void OnSetupDefaults(object nativeView); - - void SetupDefaults(object nativeView) => - OnSetupDefaults(nativeView); - private protected abstract void OnConnectHandler(object nativeView); void ConnectHandler(object nativeView) => diff --git a/src/Core/src/Handlers/Element/ElementHandlerOfT.cs b/src/Core/src/Handlers/Element/ElementHandlerOfT.cs index b4ed5d4857c1..322564ad89ba 100644 --- a/src/Core/src/Handlers/Element/ElementHandlerOfT.cs +++ b/src/Core/src/Handlers/Element/ElementHandlerOfT.cs @@ -9,7 +9,6 @@ public abstract partial class ElementHandler : Elemen [HotReload.OnHotReload] internal static void OnHotReload() { - Defaults>.HasSetDefaults = false; } protected ElementHandler(PropertyMapper mapper) @@ -33,18 +32,8 @@ protected ElementHandler(PropertyMapper mapper) object? IElementHandler.NativeView => base.NativeView; - protected override bool HasSetDefaults - { - get => Defaults>.HasSetDefaults; - set => Defaults>.HasSetDefaults = value; - } - protected abstract TNativeView CreateNativeElement(); - protected virtual void SetupDefaults(TNativeView nativeView) - { - } - protected virtual void ConnectHandler(TNativeView nativeView) { } @@ -56,9 +45,6 @@ protected virtual void DisconnectHandler(TNativeView nativeView) private protected override object OnCreateNativeElement() => CreateNativeElement(); - private protected override void OnSetupDefaults(object nativeView) => - SetupDefaults((TNativeView)nativeView); - private protected override void OnConnectHandler(object nativeView) => ConnectHandler((TNativeView)nativeView); diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Android.cs b/src/Core/src/Handlers/Entry/EntryHandler.Android.cs index b4fcde9f174d..fbeca6cf628a 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Android.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Android.cs @@ -58,9 +58,9 @@ protected override void DisconnectHandler(AppCompatEditText nativeView) ActionListener.Handler = null; } - protected override void SetupDefaults(AppCompatEditText nativeView) + void SetupDefaults(AppCompatEditText nativeView) { - base.SetupDefaults(nativeView); + ClearButtonDrawable = GetClearButtonDrawable(); DefaultTextColors = nativeView.TextColors; diff --git a/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs b/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs index 9f0772889c8c..bc2e715eac34 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs @@ -40,7 +40,7 @@ protected override void DisconnectHandler(MauiTextField nativeView) nativeView.ShouldChangeCharacters -= OnShouldChangeCharacters; } - protected override void SetupDefaults(MauiTextField nativeView) + void SetupDefaults(MauiTextField nativeView) { DefaultTextColor = nativeView.TextColor; } diff --git a/src/Core/src/Handlers/Label/LabelHandler.Android.cs b/src/Core/src/Handlers/Label/LabelHandler.Android.cs index e21fbdb997a0..512f018d92e2 100644 --- a/src/Core/src/Handlers/Label/LabelHandler.Android.cs +++ b/src/Core/src/Handlers/Label/LabelHandler.Android.cs @@ -18,7 +18,7 @@ public partial class LabelHandler : ViewHandler protected override TextView CreateNativeView() => new TextView(Context); - protected override void SetupDefaults(TextView nativeView) + void SetupDefaults(TextView nativeView) { if (nativeView.TextColors == null) { diff --git a/src/Core/src/Handlers/Picker/PickerHandler.Android.cs b/src/Core/src/Handlers/Picker/PickerHandler.Android.cs index 93f4056f1e27..235a4f594653 100644 --- a/src/Core/src/Handlers/Picker/PickerHandler.Android.cs +++ b/src/Core/src/Handlers/Picker/PickerHandler.Android.cs @@ -38,9 +38,9 @@ protected override void DisconnectHandler(MauiPicker nativeView) base.DisconnectHandler(nativeView); } - protected override void SetupDefaults(MauiPicker nativeView) + void SetupDefaults(MauiPicker nativeView) { - base.SetupDefaults(nativeView); + DefaultBackground = nativeView.Background; DefaultTitleColors = nativeView.HintTextColors; diff --git a/src/Core/src/Handlers/Picker/PickerHandler.Windows.cs b/src/Core/src/Handlers/Picker/PickerHandler.Windows.cs index b09a6ff4b0c5..18e78e42c64a 100644 --- a/src/Core/src/Handlers/Picker/PickerHandler.Windows.cs +++ b/src/Core/src/Handlers/Picker/PickerHandler.Windows.cs @@ -28,11 +28,11 @@ protected override void DisconnectHandler(MauiComboBox nativeView) nativeView.SelectionChanged -= OnControlSelectionChanged; } - protected override void SetupDefaults(MauiComboBox nativeView) + void SetupDefaults(MauiComboBox nativeView) { _defaultForeground = nativeView.Foreground; - base.SetupDefaults(nativeView); + } void Reload() { diff --git a/src/Core/src/Handlers/SearchBar/SearchBarHandler.Android.cs b/src/Core/src/Handlers/SearchBar/SearchBarHandler.Android.cs index ef6e6c2298f8..23f106095615 100644 --- a/src/Core/src/Handlers/SearchBar/SearchBarHandler.Android.cs +++ b/src/Core/src/Handlers/SearchBar/SearchBarHandler.Android.cs @@ -22,11 +22,11 @@ protected override SearchView CreateNativeView() return searchView; } - protected override void SetupDefaults(SearchView nativeView) + void SetupDefaults(SearchView nativeView) { DefaultBackground = nativeView.Background; - base.SetupDefaults(nativeView); + } // This is a Android-specific mapping diff --git a/src/Core/src/Handlers/SearchBar/SearchBarHandler.iOS.cs b/src/Core/src/Handlers/SearchBar/SearchBarHandler.iOS.cs index 018b1fb6042f..552e32b43869 100644 --- a/src/Core/src/Handlers/SearchBar/SearchBarHandler.iOS.cs +++ b/src/Core/src/Handlers/SearchBar/SearchBarHandler.iOS.cs @@ -47,7 +47,7 @@ protected override void DisconnectHandler(UISearchBar nativeView) base.DisconnectHandler(nativeView); } - protected override void SetupDefaults(UISearchBar nativeView) + void SetupDefaults(UISearchBar nativeView) { _defaultTextColor = QueryEditor?.TextColor; @@ -60,7 +60,7 @@ protected override void SetupDefaults(UISearchBar nativeView) _cancelButtonTextColorDefaultDisabled = cancelButton.TitleColor(UIControlState.Disabled); } - base.SetupDefaults(nativeView); + } public static void MapText(SearchBarHandler handler, ISearchBar searchBar) diff --git a/src/Core/src/Handlers/Slider/SliderHandler.Android.cs b/src/Core/src/Handlers/Slider/SliderHandler.Android.cs index 519eb027918f..374b70796381 100644 --- a/src/Core/src/Handlers/Slider/SliderHandler.Android.cs +++ b/src/Core/src/Handlers/Slider/SliderHandler.Android.cs @@ -37,7 +37,7 @@ protected override void DisconnectHandler(SeekBar nativeView) nativeView.SetOnSeekBarChangeListener(null); } - protected override void SetupDefaults(SeekBar nativeView) + void SetupDefaults(SeekBar nativeView) { DefaultThumbColorFilter = nativeView.Thumb?.GetColorFilter(); DefaultProgressTintMode = nativeView.ProgressTintMode; diff --git a/src/Core/src/Handlers/Slider/SliderHandler.Windows.cs b/src/Core/src/Handlers/Slider/SliderHandler.Windows.cs index d7589af54475..619b6c836ff1 100644 --- a/src/Core/src/Handlers/Slider/SliderHandler.Windows.cs +++ b/src/Core/src/Handlers/Slider/SliderHandler.Windows.cs @@ -48,7 +48,7 @@ protected override void DisconnectHandler(MauiSlider nativeView) _pointerReleasedHandler = null; } - protected override void SetupDefaults(MauiSlider nativeView) + void SetupDefaults(MauiSlider nativeView) { DefaultForegroundColor = nativeView.Foreground; DefaultBackgroundColor = nativeView.Background; diff --git a/src/Core/src/Handlers/Slider/SliderHandler.iOS.cs b/src/Core/src/Handlers/Slider/SliderHandler.iOS.cs index ecac783996c8..fffbe62f090b 100644 --- a/src/Core/src/Handlers/Slider/SliderHandler.iOS.cs +++ b/src/Core/src/Handlers/Slider/SliderHandler.iOS.cs @@ -29,7 +29,7 @@ protected override void DisconnectHandler(UISlider nativeView) nativeView.RemoveTarget(OnTouchUpControlEvent, UIControlEvent.TouchUpInside | UIControlEvent.TouchUpOutside); } - protected override void SetupDefaults(UISlider nativeView) + void SetupDefaults(UISlider nativeView) { DefaultMinTrackColor = nativeView.MinimumTrackTintColor; DefaultMaxTrackColor = nativeView.MaximumTrackTintColor; diff --git a/src/Core/src/Handlers/Switch/SwitchHandler.Android.cs b/src/Core/src/Handlers/Switch/SwitchHandler.Android.cs index 829c93ebf9e4..c537ce6db90c 100644 --- a/src/Core/src/Handlers/Switch/SwitchHandler.Android.cs +++ b/src/Core/src/Handlers/Switch/SwitchHandler.Android.cs @@ -30,7 +30,7 @@ protected override void DisconnectHandler(ASwitch nativeView) nativeView.SetOnCheckedChangeListener(null); } - protected override void SetupDefaults(ASwitch nativeView) + void SetupDefaults(ASwitch nativeView) { DefaultTrackColorStateList = nativeView.GetDefaultSwitchTrackColorStateList(); DefaultThumbColorStateList = nativeView.GetDefaultSwitchThumbColorStateList(); diff --git a/src/Core/src/Handlers/Switch/SwitchHandler.iOS.cs b/src/Core/src/Handlers/Switch/SwitchHandler.iOS.cs index 506b319fed8d..611619951f68 100644 --- a/src/Core/src/Handlers/Switch/SwitchHandler.iOS.cs +++ b/src/Core/src/Handlers/Switch/SwitchHandler.iOS.cs @@ -29,7 +29,7 @@ protected override void DisconnectHandler(UISwitch nativeView) nativeView.ValueChanged -= OnControlValueChanged; } - protected override void SetupDefaults(UISwitch nativeView) + void SetupDefaults(UISwitch nativeView) { DefaultOnTrackColor = UISwitch.Appearance.OnTintColor; DefaultOffTrackColor = nativeView.GetOffTrackColor(); diff --git a/src/Core/src/Handlers/TimePicker/TimePickerHandler.Android.cs b/src/Core/src/Handlers/TimePicker/TimePickerHandler.Android.cs index c763afac2333..35f82703f85a 100644 --- a/src/Core/src/Handlers/TimePicker/TimePickerHandler.Android.cs +++ b/src/Core/src/Handlers/TimePicker/TimePickerHandler.Android.cs @@ -24,11 +24,11 @@ protected override MauiTimePicker CreateNativeView() return _timePicker; } - protected override void SetupDefaults(MauiTimePicker nativeView) + void SetupDefaults(MauiTimePicker nativeView) { DefaultBackground = nativeView.Background; - base.SetupDefaults(nativeView); + } protected override void DisconnectHandler(MauiTimePicker nativeView) diff --git a/src/Core/src/Handlers/TimePicker/TimePickerHandler.Windows.cs b/src/Core/src/Handlers/TimePicker/TimePickerHandler.Windows.cs index 27ebe2a88d3d..cca1260c9e05 100644 --- a/src/Core/src/Handlers/TimePicker/TimePickerHandler.Windows.cs +++ b/src/Core/src/Handlers/TimePicker/TimePickerHandler.Windows.cs @@ -20,11 +20,11 @@ protected override void DisconnectHandler(TimePicker nativeView) nativeView.TimeChanged -= OnControlTimeChanged; } - protected override void SetupDefaults(TimePicker nativeView) + void SetupDefaults(TimePicker nativeView) { _defaultForeground = nativeView.Foreground; - base.SetupDefaults(nativeView); + } public static void MapFormat(TimePickerHandler handler, ITimePicker timePicker) diff --git a/src/Core/src/Handlers/View/ViewHandler.cs b/src/Core/src/Handlers/View/ViewHandler.cs index c658edbe7c86..45c23d963ff8 100644 --- a/src/Core/src/Handlers/View/ViewHandler.cs +++ b/src/Core/src/Handlers/View/ViewHandler.cs @@ -105,11 +105,6 @@ private protected sealed override object OnCreateNativeElement() => OnCreateNativeView(); #if !NETSTANDARD - private protected abstract void OnSetupDefaults(NativeView nativeView); - - private protected sealed override void OnSetupDefaults(object nativeView) => - OnSetupDefaults((NativeView)nativeView); - private protected abstract void OnConnectHandler(NativeView nativeView); partial void ConnectingHandler(NativeView? nativeView); diff --git a/src/Core/src/Handlers/View/ViewHandlerOfT.cs b/src/Core/src/Handlers/View/ViewHandlerOfT.cs index 70b1b2eade51..b933bf2bc5e6 100644 --- a/src/Core/src/Handlers/View/ViewHandlerOfT.cs +++ b/src/Core/src/Handlers/View/ViewHandlerOfT.cs @@ -22,7 +22,6 @@ public abstract partial class ViewHandler : ViewHandl [HotReload.OnHotReload] internal static void OnHotReload() { - Defaults>.HasSetDefaults = false; } protected ViewHandler(PropertyMapper mapper) @@ -48,12 +47,6 @@ protected ViewHandler(PropertyMapper mapper) object? IElementHandler.NativeView => base.NativeView; - protected override bool HasSetDefaults - { - get => Defaults>.HasSetDefaults; - set => Defaults>.HasSetDefaults = value; - } - public virtual void SetVirtualView(IView view) => base.SetVirtualView(view); @@ -62,10 +55,6 @@ public sealed override void SetVirtualView(IElement view) => protected abstract TNativeView CreateNativeView(); - protected virtual void SetupDefaults(TNativeView nativeView) - { - } - protected virtual void ConnectHandler(TNativeView nativeView) { } @@ -77,9 +66,6 @@ protected virtual void DisconnectHandler(TNativeView nativeView) private protected override NativeView OnCreateNativeView() => CreateNativeView(); - private protected override void OnSetupDefaults(NativeView nativeView) => - SetupDefaults((TNativeView)nativeView); - private protected override void OnConnectHandler(NativeView nativeView) => ConnectHandler((TNativeView)nativeView);