Skip to content

Commit

Permalink
Hide Interface - Added support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nis-ship-it committed Oct 20, 2024
1 parent 8fe1b28 commit 8a43a58
Showing 1 changed file with 47 additions and 1 deletion.
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 labelForInterfaceToggle: 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(labelForInterfaceToggle) {
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

0 comments on commit 8a43a58

Please sign in to comment.