Skip to content

Commit 20f6498

Browse files
committed
Tweak up/down command
1 parent 7c3e58e commit 20f6498

1 file changed

Lines changed: 2 additions & 20 deletions

File tree

Sources/UIKeyCommandTableView/UIKeyCommandTableView.swift

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,30 +149,12 @@ public class UIKeyCommandTableView: UITableView {
149149

150150
@objc
151151
public func selectPreviousRow() {
152-
guard let currentSelection = indexPathForSelectedRow else {
153-
return selectRowIfPossible(at: {
154-
if let lastVisibleRow = indexPathsForVisibleRows?.last {
155-
return lastVisibleRow
156-
}
157-
return indexPathForLastRowInLastSection
158-
}())
159-
}
160-
161-
selectRowIfPossible(at: currentSelection.previousRow())
152+
selectRowIfPossible(at: indexPathForSelectedRow?.previousRow() ?? indexPathForLastVisibleRow)
162153
}
163154

164155
@objc
165156
public func selectNextRow() {
166-
guard let currentSelection = indexPathForSelectedRow else {
167-
return selectRowIfPossible(at: {
168-
for indexPath in indexPathsForVisibleRows ?? [] where isRowVisible(at: indexPath) == .fullyVisible {
169-
return indexPath
170-
}
171-
return IndexPath(row: NSNotFound, section: .zero)
172-
}())
173-
}
174-
175-
selectRowIfPossible(at: currentSelection.nextRow())
157+
selectRowIfPossible(at: indexPathForSelectedRow?.nextRow() ?? indexPathForFirstVisibleRow)
176158
}
177159

178160
}

0 commit comments

Comments
 (0)