From c3da7dbb34a16e702bcd3b186646a88c7fb7b75c Mon Sep 17 00:00:00 2001 From: "E.Z. Hart" Date: Mon, 7 Jan 2019 05:13:32 -0700 Subject: [PATCH] [iOS] Implement item move on iOS CollectionView (#4863) * Implement item move on iOS CollectionView * Remove private modifier --- .../CollectionView/ObservableItemsSource.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs b/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs index e2ed690..d10d224 100644 --- a/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs +++ b/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs @@ -21,7 +21,6 @@ namespace Xamarin.Forms.Platform.iOS 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: @@ -33,6 +32,7 @@ namespace Xamarin.Forms.Platform.iOS case NotifyCollectionChangedAction.Replace: break; case NotifyCollectionChangedAction.Move: + Move(args); break; case NotifyCollectionChangedAction.Reset: break; @@ -41,6 +41,14 @@ namespace Xamarin.Forms.Platform.iOS } } + 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]; -- 2.7.4