Browse Source

feat: Add keyboard shortcuts to switch main views and create posts

I added several keyboard shortcuts so users can switch between the main
views of "Home", "DMs", "Search", and "Notifications" with the shortcuts
"CMD+1", "CMD+2" etc.. Those shortcuts made the most sense to me but
they're definitely up for discussion.

Added a new keyboard shortcut to creat a new post. Unfortunately it had
to be "SHIFT+CMD+N" because "CMD+N" already created a new window.

Closes: #163
Changelog-Added: Cmd-{1,2,3,4} to switch between tabs on MacOS
Changelog-Added: Shift-Cmd-N to create a post on MacOS
post-button-style
Jonathan Milligan 2 years ago
committed by William Casarin
parent
commit
393745f67c
  1. 11
      damus/Views/MainTabView.swift
  2. 1
      damus/Views/PostButton.swift

11
damus/Views/MainTabView.swift

@ -76,14 +76,11 @@ struct TabBar: View {
VStack {
Divider()
HStack {
TabButton(timeline: .home, img: "house", selected: $selected, new_events: $new_events, action: action)
TabButton(timeline: .dms, img: "bubble.left.and.bubble.right", selected: $selected, new_events: $new_events, action: action)
TabButton(timeline: .search, img: "magnifyingglass.circle", selected: $selected, new_events: $new_events, action: action)
TabButton(timeline: .notifications, img: "bell", selected: $selected, new_events: $new_events, action: action)
TabButton(timeline: .home, img: "house", selected: $selected, new_events: $new_events, action: action).keyboardShortcut("1")
TabButton(timeline: .dms, img: "bubble.left.and.bubble.right", selected: $selected, new_events: $new_events, action: action).keyboardShortcut("2")
TabButton(timeline: .search, img: "magnifyingglass.circle", selected: $selected, new_events: $new_events, action: action).keyboardShortcut("3")
TabButton(timeline: .notifications, img: "bell", selected: $selected, new_events: $new_events, action: action).keyboardShortcut("4")
}
}
}
}

1
damus/Views/PostButton.swift

@ -23,6 +23,7 @@ func PostButton(action: @escaping () -> ()) -> some View {
radius: 3,
x: 3,
y: 3)
.keyboardShortcut("n", modifiers: [.command, .shift])
}
func PostButtonContainer(action: @escaping () -> ()) -> some View {

Loading…
Cancel
Save