+++ /dev/null
-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
-
- }
-}
<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>
{
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) =>
{
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
bool _disposed;
bool _wasEmpty;
bool _estimatedRowHeight;
- NSIndexPath _lastTouchedCell;
public UITableViewRowAnimation ReloadSectionsAnimation { get; set; } = UITableViewRowAnimation.Automatic;
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;
}
_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;
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
- _lastTouchedCell = null;
var cell = tableView.CellAt(indexPath);
if (cell == null)
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArguments: ${{ parameters.msbuildExtraArguments }} /p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"
-
+
- task: VSTest@2
displayName: 'Unit Tests'
inputs: