Revert "ios: raise touch event on touchbegin. (#6989) fixes #3320" (#7787)

This reverts commit dca82ed828.
This commit is contained in:
Rui Marinho 2019-10-03 09:50:00 +01:00 коммит произвёл GitHub
Родитель 7f384f34fa
Коммит b86351d71d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 15 добавлений и 129 удалений

Просмотреть файл

@ -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
}
}

Просмотреть файл

@ -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>

Просмотреть файл

@ -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

Просмотреть файл

@ -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)