Skip to content

Commit fdf9fec

Browse files
committed
use drawDivider
1 parent 6b6c0cd commit fdf9fec

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

CodeEdit/WorkspaceView.swift

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ struct WorkspaceSplitView: NSViewControllerRepresentable {
143143
final class CustomSplitView: NSSplitView {
144144
override var dividerThickness: CGFloat { StatusBarView.height }
145145
override var dividerColor: NSColor { .clear }
146+
147+
private var statusBar = NSHostingView(rootView: StatusBarView())
148+
149+
override func drawDivider(in rect: NSRect) {
150+
addSubview(statusBar)
151+
statusBar.frame = rect
152+
statusBar.needsDisplay = true
153+
}
146154
}
147155

148156
final class WorkspaceViewController: NSSplitViewController {
@@ -156,20 +164,6 @@ struct WorkspaceSplitView: NSViewControllerRepresentable {
156164
fatalError("init(coder:) has not been implemented")
157165
}
158166

159-
override func viewDidLoad() {
160-
super.viewDidLoad()
161-
let dividerView = NSHostingView(rootView: StatusBarView())
162-
dividerView.translatesAutoresizingMaskIntoConstraints = false
163-
let constraints = [
164-
// dividerView.topAnchor.constraint(equalTo: splitView.subviews[0].bottomAnchor),
165-
dividerView.bottomAnchor.constraint(equalTo: splitView.subviews[1].topAnchor),
166-
dividerView.leadingAnchor.constraint(equalTo: splitView.leadingAnchor),
167-
dividerView.trailingAnchor.constraint(equalTo: splitView.trailingAnchor)
168-
]
169-
splitView.addSubview(dividerView)
170-
NSLayoutConstraint.activate(constraints)
171-
}
172-
173167
func addPane(_ pane: some View) {
174168
let viewController = NSHostingController(rootView: pane)
175169
let splitViewItem = NSSplitViewItem(viewController: viewController)

0 commit comments

Comments
 (0)