Browse Source

fix order drop

Marino Faggiana 6 years ago
parent
commit
2d22fe2165
1 changed files with 21 additions and 13 deletions
  1. 21 13
      iOSClient/Scan/ScanCollectionView.swift

+ 21 - 13
iOSClient/Scan/ScanCollectionView.swift

@@ -462,27 +462,35 @@ extension DragDropViewController : UICollectionViewDropDelegate {
         
         let destinationIndexPath: IndexPath
         
-        if let indexPath = coordinator.destinationIndexPath {
-        
-            destinationIndexPath = indexPath
-        
-        } else {
-        
-            // Get last index path of table view.
-            let section = collectionView.numberOfSections - 1
-            let row = collectionView.numberOfItems(inSection: section)
-            
-            destinationIndexPath = IndexPath(row: row, section: section)
-        }
-        
         switch coordinator.proposal.operation {
             
         case .move:
+            
+            if let indexPath = coordinator.destinationIndexPath {
+                
+                destinationIndexPath = indexPath
+                
+            } else {
+                
+                // Get last index path of table view.
+                let section = collectionView.numberOfSections - 1
+                let row = collectionView.numberOfItems(inSection: section)
+                
+                destinationIndexPath = IndexPath(row: row, section: section)
+            }
             self.reorderItems(coordinator: coordinator, destinationIndexPath: destinationIndexPath, collectionView: collectionView)
+            
             break
             
         case .copy:
+            
+            // Get last index path of table view.
+            let section = collectionView.numberOfSections - 1
+            let row = collectionView.numberOfItems(inSection: section)
+            
+            destinationIndexPath = IndexPath(row: row, section: section)
             self.copyItems(coordinator: coordinator, destinationIndexPath: destinationIndexPath, collectionView: collectionView)
+            
             break
             
         default: