Skip to content

Make status bar an actual divider #1731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions CodeEdit/Features/SplitView/Views/SplitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import SwiftUI
struct SplitView<Content: View>: View {
var axis: Axis
var content: Content
var showDividers: Bool = false

init(axis: Axis, @ViewBuilder content: () -> Content) {
init(axis: Axis, showDividers: Bool = false, @ViewBuilder content: () -> Content) {
self.axis = axis
self.showDividers = showDividers
self.content = content()
}

Expand All @@ -21,7 +23,7 @@ struct SplitView<Content: View>: View {
var body: some View {
VStack {
content.variadic { children in
SplitViewControllerView(axis: axis, children: children, viewController: $viewController)
SplitViewControllerView(axis: axis, children: children, showDividers: showDividers, viewController: $viewController)
}
}
._trait(SplitViewControllerLayoutValueKey.self, viewController)
Expand Down
25 changes: 23 additions & 2 deletions CodeEdit/Features/SplitView/Views/SplitViewControllerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct SplitViewControllerView: NSViewControllerRepresentable {

var axis: Axis
var children: _VariadicView.Children
var showDividers: Bool
@Binding var viewController: () -> SplitViewController?

func makeNSViewController(context: Context) -> SplitViewController {
Expand Down Expand Up @@ -61,7 +62,7 @@ struct SplitViewControllerView: NSViewControllerRepresentable {
}

func makeCoordinator() -> SplitViewController {
SplitViewController(parent: self, axis: axis)
SplitViewController(parent: self, axis: axis, showDividers: showDividers)
}
}

Expand All @@ -70,10 +71,12 @@ final class SplitViewController: NSSplitViewController {
var items: [SplitViewItem] = []
var axis: Axis
var parentView: SplitViewControllerView
var showDividers: Bool

init(parent: SplitViewControllerView, axis: Axis = .horizontal) {
init(parent: SplitViewControllerView, axis: Axis = .horizontal, showDividers: Bool = true) {
self.axis = axis
self.parentView = parent
self.showDividers = showDividers
super.init(nibName: nil, bundle: nil)
}

Expand All @@ -95,6 +98,24 @@ final class SplitViewController: NSSplitViewController {
false
}

override func splitView(
_ splitView: NSSplitView,
effectiveRect proposedEffectiveRect: NSRect,
forDrawnRect drawnRect: NSRect,
ofDividerAt dividerIndex: Int
) -> NSRect {
if showDividers {
super.splitView(
splitView,
effectiveRect: proposedEffectiveRect,
forDrawnRect: drawnRect,
ofDividerAt: dividerIndex
)
} else {
.zero
}
}

func collapse(for id: AnyHashable, enabled: Bool) {
items.first { $0.id == id }?.item.animator().isCollapsed = enabled
}
Expand Down
5 changes: 3 additions & 2 deletions CodeEdit/Features/StatusBar/Views/StatusBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ struct StatusBarView: View {

/// A drag gesture to resize the drawer beneath the status bar
private var dragGesture: some Gesture {
DragGesture(coordinateSpace: .global)
return DragGesture.init(coordinateSpace: .global)
.onChanged { value in
proxy.setPosition(of: 0, position: value.location.y + Self.height / 2)
proxy.setPosition(of: 0, position: value.location.y - Self.height / 2)
proxy.setPosition(of: 1, position: value.location.y + Self.height / 2)
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions CodeEdit/WorkspaceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct WorkspaceView: View {
if workspace.workspaceFileManager != nil {
VStack {
SplitViewReader { proxy in
SplitView(axis: .vertical) {
SplitView(axis: .vertical, showDividers: false) {
EditorLayoutView(
layout: editorManager.isFocusingActiveEditor
? editorManager.activeEditor.getEditorLayout() ?? editorManager.editorLayout
Expand All @@ -46,10 +46,9 @@ struct WorkspaceView: View {
.collapsed($utilityAreaViewModel.isMaximized)
.frame(minHeight: 170 + 29 + 29)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.holdingPriority(.init(1))
.safeAreaInset(edge: .bottom, spacing: 0) {
StatusBarView(proxy: proxy)
}

StatusBarView(proxy: proxy)

UtilityAreaView()
.collapsable()
.collapsed($utilityAreaViewModel.isCollapsed)
Expand Down