blob: ca05bc548e4099b10c4810aa18bc3f6402ac8804 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
using System;
#if __UNIFIED__
using Foundation;
#else
using MonoTouch.Foundation;
#endif
namespace Xamarin.Forms.Platform.iOS
{
internal static class CellExtensions
{
internal static NSIndexPath GetIndexPath(this Cell self)
{
if (self == null)
throw new ArgumentNullException("self");
NSIndexPath path;
if (self.RealParent is ListView)
{
var section = 0;
var til = TemplatedItemsList<ItemsView<Cell>, Cell>.GetGroup(self);
if (til != null)
section = TemplatedItemsList<ItemsView<Cell>, Cell>.GetIndex(til.HeaderContent);
var row = TemplatedItemsList<ItemsView<Cell>, Cell>.GetIndex(self);
path = NSIndexPath.FromRowSection(row, section);
}
else if (self.RealParent is TableView)
{
var tmPath = TableView.TableSectionModel.GetPath(self);
path = NSIndexPath.FromRowSection(tmPath.Item2, tmPath.Item1);
}
else
throw new NotSupportedException("Unknown cell parent type");
return path;
}
}
}
|