ios: mac catalyst kb shortcuts

This commit is contained in:
2026-05-02 23:50:51 -07:00
parent 29e340fd08
commit 2f265fd847
3 changed files with 109 additions and 0 deletions

View File

@@ -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