[iOS] Platform specifics to control ScrollView content touch delay (#563)
authoradrianknight89 <adrianknight89@outlook.com>
Fri, 24 Mar 2017 19:07:59 +0000 (14:07 -0500)
committerJason Smith <jason.smith@xamarin.com>
Fri, 24 Mar 2017 19:07:59 +0000 (12:07 -0700)
* can delay content touches optionally

* revert bug fix

* add back _tapGesture

* remove extra declaration

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41778.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ScrollView.cs [new file with mode: 0644]
Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs
docs/Xamarin.Forms.Core/Xamarin.Forms.PlatformConfiguration.iOSSpecific/ScrollView.xml [new file with mode: 0644]

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 (file)
index 0000000..327bea0
--- /dev/null
@@ -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
index bf393ae..98753ff 100644 (file)
     <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 (file)
index 0000000..1a90a1f
--- /dev/null
@@ -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
index a052352..1184e01 100644 (file)
     <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" />
index 244edfa..1fe2edb 100644 (file)
@@ -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 (file)
index 0000000..0e072e1
--- /dev/null
@@ -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&lt;Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView&gt; config);" />
+      <MemberSignature Language="ILAsm" Value=".method public static hidebysig bool ShouldDelayContentTouches(class Xamarin.Forms.IPlatformElementConfiguration`2&lt;class Xamarin.Forms.PlatformConfiguration.iOS, class Xamarin.Forms.ScrollView&gt; 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&lt;Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView&gt;" 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&lt;Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView&gt; SetShouldDelayContentTouches (this Xamarin.Forms.IPlatformElementConfiguration&lt;Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView&gt; config, bool value);" />
+      <MemberSignature Language="ILAsm" Value=".method public static hidebysig class Xamarin.Forms.IPlatformElementConfiguration`2&lt;class Xamarin.Forms.PlatformConfiguration.iOS, class Xamarin.Forms.ScrollView&gt; SetShouldDelayContentTouches(class Xamarin.Forms.IPlatformElementConfiguration`2&lt;class Xamarin.Forms.PlatformConfiguration.iOS, class Xamarin.Forms.ScrollView&gt; config, bool value) cil managed" />
+      <MemberType>Method</MemberType>
+      <AssemblyInfo>
+        <AssemblyVersion>2.0.0.0</AssemblyVersion>
+      </AssemblyInfo>
+      <ReturnValue>
+        <ReturnType>Xamarin.Forms.IPlatformElementConfiguration&lt;Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView&gt;</ReturnType>
+      </ReturnValue>
+      <Parameters>
+        <Parameter Name="config" Type="Xamarin.Forms.IPlatformElementConfiguration&lt;Xamarin.Forms.PlatformConfiguration.iOS,Xamarin.Forms.ScrollView&gt;" 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>