Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion CodeEdit/Features/WindowCommands/ViewCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct ViewCommands: Commands {

Divider()

HideCommands()
HideCommands(showEditorPathBar: $showEditorPathBar)

Divider()

Expand All @@ -94,6 +94,7 @@ struct ViewCommands: Commands {
extension ViewCommands {
struct HideCommands: View {
@UpdatingWindowController var windowController: CodeEditWindowController?
@Binding var showEditorPathBar: Bool

var navigatorCollapsed: Bool {
windowController?.navigatorCollapsed ?? true
Expand All @@ -111,6 +112,18 @@ extension ViewCommands {
windowController?.toolbarCollapsed ?? true
}

private var interfaceToggleLabel: String {
let shouldShow = navigatorCollapsed && inspectorCollapsed &&
toolbarCollapsed && !showEditorPathBar
return "\(shouldShow ? "Show" : "Hide") Interface"
}

private var isAnyPanelVisible: Bool {
return !navigatorCollapsed || !inspectorCollapsed ||
!utilityAreaCollapsed || !toolbarCollapsed ||
showEditorPathBar
}

var body: some View {
Button("\(navigatorCollapsed ? "Show" : "Hide") Navigator") {
windowController?.toggleFirstPanel()
Expand All @@ -135,6 +148,39 @@ extension ViewCommands {
}
.disabled(windowController == nil)
.keyboardShortcut("t", modifiers: [.option, .command])

Button(interfaceToggleLabel) {
if isAnyPanelVisible {
if !navigatorCollapsed {
windowController?.toggleFirstPanel()
}

if !inspectorCollapsed {
windowController?.toggleLastPanel()
}

if !utilityAreaCollapsed {
CommandManager.shared.executeCommand("open.drawer")
}

if !toolbarCollapsed {
windowController?.toggleToolbar()
}

if showEditorPathBar {
showEditorPathBar.toggle()
}

} else {
// If all are closed, you can choose to open them again
windowController?.toggleFirstPanel()
windowController?.toggleLastPanel()
windowController?.toggleToolbar()
showEditorPathBar.toggle()
}
}
.disabled(windowController == nil)
.keyboardShortcut(".", modifiers: [.command])
}
}
}
Expand Down
Loading