From: adrianknight89 Date: Fri, 24 Mar 2017 19:07:59 +0000 (-0500) Subject: [iOS] Platform specifics to control ScrollView content touch delay (#563) X-Git-Tag: submit/tizen/20170424.094440~182 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27de335bf1ce9195e7b1de7ec738176da92b3617;p=platform%2Fupstream%2Fxamarin-forms.git [iOS] Platform specifics to control ScrollView content touch delay (#563) * can delay content touches optionally * revert bug fix * add back _tapGesture * remove extra declaration --- diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41778.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41778.cs new file mode 100644 index 0000000..327bea0 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41778.cs @@ -0,0 +1,39 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; +using Xamarin.Forms.PlatformConfiguration; +using Xamarin.Forms.PlatformConfiguration.iOSSpecific; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 41778, "Slider Inside ScrollView Will Open MasterDetailPage.Master", PlatformAffected.iOS)] + public class Bugzilla41778 : TestMasterDetailPage // or TestMasterDetailPage, etc ... + { + protected override void Init() + { + Master = new ContentPage + { + Title = "Menu", + BackgroundColor = Color.Blue + }; + + Detail = new DetailPageCS(); + } + } + + public class DetailPageCS : ContentPage + { + public DetailPageCS() + { + var scrollView = new ScrollView { Content = new Slider() }; + scrollView.On().SetShouldDelayContentTouches(false); + + Content = scrollView; + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index bf393ae..98753ff 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -131,6 +131,7 @@ + diff --git a/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ScrollView.cs b/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ScrollView.cs new file mode 100644 index 0000000..1a90a1f --- /dev/null +++ b/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ScrollView.cs @@ -0,0 +1,30 @@ +namespace Xamarin.Forms.PlatformConfiguration.iOSSpecific +{ + using FormsElement = Forms.ScrollView; + + public static class ScrollView + { + public static readonly BindableProperty ShouldDelayContentTouchesProperty = BindableProperty.Create(nameof(ShouldDelayContentTouches), typeof(bool), typeof(ScrollView), true); + + public static bool GetShouldDelayContentTouches(BindableObject element) + { + return (bool)element.GetValue(ShouldDelayContentTouchesProperty); + } + + public static void SetShouldDelayContentTouches(BindableObject element, bool value) + { + element.SetValue(ShouldDelayContentTouchesProperty, value); + } + + public static bool ShouldDelayContentTouches(this IPlatformElementConfiguration config) + { + return GetShouldDelayContentTouches(config.Element); + } + + public static IPlatformElementConfiguration SetShouldDelayContentTouches(this IPlatformElementConfiguration config, bool value) + { + SetShouldDelayContentTouches(config.Element, value); + return config; + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj index a052352..1184e01 100644 --- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj +++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj @@ -102,6 +102,7 @@ + diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs index 244edfa..1fe2edb 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs @@ -2,6 +2,7 @@ using System; using System.ComponentModel; using Xamarin.Forms.Internals; using UIKit; +using Xamarin.Forms.PlatformConfiguration.iOSSpecific; using PointF = CoreGraphics.CGPoint; using RectangleF = CoreGraphics.CGRect; @@ -66,8 +67,6 @@ namespace Xamarin.Forms.Platform.iOS ((IScrollViewController)element).ScrollToRequested += OnScrollToRequested; if (_packager == null) { - DelaysContentTouches = true; - _packager = new VisualElementPackager(this); _packager.Load(); @@ -84,6 +83,7 @@ namespace Xamarin.Forms.Platform.iOS }); } + UpdateDelaysContentTouches(); UpdateContentSize(); UpdateBackgroundColor(); @@ -165,7 +165,9 @@ namespace Xamarin.Forms.Platform.iOS void HandlePropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName == ScrollView.ContentSizeProperty.PropertyName) + if (e.PropertyName == PlatformConfiguration.iOSSpecific.ScrollView.ShouldDelayContentTouchesProperty.PropertyName) + UpdateDelaysContentTouches(); + else if (e.PropertyName == ScrollView.ContentSizeProperty.PropertyName) UpdateContentSize(); else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) UpdateBackgroundColor(); @@ -220,6 +222,11 @@ namespace Xamarin.Forms.Platform.iOS Controller.SendScrollFinished(); } + void UpdateDelaysContentTouches() + { + DelaysContentTouches = ((ScrollView)Element).OnThisPlatform().ShouldDelayContentTouches(); + } + void UpdateBackgroundColor() { BackgroundColor = Element.BackgroundColor.ToUIColor(Color.Transparent); diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms.PlatformConfiguration.iOSSpecific/ScrollView.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms.PlatformConfiguration.iOSSpecific/ScrollView.xml new file mode 100644 index 0000000..0e072e1 --- /dev/null +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms.PlatformConfiguration.iOSSpecific/ScrollView.xml @@ -0,0 +1,116 @@ + + + + + Xamarin.Forms.Core + 2.0.0.0 + + + System.Object + + + + To be added. + To be added. + + + + + + Method + + 2.0.0.0 + + + System.Boolean + + + + + + To be added. + To be added. + To be added. + To be added. + + + + + + Method + + 2.0.0.0 + + + System.Boolean + + + + + + To be added. + To be added. + To be added. + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.BindableProperty + + + To be added. + To be added. + + + + + + Method + + 2.0.0.0 + + + System.Void + + + + + + + To be added. + To be added. + To be added. + To be added. + + + + + + Method + + 2.0.0.0 + + + Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView> + + + + + + + To be added. + To be added. + To be added. + To be added. + To be added. + + + +