Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Implement item move on iOS CollectionView #4863

Merged
merged 2 commits into from Jan 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,7 +21,6 @@ public ObservableItemsSource(IEnumerable itemSource, UICollectionView collection

void CollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
{
// TODO hartez 2018/07/31 16:02:50 Handle the rest of these cases (implementing selection will make them much easier to test)
switch (args.Action)
{
case NotifyCollectionChangedAction.Add:
Expand All @@ -33,6 +32,7 @@ void CollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
case NotifyCollectionChangedAction.Replace:
break;
case NotifyCollectionChangedAction.Move:
Move(args);
break;
case NotifyCollectionChangedAction.Reset:
break;
Expand All @@ -41,6 +41,14 @@ void CollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
}
}

void Move(NotifyCollectionChangedEventArgs args)
{
var oldPath = NSIndexPath.Create(0, args.OldStartingIndex);
var newPath = NSIndexPath.Create(0, args.NewStartingIndex);

_collectionView.MoveItem(oldPath, newPath);
}

static NSIndexPath[] CreateIndexesFrom(int startIndex, int count)
{
var result = new NSIndexPath[count];
Expand Down