ios: mac catalyst kb shortcuts
This commit is contained in:
@@ -443,6 +443,34 @@ final class SybilViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
func selectPreviousSidebarItem() {
|
||||
selectAdjacentSidebarItem(offset: -1)
|
||||
}
|
||||
|
||||
func selectNextSidebarItem() {
|
||||
selectAdjacentSidebarItem(offset: 1)
|
||||
}
|
||||
|
||||
private func selectAdjacentSidebarItem(offset: Int) {
|
||||
let items = sidebarItems
|
||||
guard !items.isEmpty else {
|
||||
return
|
||||
}
|
||||
|
||||
let currentIndex = selectedItem.flatMap { selection in
|
||||
items.firstIndex { $0.selection == selection }
|
||||
}
|
||||
let startingIndex = currentIndex ?? (offset < 0 ? items.count : -1)
|
||||
let nextIndex = (startingIndex + offset + items.count) % items.count
|
||||
let nextSelection = items[nextIndex].selection
|
||||
|
||||
guard draftKind != nil || selectedItem != nextSelection else {
|
||||
return
|
||||
}
|
||||
|
||||
select(nextSelection)
|
||||
}
|
||||
|
||||
func deleteItem(_ selection: SidebarSelection) async {
|
||||
guard isAuthenticated else {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user