From c332a25b2655a64cacf4eed0c13a1cd16b6394a2 Mon Sep 17 00:00:00 2001 From: Andres Pineda Date: Mon, 16 Nov 2020 17:39:20 -0500 Subject: [PATCH] feat(iOS): Add TimePicker Feature Flag --- src/Uno.UI/FeatureConfiguration.cs | 9 +++- .../TimePicker/TimePickerSelector.iOS.cs | 42 +++++-------------- .../UI/Xaml/Style/Generic/Generic.Native.xaml | 2 - 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/Uno.UI/FeatureConfiguration.cs b/src/Uno.UI/FeatureConfiguration.cs index 49886914015c..32c4060da758 100644 --- a/src/Uno.UI/FeatureConfiguration.cs +++ b/src/Uno.UI/FeatureConfiguration.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; using Windows.UI.Xaml; @@ -450,5 +450,12 @@ public static class Xaml [EditorBrowsable(EditorBrowsableState.Never)] public static int MaxRecursiveResolvingDepth { get; set; } = 12; } + + public static class TimePicker + { +#if __IOS__ + public static bool UseLegacyStyle { get; set; } = false; +#endif + } } } diff --git a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerSelector.iOS.cs b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerSelector.iOS.cs index bfc70cc03935..3f50050c9590 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerSelector.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerSelector.iOS.cs @@ -14,17 +14,10 @@ namespace Windows.UI.Xaml.Controls { public partial class TimePickerSelector { - private readonly UIDatePickerStyle _iOSDefaultStyle = UIDatePickerStyle.Wheels; - private UIDatePicker _picker; private NSDate _initialTime; private NSDate _newDate; - partial void InitPartial() - { - ResourceResolver.ApplyResource(this, UsePlatformDefaultStyleProperty, "TimePickerSelectorUsePlatformDefaultStyle", isThemeResourceExtension: false); - } - private protected override void OnLoaded() { base.OnLoaded(); @@ -155,28 +148,6 @@ private protected override void OnUnloaded() base.OnUnloaded(); } - /// - /// Used to set whether or not we want to use the default specified for the os Version - /// Default value is False - /// - public bool UsePlatformDefaultStyle - { - get => (bool)GetValue(UsePlatformDefaultStyleProperty); - set => SetValue(UsePlatformDefaultStyleProperty, value); - } - - public static DependencyProperty UsePlatformDefaultStyleProperty { get; } = - DependencyProperty.Register( - nameof(UsePlatformDefaultStyle), - typeof(bool), - typeof(TimePickerSelector), - new FrameworkPropertyMetadata( - defaultValue: false, - propertyChangedCallback: (s, e) => ((TimePickerSelector)s)?.OnUseDefaultStyleChanged() - )); - - private void OnUseDefaultStyleChanged() => UpdatePickerStyle(); - private void UpdatePickerStyle() { if (_picker == null) @@ -184,9 +155,16 @@ private void UpdatePickerStyle() return; } - _picker.PreferredDatePickerStyle = UIDevice.CurrentDevice.CheckSystemVersion(14, 0) && UsePlatformDefaultStyle - ? UIDatePickerStyle.Inline - : _iOSDefaultStyle; + if (UIDevice.CurrentDevice.CheckSystemVersion(14, 0)) + { + _picker.PreferredDatePickerStyle = FeatureConfiguration.TimePicker.UseLegacyStyle + ? UIDatePickerStyle.Wheels + : UIDatePickerStyle.Inline; + } + else + { + _picker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels; + } } } } diff --git a/src/Uno.UI/UI/Xaml/Style/Generic/Generic.Native.xaml b/src/Uno.UI/UI/Xaml/Style/Generic/Generic.Native.xaml index 2e187a3724fb..5e0591fc3c1f 100644 --- a/src/Uno.UI/UI/Xaml/Style/Generic/Generic.Native.xaml +++ b/src/Uno.UI/UI/Xaml/Style/Generic/Generic.Native.xaml @@ -25,10 +25,8 @@ False - False -