Fix suggestion for upward dragging drop zones. Issue #1360

This commit is contained in:
Maurice Parker 2019-11-26 13:42:25 -06:00
parent 19336dd07e
commit 3d1f68a877
1 changed files with 5 additions and 3 deletions

View File

@ -349,18 +349,20 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
var sortedNodes = nodes.sortedAlphabeticallyWithFoldersAtEnd()
let index = sortedNodes.firstIndex(of: draggedNode)!
sortedNodes.remove(at: index)
if index == 0 {
if parentNode.representedObject is Account {
return IndexPath(row: 0, section: destIndexPath.section)
} else {
return dataSource.indexPath(for: parentNode)!
let candidateIndexPath = dataSource.indexPath(for: sortedNodes[index])!
let movementAdjustment = sourceIndexPath < destIndexPath ? 1 : 0
return IndexPath(row: candidateIndexPath.row - movementAdjustment, section: candidateIndexPath.section)
}
} else {
sortedNodes.remove(at: index)
if index >= sortedNodes.count {
let lastSortedIndexPath = dataSource.indexPath(for: sortedNodes[sortedNodes.count - 1])!
let movementAdjustment = sourceIndexPath > destIndexPath ? 1 : 0