Skip to content

Commit 8a43a58

Browse files
author
Nish
committed
Hide Interface - Added support
At the moment this code, toggles navigator, inspector, utility, pathbar and toolbar area and handles all cases for each of them when using hide interface.
1 parent 8fe1b28 commit 8a43a58

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

CodeEdit/Features/WindowCommands/ViewCommands.swift

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct ViewCommands: Commands {
7171

7272
Divider()
7373

74-
HideCommands()
74+
HideCommands(showEditorPathBar: $showEditorPathBar)
7575

7676
Divider()
7777

@@ -94,6 +94,7 @@ struct ViewCommands: Commands {
9494
extension ViewCommands {
9595
struct HideCommands: View {
9696
@UpdatingWindowController var windowController: CodeEditWindowController?
97+
@Binding var showEditorPathBar: Bool
9798

9899
var navigatorCollapsed: Bool {
99100
windowController?.navigatorCollapsed ?? true
@@ -111,6 +112,18 @@ extension ViewCommands {
111112
windowController?.toolbarCollapsed ?? true
112113
}
113114

115+
private var labelForInterfaceToggle: String {
116+
let shouldShow = navigatorCollapsed && inspectorCollapsed &&
117+
toolbarCollapsed && !showEditorPathBar
118+
return "\(shouldShow ? "Show" : "Hide") Interface"
119+
}
120+
121+
private var isAnyPanelVisible: Bool {
122+
return !navigatorCollapsed || !inspectorCollapsed ||
123+
!utilityAreaCollapsed || !toolbarCollapsed ||
124+
showEditorPathBar
125+
}
126+
114127
var body: some View {
115128
Button("\(navigatorCollapsed ? "Show" : "Hide") Navigator") {
116129
windowController?.toggleFirstPanel()
@@ -135,6 +148,39 @@ extension ViewCommands {
135148
}
136149
.disabled(windowController == nil)
137150
.keyboardShortcut("t", modifiers: [.option, .command])
151+
152+
Button(labelForInterfaceToggle) {
153+
if isAnyPanelVisible {
154+
if !navigatorCollapsed {
155+
windowController?.toggleFirstPanel()
156+
}
157+
158+
if !inspectorCollapsed {
159+
windowController?.toggleLastPanel()
160+
}
161+
162+
if !utilityAreaCollapsed {
163+
CommandManager.shared.executeCommand("open.drawer")
164+
}
165+
166+
if !toolbarCollapsed {
167+
windowController?.toggleToolbar()
168+
}
169+
170+
if showEditorPathBar {
171+
showEditorPathBar.toggle()
172+
}
173+
174+
} else {
175+
// If all are closed, you can choose to open them again
176+
windowController?.toggleFirstPanel()
177+
windowController?.toggleLastPanel()
178+
windowController?.toggleToolbar()
179+
showEditorPathBar.toggle()
180+
}
181+
}
182+
.disabled(windowController == nil)
183+
.keyboardShortcut(".", modifiers: [.command])
138184
}
139185
}
140186
}

0 commit comments

Comments
 (0)