diff --git a/src/Compatibility/Core/src/iOS/Renderers/DatePickerRenderer.cs b/src/Compatibility/Core/src/iOS/Renderers/DatePickerRenderer.cs index c786643a348e..4e8cf6d1bdfa 100644 --- a/src/Compatibility/Core/src/iOS/Renderers/DatePickerRenderer.cs +++ b/src/Compatibility/Core/src/iOS/Renderers/DatePickerRenderer.cs @@ -152,6 +152,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE } } + [PortHandler] void HandleValueChanged(object sender, EventArgs e) { if (Element.OnThisPlatform().UpdateMode() == UpdateMode.Immediately) diff --git a/src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs b/src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs index 9d40543bd77a..3933d5cbac2a 100644 --- a/src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs +++ b/src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs @@ -286,6 +286,7 @@ protected virtual void UpdateColor() } } + [PortHandler] void UpdateAdjustsFontSizeToFitWidth() { Control.AdjustsFontSizeToFitWidth = Element.OnThisPlatform().AdjustsFontSizeToFitWidth(); @@ -511,6 +512,7 @@ UITextPosition GetSelectionStart(int cursorPosition, out int startOffset) return start; } + [PortHandler] void UpdateCursorColor() { var control = Control; diff --git a/src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs b/src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs index 079092b5248f..b86623865166 100644 --- a/src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs +++ b/src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs @@ -551,12 +551,14 @@ void UpdateCurrentPagePreferredStatusBarUpdateAnimation() PlatformConfiguration.iOSSpecific.Page.SetPreferredStatusBarUpdateAnimation(Current.OnThisPlatform(), animation); } + [PortHandler] void UpdateUseLargeTitles() { if (Forms.IsiOS11OrNewer && NavPage != null) NavigationBar.PrefersLargeTitles = NavPage.OnThisPlatform().PrefersLargeTitles(); } + [PortHandler] void UpdateTranslucent() { NavigationBar.Translucent = NavPage.OnThisPlatform().IsNavigationBarTranslucent(); diff --git a/src/Compatibility/Core/src/iOS/Renderers/ScrollViewRenderer.cs b/src/Compatibility/Core/src/iOS/Renderers/ScrollViewRenderer.cs index 6fcb7aac9b74..79542e8d2cb4 100644 --- a/src/Compatibility/Core/src/iOS/Renderers/ScrollViewRenderer.cs +++ b/src/Compatibility/Core/src/iOS/Renderers/ScrollViewRenderer.cs @@ -301,6 +301,7 @@ void OnScrollToRequested(object sender, ScrollToRequestedEventArgs e) ScrollView.SendScrollFinished(); } + [PortHandler] void UpdateDelaysContentTouches() { DelaysContentTouches = ((ScrollView)Element).OnThisPlatform().ShouldDelayContentTouches(); diff --git a/src/Compatibility/Core/src/iOS/Renderers/SearchBarRenderer.cs b/src/Compatibility/Core/src/iOS/Renderers/SearchBarRenderer.cs index ee81cbd34af8..dc162ad40b5b 100644 --- a/src/Compatibility/Core/src/iOS/Renderers/SearchBarRenderer.cs +++ b/src/Compatibility/Core/src/iOS/Renderers/SearchBarRenderer.cs @@ -440,6 +440,7 @@ UIToolbar CreateNumericKeyboardAccessoryView() return accessoryView; } + [PortHandler] void UpdateSearchBarStyle() { Control.SearchBarStyle = Element.OnThisPlatform().GetSearchBarStyle().ToPlatformSearchBarStyle(); diff --git a/src/Controls/samples/Controls.Sample/ViewModels/PlatformSpecificsViewModel.cs b/src/Controls/samples/Controls.Sample/ViewModels/PlatformSpecificsViewModel.cs index ed87d256a37d..55668e3aca95 100644 --- a/src/Controls/samples/Controls.Sample/ViewModels/PlatformSpecificsViewModel.cs +++ b/src/Controls/samples/Controls.Sample/ViewModels/PlatformSpecificsViewModel.cs @@ -42,7 +42,7 @@ protected override IEnumerable CreateItems() new SectionModel(typeof(AndroidWebViewZoomPage), "WebView Zoom Controls", "This Android platform-specific enables pinch-to-zoom and a zoom control on a WebView."), }; -#elif IOS +#elif IOS || MACCATALYST return new[] { new SectionModel(typeof(iOSBlurEffectPage), "Blur Effect", diff --git a/src/Controls/src/Core/HandlerImpl/DatePicker.Impl.cs b/src/Controls/src/Core/HandlerImpl/DatePicker.Impl.cs deleted file mode 100644 index 6a43f65c8c35..000000000000 --- a/src/Controls/src/Core/HandlerImpl/DatePicker.Impl.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Microsoft.Maui.Controls -{ - /// - public partial class DatePicker : IDatePicker - { - Font ITextStyle.Font => this.ToFont(); - } -} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Android.cs b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Android.cs new file mode 100644 index 000000000000..cd9d5cf2dbcf --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Android.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class DatePicker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Impl.cs b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Impl.cs new file mode 100644 index 000000000000..774a04433aca --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Impl.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class DatePicker : IDatePicker + { + Font ITextStyle.Font => this.ToFont(); + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Standard.cs b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Standard.cs new file mode 100644 index 000000000000..cd9d5cf2dbcf --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Standard.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class DatePicker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Windows.cs b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Windows.cs new file mode 100644 index 000000000000..cd9d5cf2dbcf --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.Windows.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class DatePicker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.cs b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.cs new file mode 100644 index 000000000000..494ff99f5b1a --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.cs @@ -0,0 +1,18 @@ +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 + }; + + internal static new void RemapForControls() + { + // Adjust the mappings to preserve Controls.DatePicker legacy behaviors + DatePickerHandler.Mapper = ControlsDatePickerMapper; + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.iOS.cs b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.iOS.cs new file mode 100644 index 000000000000..1f6575fc2dfc --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.iOS.cs @@ -0,0 +1,13 @@ +using Microsoft.Maui.Controls.Platform; +using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; + +namespace Microsoft.Maui.Controls +{ + public partial class DatePicker + { + public static void MapUpdateMode(DatePickerHandler handler, DatePicker datePicker) + { + handler.UpdateImmediately = datePicker.OnThisPlatform().UpdateMode() == UpdateMode.Immediately; + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/Entry/Entry.cs b/src/Controls/src/Core/HandlerImpl/Entry/Entry.cs index dddeb4309d26..1e81885d2f91 100644 --- a/src/Controls/src/Core/HandlerImpl/Entry/Entry.cs +++ b/src/Controls/src/Core/HandlerImpl/Entry/Entry.cs @@ -9,6 +9,9 @@ public partial class Entry [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, diff --git a/src/Controls/src/Core/HandlerImpl/Entry/Entry.iOS.cs b/src/Controls/src/Core/HandlerImpl/Entry/Entry.iOS.cs index cd01ab1f9fc5..8dab982b9ca1 100644 --- a/src/Controls/src/Core/HandlerImpl/Entry/Entry.iOS.cs +++ b/src/Controls/src/Core/HandlerImpl/Entry/Entry.iOS.cs @@ -2,7 +2,17 @@ { public partial class Entry { - public static void MapText(EntryHandler handler, Entry entry) + public static void MapCursorColor(EntryHandler handler, Entry entry) + { + Platform.TextExtensions.UpdateCursorColor(handler.PlatformView, entry); + } + + public static void MapAdjustsFontSizeToFitWidth(EntryHandler handler, Entry entry) + { + Platform.TextExtensions.UpdateAdjustsFontSizeToFitWidth(handler.PlatformView, entry); + } + + public static void MapText(EntryHandler handler, Entry entry) { Platform.TextExtensions.UpdateText(handler.PlatformView, entry); } diff --git a/src/Controls/src/Core/HandlerImpl/NavigationPage/NavigationPage.cs b/src/Controls/src/Core/HandlerImpl/NavigationPage/NavigationPage.cs new file mode 100644 index 000000000000..123a56ccb283 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/NavigationPage/NavigationPage.cs @@ -0,0 +1,20 @@ +namespace Microsoft.Maui.Controls +{ + public partial class NavigationPage + { + public static IPropertyMapper ControlsNavigationPageMapper = + new PropertyMapper(NavigationViewHandler.Mapper) + { +#if IOS + [PlatformConfiguration.iOSSpecific.NavigationPage.PrefersLargeTitlesProperty.PropertyName] = MapPrefersLargeTitles, + [PlatformConfiguration.iOSSpecific.NavigationPage.IsNavigationBarTranslucentProperty.PropertyName] = MapIsNavigationBarTranslucent, +#endif + }; + + internal static new void RemapForControls() + { + // Adjust the mappings to preserve Controls.NavigationPage legacy behaviors + NavigationViewHandler.Mapper = ControlsNavigationPageMapper; + } + } +} diff --git a/src/Controls/src/Core/HandlerImpl/NavigationPage/NavigationPage.iOS.cs b/src/Controls/src/Core/HandlerImpl/NavigationPage/NavigationPage.iOS.cs new file mode 100644 index 000000000000..236371e9eda8 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/NavigationPage/NavigationPage.iOS.cs @@ -0,0 +1,17 @@ +namespace Microsoft.Maui.Controls +{ + public partial class NavigationPage + { + public static void MapPrefersLargeTitles(NavigationViewHandler handler, NavigationPage navigationPage) + { + if (handler.ViewController is ControlsNavigationController navigationController) + Platform.NavigationPageExtensions.UpdatePrefersLargeTitles(navigationController, navigationPage); + } + + public static void MapIsNavigationBarTranslucent(NavigationViewHandler handler, NavigationPage navigationPage) + { + if (handler.ViewController is ControlsNavigationController navigationController) + Platform.NavigationPageExtensions.UpdateIsNavigationBarTranslucent(navigationController, navigationPage); + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/Picker/Picker.Android.cs b/src/Controls/src/Core/HandlerImpl/Picker/Picker.Android.cs new file mode 100644 index 000000000000..e29d85be74ff --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/Picker/Picker.Android.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class Picker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/Picker.Impl.cs b/src/Controls/src/Core/HandlerImpl/Picker/Picker.Impl.cs similarity index 79% rename from src/Controls/src/Core/HandlerImpl/Picker.Impl.cs rename to src/Controls/src/Core/HandlerImpl/Picker/Picker.Impl.cs index 081f572d5eb4..6dd5eb86740e 100644 --- a/src/Controls/src/Core/HandlerImpl/Picker.Impl.cs +++ b/src/Controls/src/Core/HandlerImpl/Picker/Picker.Impl.cs @@ -2,7 +2,6 @@ namespace Microsoft.Maui.Controls { - /// public partial class Picker : IPicker { Font ITextStyle.Font => this.ToFont(); diff --git a/src/Controls/src/Core/HandlerImpl/Picker/Picker.Standard.cs b/src/Controls/src/Core/HandlerImpl/Picker/Picker.Standard.cs new file mode 100644 index 000000000000..e29d85be74ff --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/Picker/Picker.Standard.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class Picker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/Picker/Picker.Windows.cs b/src/Controls/src/Core/HandlerImpl/Picker/Picker.Windows.cs new file mode 100644 index 000000000000..e29d85be74ff --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/Picker/Picker.Windows.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class Picker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/Picker/Picker.cs b/src/Controls/src/Core/HandlerImpl/Picker/Picker.cs new file mode 100644 index 000000000000..50dc2d934f15 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/Picker/Picker.cs @@ -0,0 +1,18 @@ +namespace Microsoft.Maui.Controls +{ + public partial class Picker + { + public static IPropertyMapper ControlsPickerMapper = new PropertyMapper(PickerHandler.Mapper) + { +#if IOS + [PlatformConfiguration.iOSSpecific.Picker.UpdateModeProperty.PropertyName] = MapUpdateMode, +#endif + }; + + internal static new void RemapForControls() + { + // Adjust the mappings to preserve Controls.Picker legacy behaviors + PickerHandler.Mapper = ControlsPickerMapper; + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/Picker/Picker.iOS.cs b/src/Controls/src/Core/HandlerImpl/Picker/Picker.iOS.cs new file mode 100644 index 000000000000..f652f1b8e78a --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/Picker/Picker.iOS.cs @@ -0,0 +1,13 @@ +using Microsoft.Maui.Controls.Platform; +using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; + +namespace Microsoft.Maui.Controls +{ + public partial class Picker + { + public static void MapUpdateMode(PickerHandler handler, Picker picker) + { + handler.UpdateImmediately = picker.OnThisPlatform().UpdateMode() == UpdateMode.Immediately; + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Android.cs b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Android.cs new file mode 100644 index 000000000000..92833c1b0cf9 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Android.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class ScrollView + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/ScrollView.Impl.cs b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Impl.cs similarity index 95% rename from src/Controls/src/Core/HandlerImpl/ScrollView.Impl.cs rename to src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Impl.cs index 9fcf8dde9f44..159b4fa07790 100644 --- a/src/Controls/src/Core/HandlerImpl/ScrollView.Impl.cs +++ b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Impl.cs @@ -5,7 +5,6 @@ namespace Microsoft.Maui.Controls { - /// public partial class ScrollView : IScrollView, IContentView { object IContentView.Content => Content; diff --git a/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Standard.cs b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Standard.cs new file mode 100644 index 000000000000..92833c1b0cf9 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Standard.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class ScrollView + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Windows.cs b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Windows.cs new file mode 100644 index 000000000000..92833c1b0cf9 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.Windows.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class ScrollView + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.cs b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.cs new file mode 100644 index 000000000000..aef649c5612c --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.cs @@ -0,0 +1,19 @@ +namespace Microsoft.Maui.Controls +{ + public partial class ScrollView + { + public static IPropertyMapper ControlsScrollViewMapper = + new PropertyMapper(ScrollViewHandler.Mapper) + { +#if IOS + [PlatformConfiguration.iOSSpecific.ScrollView.ShouldDelayContentTouchesProperty.PropertyName] = MapShouldDelayContentTouches, +#endif + }; + + internal static new void RemapForControls() + { + // Adjust the mappings to preserve Controls.ScrollView legacy behaviors + ScrollViewHandler.Mapper = ControlsScrollViewMapper; + } + } +} diff --git a/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.iOS.cs b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.iOS.cs new file mode 100644 index 000000000000..04cbbe08f188 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.iOS.cs @@ -0,0 +1,10 @@ +namespace Microsoft.Maui.Controls +{ + public partial class ScrollView + { + public static void MapShouldDelayContentTouches(ScrollViewHandler handler, ScrollView scrollView) + { + Platform.ScrollViewExtensions.UpdateShouldDelayContentTouches(handler.PlatformView, scrollView); + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.cs b/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.cs index 86811a287c09..826b3a3ddd33 100644 --- a/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.cs +++ b/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.cs @@ -7,6 +7,8 @@ public partial class SearchBar { #if WINDOWS [PlatformConfiguration.WindowsSpecific.SearchBar.IsSpellCheckEnabledProperty.PropertyName] = MapIsSpellCheckEnabled, +#elif IOS + [PlatformConfiguration.iOSSpecific.SearchBar.SearchBarStyleProperty.PropertyName] = MapSearchBarStyle, #endif [nameof(Text)] = MapText, [nameof(TextTransform)] = MapText, diff --git a/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.iOS.cs b/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.iOS.cs index 270c2a1f2010..2b96524dc05f 100644 --- a/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.iOS.cs +++ b/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.iOS.cs @@ -2,7 +2,12 @@ { public partial class SearchBar { - public static void MapText(SearchBarHandler handler, SearchBar searchBar) + public static void MapSearchBarStyle(SearchBarHandler handler, SearchBar searchBar) + { + Platform.SearchBarExtensions.UpdateSearchBarStyle(handler.PlatformView, searchBar); + } + + public static void MapText(SearchBarHandler handler, SearchBar searchBar) { Platform.SearchBarExtensions.UpdateText(handler.PlatformView, searchBar); } diff --git a/src/Controls/src/Core/HandlerImpl/TimePicker.Impl.cs b/src/Controls/src/Core/HandlerImpl/TimePicker.Impl.cs deleted file mode 100644 index f1ec69f789f5..000000000000 --- a/src/Controls/src/Core/HandlerImpl/TimePicker.Impl.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Microsoft.Maui.Controls -{ - /// - public partial class TimePicker : ITimePicker - { - Font ITextStyle.Font => this.ToFont(); - } -} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Android.cs b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Android.cs new file mode 100644 index 000000000000..241aaf02ca90 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Android.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class TimePicker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Impl.cs b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Impl.cs new file mode 100644 index 000000000000..d8308932da34 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Impl.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class TimePicker : ITimePicker + { + Font ITextStyle.Font => this.ToFont(); + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Standard.cs b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Standard.cs new file mode 100644 index 000000000000..241aaf02ca90 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Standard.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class TimePicker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Windows.cs b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Windows.cs new file mode 100644 index 000000000000..241aaf02ca90 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.Windows.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.Controls +{ + public partial class TimePicker + { + + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.cs b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.cs new file mode 100644 index 000000000000..9298d994983d --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.cs @@ -0,0 +1,18 @@ +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 + }; + + internal static new void RemapForControls() + { + // Adjust the mappings to preserve Controls.TimePicker legacy behaviors + TimePickerHandler.Mapper = ControlsTimePickerMapper; + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.iOS.cs b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.iOS.cs new file mode 100644 index 000000000000..1c8745995dd5 --- /dev/null +++ b/src/Controls/src/Core/HandlerImpl/TimePicker/TimePicker.iOS.cs @@ -0,0 +1,13 @@ +using Microsoft.Maui.Controls.Platform; +using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; + +namespace Microsoft.Maui.Controls +{ + public partial class TimePicker + { + public static void MapUpdateMode(TimePickerHandler handler, TimePicker timePicker) + { + handler.UpdateImmediately = timePicker.OnThisPlatform().UpdateMode() == UpdateMode.Immediately; + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/Platform/iOS/Extensions/NavigationPageExtensions.cs b/src/Controls/src/Core/Platform/iOS/Extensions/NavigationPageExtensions.cs new file mode 100644 index 000000000000..45b4c6e4818d --- /dev/null +++ b/src/Controls/src/Core/Platform/iOS/Extensions/NavigationPageExtensions.cs @@ -0,0 +1,26 @@ +using System; +using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; +using UIKit; + +namespace Microsoft.Maui.Controls.Platform +{ + public static class NavigationPageExtensions + { + public static void UpdatePrefersLargeTitles(this UINavigationController platformView, NavigationPage navigationPage) + { + if (platformView.NavigationBar == null) + return; + + if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsMacCatalystVersionAtLeast(11)) + platformView.NavigationBar.PrefersLargeTitles = navigationPage.OnThisPlatform().PrefersLargeTitles(); + } + + public static void UpdateIsNavigationBarTranslucent(this UINavigationController platformView, NavigationPage navigationPage) + { + if (platformView.NavigationBar == null) + return; + + platformView.NavigationBar.Translucent = navigationPage.OnThisPlatform().IsNavigationBarTranslucent(); + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/Platform/iOS/Extensions/ScrollViewExtensions.cs b/src/Controls/src/Core/Platform/iOS/Extensions/ScrollViewExtensions.cs new file mode 100644 index 000000000000..745f1e4ccd33 --- /dev/null +++ b/src/Controls/src/Core/Platform/iOS/Extensions/ScrollViewExtensions.cs @@ -0,0 +1,13 @@ +using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; +using UIKit; + +namespace Microsoft.Maui.Controls.Platform +{ + public static class ScrollViewExtensions + { + public static void UpdateShouldDelayContentTouches(this UIScrollView platformView, ScrollView scrollView) + { + platformView.DelaysContentTouches = scrollView.OnThisPlatform().ShouldDelayContentTouches(); + } + } +} \ No newline at end of file diff --git a/src/Controls/src/Core/Platform/iOS/Extensions/SearchBarExtensions.cs b/src/Controls/src/Core/Platform/iOS/Extensions/SearchBarExtensions.cs index 087b9baec8ae..6f1562a67851 100644 --- a/src/Controls/src/Core/Platform/iOS/Extensions/SearchBarExtensions.cs +++ b/src/Controls/src/Core/Platform/iOS/Extensions/SearchBarExtensions.cs @@ -1,13 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.Maui.Controls.Internals; +using Microsoft.Maui.Controls.Internals; +using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; using UIKit; namespace Microsoft.Maui.Controls.Platform { public static class SearchBarExtensions { + public static void UpdateSearchBarStyle(this UISearchBar uiSearchBar, SearchBar searchBar) + { + uiSearchBar.SearchBarStyle = searchBar.OnThisPlatform().GetSearchBarStyle().ToPlatformSearchBarStyle(); + } + public static void UpdateText(this UISearchBar uiSearchBar, SearchBar searchBar) { uiSearchBar.Text = TextTransformUtilites.GetTransformedText(searchBar.Text, searchBar.TextTransform); diff --git a/src/Controls/src/Core/Platform/iOS/Extensions/TextExtensions.cs b/src/Controls/src/Core/Platform/iOS/Extensions/TextExtensions.cs index b412ec50e74a..3b52425ca1ca 100644 --- a/src/Controls/src/Core/Platform/iOS/Extensions/TextExtensions.cs +++ b/src/Controls/src/Core/Platform/iOS/Extensions/TextExtensions.cs @@ -4,11 +4,29 @@ using Microsoft.Maui.Controls.Internals; using Microsoft.Maui.Platform; using UIKit; +using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; +using Specifics = Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.Entry; namespace Microsoft.Maui.Controls.Platform { public static class TextExtensions { + public static void UpdateCursorColor(this UITextField textField, Entry entry) + { + if (entry.IsSet(Specifics.CursorColorProperty)) + { + var color = entry.OnThisPlatform().GetCursorColor(); + + if (color != null) + textField.TintColor = color.ToPlatform(); + } + } + + public static void UpdateAdjustsFontSizeToFitWidth(this UITextField textField, Entry entry) + { + textField.AdjustsFontSizeToFitWidth = entry.OnThisPlatform().AdjustsFontSizeToFitWidth(); + } + public static void UpdateText(this UITextView textView, InputView inputView) { textView.Text = TextTransformUtilites.GetTransformedText(inputView.Text, inputView.TextTransform); @@ -64,4 +82,4 @@ internal static void SetLineBreakMode(this UILabel platformLabel, Label label) platformLabel.Lines = maxLines; } } -} +} \ No newline at end of file diff --git a/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs b/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs index f4bdc382b624..eaff4b2b7dcd 100644 --- a/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs +++ b/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs @@ -213,15 +213,19 @@ internal static MauiAppBuilder RemapForControls(this MauiAppBuilder builder) VisualElement.RemapForControls(); Label.RemapForControls(); Button.RemapForControls(); + DatePicker.RemapForControls(); RadioButton.RemapForControls(); FlyoutPage.RemapForControls(); Toolbar.RemapForControls(); Window.RemapForControls(); Editor.RemapForControls(); Entry.RemapForControls(); + Picker.RemapForControls(); SearchBar.RemapForControls(); TabbedPage.RemapForControls(); + TimePicker.RemapForControls(); Layout.RemapForControls(); + ScrollView.RemapForControls(); RefreshView.RemapForControls(); Shape.RemapForControls(); WebView.RemapForControls(); diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs index ada2b0180849..9cb70cbc979a 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs @@ -10,9 +10,10 @@ public partial class DatePickerHandler : ViewHandler protected override UIDatePicker CreatePlatformView() { return new UIDatePicker { Mode = UIDatePickerMode.Date, TimeZone = new NSTimeZone("UTC") }; - ; } + internal bool UpdateImmediately { get; set; } = true; + protected override void ConnectHandler(UIDatePicker platformView) { platformView.EditingDidBegin += OnStarted; @@ -78,7 +79,8 @@ public static void MapFlowDirection(DatePickerHandler handler, IDatePicker dateP void OnValueChanged(object? sender, EventArgs? e) { - SetVirtualViewDate(); + if (UpdateImmediately) // Platform Specific + SetVirtualViewDate(); if (VirtualView != null) VirtualView.IsFocused = true; diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs index 3e81066e4dd8..78380302303c 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs @@ -41,6 +41,8 @@ protected override MauiDatePicker CreatePlatformView() internal UIDatePicker? DatePickerDialog { get { return _picker; } } + internal bool UpdateImmediately { get; set; } + protected override void ConnectHandler(MauiDatePicker platformView) { if (_picker is UIDatePicker picker) @@ -120,7 +122,8 @@ public static void MapFlowDirection(DatePickerHandler handler, IDatePicker dateP void OnValueChanged(object? sender, EventArgs? e) { - SetVirtualViewDate(); + if (UpdateImmediately) // Platform Specific + SetVirtualViewDate(); if (VirtualView != null) VirtualView.IsFocused = true; @@ -147,4 +150,4 @@ void SetVirtualViewDate() } } #endif -} \ No newline at end of file +} diff --git a/src/Core/src/Handlers/Picker/PickerHandler.iOS.cs b/src/Core/src/Handlers/Picker/PickerHandler.iOS.cs index 9eec94e412f1..a0d7313a50a2 100644 --- a/src/Core/src/Handlers/Picker/PickerHandler.iOS.cs +++ b/src/Core/src/Handlers/Picker/PickerHandler.iOS.cs @@ -8,8 +8,8 @@ namespace Microsoft.Maui.Handlers public partial class PickerHandler : ViewHandler { UIPickerView? _pickerView; -#if IOS && !MACCATALYST +#if IOS && !MACCATALYST protected override MauiPicker CreatePlatformView() { _pickerView = new UIPickerView(); @@ -27,7 +27,7 @@ protected override MauiPicker CreatePlatformView() platformPicker.InputAssistantItem.TrailingBarButtonGroups = null; platformPicker.AccessibilityTraits = UIAccessibilityTrait.Button; - _pickerView.Model = new PickerSource(VirtualView); + _pickerView.Model = new PickerSource(this); return platformPicker; } @@ -59,7 +59,7 @@ UIAlertController CreateAlert(UITextField uITextField) var pickerHeight = 240; var frame = new RectangleF(0, paddingTitle, 269, pickerHeight); var pickerView = new UIPickerView(frame); - pickerView.Model = new PickerSource(VirtualView); + pickerView.Model = new PickerSource(this); pickerView?.ReloadAllComponents(); var pickerController = UIAlertController.Create(VirtualView.Title, "", UIAlertControllerStyle.ActionSheet); @@ -88,6 +88,9 @@ UIAlertController CreateAlert(UITextField uITextField) return pickerController; } #endif + + internal bool UpdateImmediately { get; set; } + protected override void ConnectHandler(MauiPicker platformView) { platformView.EditingDidBegin += OnStarted; @@ -124,6 +127,7 @@ protected override void DisconnectHandler(MauiPicker platformView) base.DisconnectHandler(platformView); } + static void Reload(IPickerHandler handler) { if (handler.VirtualView == null || handler.PlatformView == null) @@ -250,27 +254,40 @@ void FinishSelectItem(UIPickerView? pickerView, UITextField textField) public class PickerSource : UIPickerViewModel { - IPicker? _virtualView; bool _disposed; - public PickerSource(IPicker? virtualView) + public PickerSource(PickerHandler? handler) { - _virtualView = virtualView; + Handler = handler; } + public PickerHandler? Handler { get; set; } public int SelectedIndex { get; internal set; } public override nint GetComponentCount(UIPickerView picker) => 1; public override nint GetRowsInComponent(UIPickerView pickerView, nint component) => - _virtualView?.GetCount() ?? 0; + Handler?.VirtualView?.GetCount() ?? 0; public override string GetTitle(UIPickerView picker, nint row, nint component) => - _virtualView?.GetItem((int)row) ?? ""; + Handler?.VirtualView?.GetItem((int)row) ?? string.Empty; - public override void Selected(UIPickerView picker, nint row, nint component) => + public override void Selected(UIPickerView picker, nint row, nint component) + { SelectedIndex = (int)row; + if (Handler != null && Handler.UpdateImmediately) // Platform Specific + { + var virtualView = Handler?.VirtualView; + var platformView = Handler?.PlatformView; + + if (virtualView == null || platformView == null) + return; + + platformView.UpdatePicker(virtualView, SelectedIndex); + } + } + protected override void Dispose(bool disposing) { if (_disposed) @@ -279,9 +296,12 @@ protected override void Dispose(bool disposing) _disposed = true; if (disposing) - _virtualView = null; + { + if (Handler != null) + Handler = null; + } base.Dispose(disposing); } } -} +} \ No newline at end of file diff --git a/src/Core/src/Handlers/TimePicker/TimePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/TimePicker/TimePickerHandler.MacCatalyst.cs index ba694cd66814..0d7691ed27c1 100644 --- a/src/Core/src/Handlers/TimePicker/TimePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/TimePicker/TimePickerHandler.MacCatalyst.cs @@ -11,6 +11,8 @@ protected override UIDatePicker CreatePlatformView() return new UIDatePicker { Mode = UIDatePickerMode.Time, TimeZone = new NSTimeZone("UTC") }; } + internal bool UpdateImmediately { get; set; } = true; + protected override void ConnectHandler(UIDatePicker platformView) { base.ConnectHandler(platformView); @@ -85,7 +87,8 @@ void OnEnded(object? sender, EventArgs eventArgs) void OnValueChanged(object? sender, EventArgs e) { - SetVirtualViewTime(); + if (UpdateImmediately) // Platform Specific + SetVirtualViewTime(); } void SetVirtualViewTime() diff --git a/src/Core/src/Handlers/TimePicker/TimePickerHandler.iOS.cs b/src/Core/src/Handlers/TimePicker/TimePickerHandler.iOS.cs index 4bfe81a35ec0..1b1b411dccfe 100644 --- a/src/Core/src/Handlers/TimePicker/TimePickerHandler.iOS.cs +++ b/src/Core/src/Handlers/TimePicker/TimePickerHandler.iOS.cs @@ -1,5 +1,4 @@ using System; -using UIKit; namespace Microsoft.Maui.Handlers { @@ -15,6 +14,8 @@ protected override MauiTimePicker CreatePlatformView() }); } + internal bool UpdateImmediately { get; set; } + protected override void ConnectHandler(MauiTimePicker platformView) { base.ConnectHandler(platformView); @@ -25,6 +26,8 @@ protected override void ConnectHandler(MauiTimePicker platformView) platformView.EditingDidEnd += OnEnded; platformView.ValueChanged += OnValueChanged; platformView.DateSelected += OnDateSelected; + platformView.Picker.ValueChanged += OnValueChanged; + platformView.UpdateTime(VirtualView.Time); } } @@ -41,6 +44,7 @@ protected override void DisconnectHandler(MauiTimePicker platformView) platformView.EditingDidEnd -= OnEnded; platformView.ValueChanged -= OnValueChanged; platformView.DateSelected -= OnDateSelected; + platformView.Picker.ValueChanged -= OnValueChanged; platformView.Dispose(); } @@ -93,7 +97,8 @@ void OnEnded(object? sender, EventArgs eventArgs) void OnValueChanged(object? sender, EventArgs e) { - SetVirtualViewTime(); + if (UpdateImmediately) // Platform Specific + SetVirtualViewTime(); } void OnDateSelected(object? sender, EventArgs e) diff --git a/src/Core/src/Platform/iOS/PickerExtensions.cs b/src/Core/src/Platform/iOS/PickerExtensions.cs index 76283fb014a0..2e8215099c4e 100644 --- a/src/Core/src/Platform/iOS/PickerExtensions.cs +++ b/src/Core/src/Platform/iOS/PickerExtensions.cs @@ -1,7 +1,6 @@ #nullable enable using System; using Foundation; -using Microsoft.Maui.Handlers; namespace Microsoft.Maui.Platform {