Skip to content

Commit

Permalink
Start adding FindVisiblePositions
Browse files Browse the repository at this point in the history
  • Loading branch information
Redth committed Jun 7, 2024
1 parent 79e5718 commit 65366cc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions VirtualListView/Apple/VirtualListViewHandler.ios.maccatalyst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,17 @@ public void InvalidateData()
});

}

public IReadOnlyList<IPositionInfo> FindVisiblePositions()
{
var positions = new List<PositionInfo>();

foreach (var cell in PlatformView.VisibleCells)
{
if (cell is CvCell cvCell)
positions.Add(cvCell.PositionInfo);
}

return positions;
}
}
2 changes: 2 additions & 0 deletions VirtualListView/IVirtualListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public interface IVirtualListView : IView
void ClearSelectedItems();

void ScrollToItem(ItemPosition path, bool animated);

IReadOnlyList<IPositionInfo> FindVisiblePositions();
}

public enum ListOrientation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,19 @@ void UpdateHorizontalScrollbarVisibility(ScrollBarVisibility scrollBarVisibility

recyclerView.HorizontalScrollBarEnabled = newHorizontalScrollVisiblility == ScrollBarVisibility.Always;
}

public IReadOnlyList<IPositionInfo> FindVisiblePositions()
{
var positions = new List<IPositionInfo>();

var firstVisibleItemPosition = layoutManager.FindFirstVisibleItemPosition();
var lastVisibleItemPosition = layoutManager.FindLastVisibleItemPosition();

for (var p = firstVisibleItemPosition; p <= lastVisibleItemPosition; p++)
{
positions.Add(PositionalViewSelector.GetInfo(p));
}

return positions;
}
}

0 comments on commit 65366cc

Please sign in to comment.