From 393745f67c43f57f7b75cfb205ea8fc270af2863 Mon Sep 17 00:00:00 2001 From: Jonathan Milligan Date: Tue, 27 Dec 2022 12:05:02 -0600 Subject: [PATCH] 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 --- damus/Views/MainTabView.swift | 11 ++++------- damus/Views/PostButton.swift | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/damus/Views/MainTabView.swift b/damus/Views/MainTabView.swift index 8bfeca26..e7666052 100644 --- a/damus/Views/MainTabView.swift +++ b/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") } } } } - - - diff --git a/damus/Views/PostButton.swift b/damus/Views/PostButton.swift index 866faa30..d1b82ddb 100644 --- a/damus/Views/PostButton.swift +++ b/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 {