зеркало из https://github.com/DeGsoft/maui-linux.git
[iOS] Proxy UITableViewCell SelectionStyle when wrapped (#1002)
* making sure the UITableViewCell SelectionStyle proxies up when wrapped in ContextActionCell and with recycling mode * corrected coding style, tabs instead of spaces. Removed stub for UITest.
This commit is contained in:
Родитель
ec75b998fa
Коммит
723cb80c6b
|
@ -20,6 +20,7 @@ using RectangleF = CoreGraphics.CGRect;
|
||||||
[assembly: ExportRenderer(typeof(TabbedPage), typeof(TabbedPageWithCustomBarColorRenderer))]
|
[assembly: ExportRenderer(typeof(TabbedPage), typeof(TabbedPageWithCustomBarColorRenderer))]
|
||||||
[assembly: ExportRenderer(typeof(Bugzilla43161.AccessoryViewCell), typeof(AccessoryViewCellRenderer))]
|
[assembly: ExportRenderer(typeof(Bugzilla43161.AccessoryViewCell), typeof(AccessoryViewCellRenderer))]
|
||||||
[assembly: ExportRenderer(typeof(Bugzilla36802.AccessoryViewCell), typeof(AccessoryViewCellRenderer))]
|
[assembly: ExportRenderer(typeof(Bugzilla36802.AccessoryViewCell), typeof(AccessoryViewCellRenderer))]
|
||||||
|
[assembly: ExportRenderer(typeof(Bugzilla52700.NoSelectionViewCell), typeof(NoSelectionViewCellRenderer))]
|
||||||
namespace Xamarin.Forms.ControlGallery.iOS
|
namespace Xamarin.Forms.ControlGallery.iOS
|
||||||
{
|
{
|
||||||
public class CustomIOSMapRenderer : ViewRenderer<CustomMapView, MKMapView>
|
public class CustomIOSMapRenderer : ViewRenderer<CustomMapView, MKMapView>
|
||||||
|
@ -583,5 +584,18 @@ namespace Xamarin.Forms.ControlGallery.iOS
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class NoSelectionViewCellRenderer : ViewCellRenderer
|
||||||
|
{
|
||||||
|
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
|
||||||
|
{
|
||||||
|
var cell = base.GetCell(item, reusableCell, tv);
|
||||||
|
|
||||||
|
// remove highlight on selected cell
|
||||||
|
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
|
||||||
|
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using Xamarin.Forms.CustomAttributes;
|
||||||
|
using Xamarin.Forms.Internals;
|
||||||
|
#if UITEST
|
||||||
|
using Xamarin.UITest;
|
||||||
|
using NUnit.Framework;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Xamarin.Forms.Controls.Issues
|
||||||
|
{
|
||||||
|
[Preserve (AllMembers = true)]
|
||||||
|
[Issue (IssueTracker.Bugzilla, 52700, "[iOS] Recycled cell should respect selection style set to none", PlatformAffected.iOS)]
|
||||||
|
public class Bugzilla52700 : TestContentPage // or TestMasterDetailPage, etc ...
|
||||||
|
{
|
||||||
|
const string Instructions = "On iOS, all three of the following ListViews should not change background color upon selection. If the background of the row changes color, this test fails.";
|
||||||
|
const string ListView1 = "Custom Cell with Context Actions";
|
||||||
|
const string ListView2 = "Custom Cell + RecycleElement";
|
||||||
|
const string ListView3 = "Custom Cell + RetainElement";
|
||||||
|
|
||||||
|
public class NoSelectionViewCell : ViewCell
|
||||||
|
{
|
||||||
|
public Label label { get; set; }
|
||||||
|
|
||||||
|
public NoSelectionViewCell ()
|
||||||
|
{
|
||||||
|
label = new Label ();
|
||||||
|
label.SetBinding (Label.TextProperty, ".");
|
||||||
|
View = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NoSelectionViewCellWithContextActions : NoSelectionViewCell
|
||||||
|
{
|
||||||
|
public NoSelectionViewCellWithContextActions ()
|
||||||
|
{
|
||||||
|
label = new Label ();
|
||||||
|
label.SetBinding (Label.TextProperty, ".");
|
||||||
|
View = label;
|
||||||
|
|
||||||
|
var delete = new MenuItem { Text = "Delete" };
|
||||||
|
ContextActions.Add (delete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Init ()
|
||||||
|
{
|
||||||
|
var label = new Label { Text = Instructions };
|
||||||
|
var selectionLabel = new Label { Text = "<< THIS changes when row selected >>" };
|
||||||
|
var listView = new ListView { ItemTemplate = new DataTemplate (typeof (NoSelectionViewCellWithContextActions)), ItemsSource = Enumerable.Range (0, 9), Header = ListView1 };
|
||||||
|
var listView2 = new ListView (ListViewCachingStrategy.RecycleElement) { ItemTemplate = new DataTemplate (typeof (NoSelectionViewCell)), ItemsSource = Enumerable.Range (10, 19), Header = ListView2 };
|
||||||
|
var listView3 = new ListView { ItemTemplate = new DataTemplate (typeof (NoSelectionViewCell)), ItemsSource = Enumerable.Range (20, 29), Header = ListView3 };
|
||||||
|
|
||||||
|
listView.ItemSelected += (sender, e) => {
|
||||||
|
selectionLabel.Text = DateTime.Now.ToLocalTime ().ToString ();
|
||||||
|
};
|
||||||
|
|
||||||
|
listView2.ItemSelected += (sender, e) => {
|
||||||
|
selectionLabel.Text = DateTime.Now.ToLocalTime ().ToString ();
|
||||||
|
};
|
||||||
|
|
||||||
|
listView3.ItemSelected += (sender, e) => {
|
||||||
|
selectionLabel.Text = DateTime.Now.ToLocalTime ().ToString ();
|
||||||
|
};
|
||||||
|
|
||||||
|
Content = new StackLayout { Children = { label, selectionLabel, listView, listView2, listView3 } };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -569,6 +569,7 @@
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42956.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42956.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla38731.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla38731.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla56710.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla56710.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla52700.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
|
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
|
||||||
|
|
|
@ -251,6 +251,11 @@ namespace Xamarin.Forms.Platform.iOS
|
||||||
_scroller.SetContentOffset(new PointF(ScrollDelegate.ButtonsWidth, 0), false);
|
_scroller.SetContentOffset(new PointF(ScrollDelegate.ButtonsWidth, 0), false);
|
||||||
else
|
else
|
||||||
_scroller.SetContentOffset(new PointF(0, 0), false);
|
_scroller.SetContentOffset(new PointF(0, 0), false);
|
||||||
|
|
||||||
|
if (ContentCell != null)
|
||||||
|
{
|
||||||
|
SelectionStyle = ContentCell.SelectionStyle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче