-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
MainWindow.swift
67 lines (61 loc) · 2.04 KB
/
MainWindow.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import Bonzai
import SwiftUI
struct MainWindow: Scene {
private let core: Core
@FocusState var focus: AppFocus?
@Environment(\.openWindow) private var openWindow
private let onScene: (AppScene) -> Void
init(_ core: Core, onScene: @escaping (AppScene) -> Void) {
self.core = core
self.onScene = onScene
}
var body: some Scene {
WindowGroup(id: KeyboardCowboy.mainWindowIdentifier) {
MainWindowView($focus, core: core, onSceneAction: {
onScene($0)
})
.animation(.easeInOut, value: core.contentStore.state)
.onAppear { NSWindow.allowsAutomaticWindowTabbing = false }
}
.windowResizability(.contentSize)
.windowStyle(.hiddenTitleBar)
.commands {
CommandGroup(after: .appSettings) {
AppMenu()
Button { openWindow(id: KeyboardCowboy.releaseNotesWindowIdentifier) } label: { Text("What's new?") }
}
CommandGroup(replacing: .newItem) {
FileMenu(
onNewConfiguration: {
let action = SidebarView.Action.addConfiguration(name: "New Configuration")
core.configCoordinator.handle(action)
core.sidebarCoordinator.handle(action)
core.contentCoordinator.handle(action)
core.detailCoordinator.handle(action)
},
onNewGroup: { onScene(.addGroup) },
onNewWorkflow: {
let action = ContentView.Action.addWorkflow(workflowId: UUID().uuidString)
core.contentCoordinator.handle(action)
core.detailCoordinator.handle(action)
focus = .detail(.name)
},
onNewCommand: { id in
onScene(.addCommand(id))
}
)
.environmentObject(core.contentStore.groupStore)
.environmentObject(core.detailCoordinator.statePublisher)
.environmentObject(core.detailCoordinator.infoPublisher)
}
CommandGroup(replacing: .toolbar) {
ViewMenu(onFilter: {
focus = .search
})
}
CommandGroup(replacing: .help) {
HelpMenu()
}
}
}
}