瀏覽代碼

fix order drop

Marino Faggiana 6 年之前
父節點
當前提交
2d22fe2165
共有 1 個文件被更改,包括 21 次插入13 次删除
  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: