diff options
author | adrianknight89 <adrianknight89@outlook.com> | 2017-03-24 14:07:59 -0500 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2017-03-24 12:07:59 -0700 |
commit | 27de335bf1ce9195e7b1de7ec738176da92b3617 (patch) | |
tree | 820c0210f5dd7ac649d2d22e10e42a1b0c00526e | |
parent | 377d24fd05e7fb597c4f9237c1596ed4fbf86f19 (diff) | |
download | xamarin-forms-27de335bf1ce9195e7b1de7ec738176da92b3617.tar.gz xamarin-forms-27de335bf1ce9195e7b1de7ec738176da92b3617.tar.bz2 xamarin-forms-27de335bf1ce9195e7b1de7ec738176da92b3617.zip |
[iOS] Platform specifics to control ScrollView content touch delay (#563)
* can delay content touches optionally
* revert bug fix
* add back _tapGesture
* remove extra declaration
6 files changed, 197 insertions, 3 deletions
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 00000000..327bea07 --- /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<iOS>().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 bf393aec..98753ff5 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 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41415.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41418.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41424.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41778.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41600.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41619.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla42000.cs" /> diff --git a/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ScrollView.cs b/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ScrollView.cs new file mode 100644 index 00000000..1a90a1f1 --- /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<iOS, FormsElement> config) + { + return GetShouldDelayContentTouches(config.Element); + } + + public static IPlatformElementConfiguration<iOS, FormsElement> SetShouldDelayContentTouches(this IPlatformElementConfiguration<iOS, FormsElement> 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 a052352e..1184e012 100644 --- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj +++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj @@ -102,6 +102,7 @@ <Compile Include="PlatformConfiguration\iOSSpecific\BlurEffectStyle.cs" /> <Compile Include="PlatformConfiguration\iOSSpecific\Entry.cs" /> <Compile Include="PlatformConfiguration\iOSSpecific\NavigationPage.cs" /> + <Compile Include="PlatformConfiguration\iOSSpecific\ScrollView.cs" /> <Compile Include="PlatformConfiguration\iOSSpecific\Picker.cs" /> <Compile Include="PlatformConfiguration\iOSSpecific\StatusBarTextColorMode.cs" /> <Compile Include="PlatformConfiguration\iOSSpecific\Page.cs" /> diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs index 244edfaf..1fe2edbd 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 00000000..0e072e10 --- /dev/null +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms.PlatformConfiguration.iOSSpecific/ScrollView.xml @@ -0,0 +1,116 @@ +<Type Name="ScrollView" FullName="Xamarin.Forms.PlatformConfiguration.iOSSpecific.ScrollView"> + <TypeSignature Language="C#" Value="public static class ScrollView" /> + <TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit ScrollView extends System.Object" /> + <AssemblyInfo> + <AssemblyName>Xamarin.Forms.Core</AssemblyName> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <Base> + <BaseTypeName>System.Object</BaseTypeName> + </Base> + <Interfaces /> + <Docs> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + <Members> + <Member MemberName="GetShouldDelayContentTouches"> + <MemberSignature Language="C#" Value="public static bool GetShouldDelayContentTouches (Xamarin.Forms.BindableObject element);" /> + <MemberSignature Language="ILAsm" Value=".method public static hidebysig bool GetShouldDelayContentTouches(class Xamarin.Forms.BindableObject element) cil managed" /> + <MemberType>Method</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.Boolean</ReturnType> + </ReturnValue> + <Parameters> + <Parameter Name="element" Type="Xamarin.Forms.BindableObject" /> + </Parameters> + <Docs> + <param name="element">To be added.</param> + <summary>To be added.</summary> + <returns>To be added.</returns> + <remarks>To be added.</remarks> + </Docs> + </Member> + <Member MemberName="ShouldDelayContentTouches"> + <MemberSignature Language="C#" Value="public static bool ShouldDelayContentTouches (this Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView> config);" /> + <MemberSignature Language="ILAsm" Value=".method public static hidebysig bool ShouldDelayContentTouches(class Xamarin.Forms.IPlatformElementConfiguration`2<class Xamarin.Forms.PlatformConfiguration.iOS, class Xamarin.Forms.ScrollView> config) cil managed" /> + <MemberType>Method</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.Boolean</ReturnType> + </ReturnValue> + <Parameters> + <Parameter Name="config" Type="Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView>" RefType="this" /> + </Parameters> + <Docs> + <param name="config">To be added.</param> + <summary>To be added.</summary> + <returns>To be added.</returns> + <remarks>To be added.</remarks> + </Docs> + </Member> + <Member MemberName="ShouldDelayContentTouchesProperty"> + <MemberSignature Language="C#" Value="public static readonly Xamarin.Forms.BindableProperty ShouldDelayContentTouchesProperty;" /> + <MemberSignature Language="ILAsm" Value=".field public static initonly class Xamarin.Forms.BindableProperty ShouldDelayContentTouchesProperty" /> + <MemberType>Field</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>Xamarin.Forms.BindableProperty</ReturnType> + </ReturnValue> + <Docs> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + </Member> + <Member MemberName="SetShouldDelayContentTouches"> + <MemberSignature Language="C#" Value="public static void SetShouldDelayContentTouches (Xamarin.Forms.BindableObject element, bool value);" /> + <MemberSignature Language="ILAsm" Value=".method public static hidebysig void SetShouldDelayContentTouches(class Xamarin.Forms.BindableObject element, bool value) cil managed" /> + <MemberType>Method</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.Void</ReturnType> + </ReturnValue> + <Parameters> + <Parameter Name="element" Type="Xamarin.Forms.BindableObject" /> + <Parameter Name="value" Type="System.Boolean" /> + </Parameters> + <Docs> + <param name="element">To be added.</param> + <param name="value">To be added.</param> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + </Member> + <Member MemberName="SetShouldDelayContentTouches"> + <MemberSignature Language="C#" Value="public static Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView> SetShouldDelayContentTouches (this Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView> config, bool value);" /> + <MemberSignature Language="ILAsm" Value=".method public static hidebysig class Xamarin.Forms.IPlatformElementConfiguration`2<class Xamarin.Forms.PlatformConfiguration.iOS, class Xamarin.Forms.ScrollView> SetShouldDelayContentTouches(class Xamarin.Forms.IPlatformElementConfiguration`2<class Xamarin.Forms.PlatformConfiguration.iOS, class Xamarin.Forms.ScrollView> config, bool value) cil managed" /> + <MemberType>Method</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView></ReturnType> + </ReturnValue> + <Parameters> + <Parameter Name="config" Type="Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView>" RefType="this" /> + <Parameter Name="value" Type="System.Boolean" /> + </Parameters> + <Docs> + <param name="config">To be added.</param> + <param name="value">To be added.</param> + <summary>To be added.</summary> + <returns>To be added.</returns> + <remarks>To be added.</remarks> + </Docs> + </Member> + </Members> +</Type> |