forked from gluonfield/enchanted
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: keyboard shortcuts UI (gluonfield#30)
- Loading branch information
1 parent
f3b4917
commit a5c07d1
Showing
12 changed files
with
143 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
Enchanted/UI/Shared/Sidebar/Components/KeyboardShortcuts.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// KeyboardShortcuts.swift | ||
// Enchanted | ||
// | ||
// Created by Augustinas Malinauskas on 19/02/2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct KeyboardShortcut: Identifiable { | ||
let id: Int | ||
var keys: [String] | ||
var description: String | ||
} | ||
|
||
struct KeyboardShortcuts: View { | ||
|
||
var shortcuts = [ | ||
KeyboardShortcut(id: 1, keys: ["⌃", "⌘", "K"], description: "Open Panel Window"), | ||
KeyboardShortcut(id: 2, keys: ["⌘", "N"], description: "New Conversation"), | ||
KeyboardShortcut(id: 3, keys: ["⌘", "⌥", "S"], description: "Hide/Show sidebar"), | ||
KeyboardShortcut(id: 4, keys: ["⌘", "V"], description: "Paste text or image from clipboard into message box ") | ||
] | ||
|
||
var body: some View { | ||
Table(shortcuts) { | ||
TableColumn("Shortcut") { shortcut in | ||
Text(shortcut.keys.joined(separator: " + ")) | ||
} | ||
.width(min: 100, max: 150) | ||
TableColumn("Description") { shortcut in | ||
Text(String(shortcut.description)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
KeyboardShortcuts() | ||
} |
39 changes: 39 additions & 0 deletions
39
Enchanted/UI/Shared/Sidebar/Components/SidebarButton.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// SidebarButton.swift | ||
// Enchanted | ||
// | ||
// Created by Augustinas Malinauskas on 19/02/2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SidebarButton: View { | ||
var title: String | ||
var image: String | ||
var onClick: () -> () | ||
|
||
var body: some View { | ||
Button(action: onClick) { | ||
HStack { | ||
Image(systemName: image) | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 16) | ||
|
||
Text(title) | ||
.lineLimit(1) | ||
.font(.system(size: 14)) | ||
.fontWeight(.regular) | ||
|
||
Spacer() | ||
} | ||
.padding(8) | ||
.foregroundColor(Color(.label)) | ||
} | ||
.buttonStyle(.plain) | ||
} | ||
} | ||
|
||
#Preview { | ||
SidebarButton(title: "Settings", image: "gearshape.fill", onClick: {}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters