Skip to content

Commit 2424295

Browse files
committed
first draft
1 parent 61bc52a commit 2424295

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

CodeEdit/Features/SplitView/Views/SplitView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import SwiftUI
1010
struct SplitView<Content: View>: View {
1111
var axis: Axis
1212
var content: Content
13+
var showDividers: Bool = false
1314

14-
init(axis: Axis, @ViewBuilder content: () -> Content) {
15+
init(axis: Axis, showDividers: Bool = false, @ViewBuilder content: () -> Content) {
1516
self.axis = axis
17+
self.showDividers = showDividers
1618
self.content = content()
1719
}
1820

@@ -21,7 +23,7 @@ struct SplitView<Content: View>: View {
2123
var body: some View {
2224
VStack {
2325
content.variadic { children in
24-
SplitViewControllerView(axis: axis, children: children, viewController: $viewController)
26+
SplitViewControllerView(axis: axis, children: children, showDividers: showDividers, viewController: $viewController)
2527
}
2628
}
2729
._trait(SplitViewControllerLayoutValueKey.self, viewController)

CodeEdit/Features/SplitView/Views/SplitViewControllerView.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct SplitViewControllerView: NSViewControllerRepresentable {
1111

1212
var axis: Axis
1313
var children: _VariadicView.Children
14+
var showDividers: Bool
1415
@Binding var viewController: () -> SplitViewController?
1516

1617
func makeNSViewController(context: Context) -> SplitViewController {
@@ -61,7 +62,7 @@ struct SplitViewControllerView: NSViewControllerRepresentable {
6162
}
6263

6364
func makeCoordinator() -> SplitViewController {
64-
SplitViewController(parent: self, axis: axis)
65+
SplitViewController(parent: self, axis: axis, showDividers: showDividers)
6566
}
6667
}
6768

@@ -70,10 +71,12 @@ final class SplitViewController: NSSplitViewController {
7071
var items: [SplitViewItem] = []
7172
var axis: Axis
7273
var parentView: SplitViewControllerView
74+
var showDividers: Bool
7375

74-
init(parent: SplitViewControllerView, axis: Axis = .horizontal) {
76+
init(parent: SplitViewControllerView, axis: Axis = .horizontal, showDividers: Bool = true) {
7577
self.axis = axis
7678
self.parentView = parent
79+
self.showDividers = showDividers
7780
super.init(nibName: nil, bundle: nil)
7881
}
7982

@@ -95,6 +98,14 @@ final class SplitViewController: NSSplitViewController {
9598
false
9699
}
97100

101+
override func splitView(_ splitView: NSSplitView, effectiveRect proposedEffectiveRect: NSRect, forDrawnRect drawnRect: NSRect, ofDividerAt dividerIndex: Int) -> NSRect {
102+
if showDividers {
103+
super.splitView(splitView, effectiveRect: proposedEffectiveRect, forDrawnRect: drawnRect, ofDividerAt: dividerIndex)
104+
} else {
105+
.zero
106+
}
107+
}
108+
98109
func collapse(for id: AnyHashable, enabled: Bool) {
99110
items.first { $0.id == id }?.item.animator().isCollapsed = enabled
100111
}

CodeEdit/Features/StatusBar/Views/StatusBarView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ struct StatusBarView: View {
5959

6060
/// A drag gesture to resize the drawer beneath the status bar
6161
private var dragGesture: some Gesture {
62-
DragGesture(coordinateSpace: .global)
62+
return DragGesture.init(coordinateSpace: .global)
6363
.onChanged { value in
64-
proxy.setPosition(of: 0, position: value.location.y + Self.height / 2)
64+
// not sure why but -20 seems to give the smoothest performance
65+
proxy.setPosition(of: 0, position: value.location.y - 20 - Self.height)
66+
proxy.setPosition(of: 1, position: value.location.y - 20)
6567
}
6668
}
6769
}

CodeEdit/WorkspaceView.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct WorkspaceView: View {
3535
if workspace.workspaceFileManager != nil {
3636
VStack {
3737
SplitViewReader { proxy in
38-
SplitView(axis: .vertical) {
38+
SplitView(axis: .vertical, showDividers: false) {
3939
EditorLayoutView(
4040
layout: editorManager.isFocusingActiveEditor
4141
? editorManager.activeEditor.getEditorLayout() ?? editorManager.editorLayout
@@ -46,10 +46,9 @@ struct WorkspaceView: View {
4646
.collapsed($utilityAreaViewModel.isMaximized)
4747
.frame(minHeight: 170 + 29 + 29)
4848
.frame(maxWidth: .infinity, maxHeight: .infinity)
49-
.holdingPriority(.init(1))
50-
.safeAreaInset(edge: .bottom, spacing: 0) {
51-
StatusBarView(proxy: proxy)
52-
}
49+
50+
StatusBarView(proxy: proxy)
51+
5352
UtilityAreaView()
5453
.collapsable()
5554
.collapsed($utilityAreaViewModel.isCollapsed)

0 commit comments

Comments
 (0)