-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
MainWindowView.swift
87 lines (82 loc) · 3.42 KB
/
MainWindowView.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import SwiftUI
@MainActor
struct MainWindowView: View {
@Namespace var namespace
private var focus: FocusState<AppFocus?>.Binding
private let core: Core
private let onSceneAction: (AppScene) -> Void
init(_ focus: FocusState<AppFocus?>.Binding,
core: Core,
onSceneAction: @escaping (AppScene) -> Void) {
self.focus = focus
self.core = core
self.onSceneAction = onSceneAction
}
var body: some View {
ContainerView(
focus,
contentState: .readonly(core.contentStore.state),
publisher: core.contentCoordinator.contentPublisher,
applicationTriggerSelectionManager: core.applicationTriggerSelectionManager,
commandSelectionManager: core.commandSelectionManager,
configSelectionManager: core.configSelectionManager,
contentSelectionManager: core.contentSelectionManager,
groupsSelectionManager: core.groupSelectionManager,
keyboardShortcutSelectionManager: core.keyboardShortcutSelectionManager,
triggerPublisher: core.detailCoordinator.triggerPublisher,
infoPublisher: core.detailCoordinator.infoPublisher,
commandPublisher: core.detailCoordinator.commandsPublisher
) { action, undoManager in
let oldConfiguration = core.configurationStore.selectedConfiguration
switch action {
case .openScene(let scene):
onSceneAction(scene)
case .sidebar(let sidebarAction):
switch sidebarAction {
case .openScene(let scene):
onSceneAction(scene)
default:
core.configCoordinator.handle(sidebarAction)
core.sidebarCoordinator.handle(sidebarAction)
core.contentCoordinator.handle(sidebarAction)
core.detailCoordinator.handle(sidebarAction)
}
case .content(let contentAction):
core.contentCoordinator.handle(contentAction)
core.detailCoordinator.handle(contentAction)
case .detail(let detailAction):
core.detailCoordinator.handle(detailAction)
core.contentCoordinator.handle(detailAction)
}
undoManager?.registerUndo(withTarget: core.configurationStore, handler: { store in
store.update(oldConfiguration)
core.contentStore.use(oldConfiguration)
core.sidebarCoordinator.handle(.refresh)
core.contentCoordinator.handle(.refresh(core.groupSelectionManager.selections))
core.detailCoordinator.handle(.selectWorkflow(workflowIds: core.contentSelectionManager.selections))
})
}
.onAppear {
KeyboardCowboy.activate()
}
.onDisappear {
KeyboardCowboy.deactivate()
}
.environmentObject(ApplicationStore.shared)
.environmentObject(core.contentStore)
.environmentObject(core.groupStore)
.environmentObject(core.shortcutStore)
.environmentObject(core.recorderStore)
.environmentObject(core.configCoordinator.configurationsPublisher)
.environmentObject(core.configCoordinator.configurationPublisher)
.environmentObject(core.sidebarCoordinator.publisher)
.environmentObject(core.contentCoordinator.contentPublisher)
.environmentObject(core.contentCoordinator.groupPublisher)
.environmentObject(core.detailCoordinator.statePublisher)
.environmentObject(core.detailCoordinator.infoPublisher)
.environmentObject(core.detailCoordinator.triggerPublisher)
.environmentObject(core.detailCoordinator.commandsPublisher)
.environmentObject(core.snippetController)
.environmentObject(OpenPanelController())
}
}