Revert "ios: raise touch event on touchbegin. (#6989) fixes #3320" (#7787)
authorRui Marinho <me@ruimarinho.net>
Thu, 3 Oct 2019 08:50:00 +0000 (09:50 +0100)
committerGitHub <noreply@github.com>
Thu, 3 Oct 2019 08:50:00 +0000 (09:50 +0100)
This reverts commit dca82ed828e3fc1b3fede8d376ea8c4abf56d4ca.

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3320.cs [deleted file]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Platform.iOS/ContextActionCell.cs
Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
build/steps/build-windows.yml

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3320.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3320.cs
deleted file mode 100644 (file)
index 587d252..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-using System.Diagnostics;
-using Xamarin.Forms.CustomAttributes;
-using Xamarin.Forms.Internals;
-using System.Collections.ObjectModel;
-using System;
-
-#if UITEST
-using NUnit.Framework;
-using Xamarin.UITest;
-#endif
-
-namespace Xamarin.Forms.Controls.Issues
-{
-
-#if UITEST
-       [NUnit.Framework.Category(Core.UITests.UITestCategories.UwpIgnore)]
-#endif
-       [Preserve(AllMembers = true)]
-       [Issue(IssueTracker.Github, 3320, "[iOS] Cells aren't highlighted on touch-down when the ListView's CachingStrategy is set to RecycleElement", PlatformAffected.iOS)]
-       public class Issue3320 : TestContentPage
-       {
-
-               protected override void Init()
-               {
-                       Title = "List Page";
-                       ObservableCollection<string> source = new ObservableCollection<string>();
-                       for (int i = 0; i < 50; i++)
-                       {
-
-                               source.Add($"ListItem:{i}");
-                       }
-
-                       var listview = new ListView(ListViewCachingStrategy.RecycleElement)
-                       {
-                               ItemsSource = source
-                       };
-
-                       this.Content = listview;
-               }
-
-#if UITEST
-               [Test]
-               [Description("Verify that SelectedItem is selected on PressAndHold")]
-               [UiTest(typeof(ViewCell))]
-               [UiTest(typeof(ListView))]
-               [UiTest(typeof(ListView), "TapAndHoldSelectedItem")]
-               public void Issue3320TextTapAndHoldSelectsRow()
-               {
-                       RunningApp.TouchAndHold(q => q.Marked("ListItem:5"));
-                       RunningApp.Screenshot("TouchAndHold-ItemIsSelected");
-               }
-#endif
-
-       }
-}
index 8ec2c03..5da6421 100644 (file)
@@ -18,7 +18,6 @@
     <Compile Include="$(MSBuildThisFileDirectory)CollectionViewHeaderFooterTemplate.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)CollectionViewHeaderFooterView.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)CollectionViewItemsUpdatingScrollMode.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)Issue3320.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue3475.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue5354.xaml.cs">
       <SubType>Code</SubType>
index 5143959..2db3c22 100644 (file)
@@ -662,28 +662,7 @@ namespace Xamarin.Forms.Platform.iOS
                {
                        NSIndexPath _lastPath;
 
-                       public override void TouchesEnded(NSSet touches, UIEvent evt)
-                       {
-                               if (_lastPath == null)
-                                       return;
-
-                               var table = (UITableView)View;
-                               if (!_lastPath.Equals(table.IndexPathForSelectedRow))
-                                       table.SelectRow(_lastPath, false, UITableViewScrollPosition.None);
-                               table.Source.RowSelected(table, _lastPath);
-                       }
-
-                       public override void TouchesBegan(NSSet touches, UIEvent evt)
-                       {
-                               if (_lastPath == null)
-                                       return;
-
-                               var table = (UITableView)View;
-                               if (!_lastPath.Equals(table.IndexPathForSelectedRow))
-                                       table.Source.RowHighlighted(table, _lastPath); 
-                       }
-
-                       public SelectGestureRecognizer()
+                       public SelectGestureRecognizer() : base(Tapped)
                        {
                                ShouldReceiveTouch = (recognizer, touch) =>
                                {
@@ -699,6 +678,19 @@ namespace Xamarin.Forms.Platform.iOS
                                        return cell != null;
                                };
                        }
+
+                       static void Tapped(UIGestureRecognizer recognizer)
+                       {
+                               var selector = (SelectGestureRecognizer)recognizer;
+
+                               if (selector._lastPath == null)
+                                       return;
+
+                               var table = (UITableView)recognizer.View;
+                               if (!selector._lastPath.Equals(table.IndexPathForSelectedRow))
+                                       table.SelectRow(selector._lastPath, false, UITableViewScrollPosition.None);
+                               table.Source.RowSelected(table, selector._lastPath);
+                       }
                }
 
                class MoreActionSheetController : UIAlertController
index aa3586d..f350924 100644 (file)
@@ -952,7 +952,6 @@ namespace Xamarin.Forms.Platform.iOS
                        bool _disposed;
                        bool _wasEmpty;
                        bool _estimatedRowHeight;
-                       NSIndexPath _lastTouchedCell;
 
                        public UITableViewRowAnimation ReloadSectionsAnimation { get; set; } = UITableViewRowAnimation.Automatic;
 
@@ -995,47 +994,12 @@ namespace Xamarin.Forms.Platform.iOS
 
                        public override void DraggingEnded(UIScrollView scrollView, bool willDecelerate)
                        {
-                               if (_uiTableView != null)
-                               {
-                                       var heldSelectedRow = _uiTableView.IndexPathsForSelectedRows;
-                                       if (heldSelectedRow != null)
-                                               foreach (var row in heldSelectedRow)
-                                               {
-                                                       var cell = _uiTableView.CellAt(row);
-                                                       if (cell != null)
-                                                               cell.Selected = true;
-                                               }
-                               }
-
                                _isDragging = false;
                                _uiTableViewController.UpdateShowHideRefresh(false);
                        }
 
                        public override void DraggingStarted(UIScrollView scrollView)
                        {
-                               if (_uiTableView != null)
-                               {
-                                       if (_lastTouchedCell != null)
-                                       {
-                                               var lastTouchCell = _uiTableView.CellAt(_lastTouchedCell);
-                                               if (lastTouchCell != null)
-                                               {
-                                                       lastTouchCell.Selected = false;
-                                               }
-
-                                               _lastTouchedCell = null;
-                                       }
-
-                                       var heldSelectedRow = _uiTableView.IndexPathsForSelectedRows;
-                                       if(heldSelectedRow != null)
-                                               foreach (var row in heldSelectedRow)
-                                               {
-                                                       var cell = _uiTableView.CellAt(row);
-                                                       if(cell != null)
-                                                               cell.Selected = false;
-                                               }
-                               }
-
                                _isDragging = true;
                        }
 
@@ -1052,19 +1016,6 @@ namespace Xamarin.Forms.Platform.iOS
                                _setupSelection = true;
                        }
 
-                       public override void RowHighlighted(UITableView tableView, NSIndexPath rowIndexPath)
-                       {
-                               TouchCell(rowIndexPath);
-                       }
-
-                       void TouchCell(NSIndexPath rowIndexPath)
-                       {
-                               var cell = _uiTableView.CellAt(rowIndexPath);
-                               if(cell!= null)
-                                       cell.Selected = true;
-                               _lastTouchedCell = rowIndexPath;
-                       }
-
                        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
                        {
                                Cell cell;
@@ -1221,7 +1172,6 @@ namespace Xamarin.Forms.Platform.iOS
 
                        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
                        {
-                               _lastTouchedCell = null;
                                var cell = tableView.CellAt(indexPath);
 
                                if (cell == null)
index 4191a5b..691d251 100644 (file)
@@ -74,7 +74,7 @@ jobs:
         platform: '$(BuildPlatform)'
         configuration: '$(BuildConfiguration)'
         msbuildArguments: ${{ parameters.msbuildExtraArguments }} /p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"
-        
+
     - task: VSTest@2
       displayName: 'Unit Tests'
       inputs: