I can't manage to get a NSToolbarItem placed in the sidebar. And I can't use NSToolbarItem.Identifier.sidebarSeperator as stated in the WWDC video because it isn't there.
toolbarItem = NSTrackingSeparatorToolbarItem(identifier: .sidebarTrackingSeparatorItemIdentifier, splitView: splitVC.splitView, dividerIndex: 0)
I'm trying to use sidebarTrackingSeparatorItemIdentifier as well. No lucks w/o the other.
Post
Replies
Boosts
Views
Activity
Hello! I'm having a rough time getting the layout of LazyVGrid to work properly when using NSApplicationDelegateAdaptor. My SwiftUI ContentView is introduced through the AppDelegate with an NSWindow and it seems that SwiftUI does not initially recognize the titlebar, tabview, toolbar items. It does after scrolling. I've tried working around it with removing the safe zone and adding a buffer to both sides, having the height computed but bugs arise visually here and performance seems to drop. Any fixes possible? I recognize this is in beta still.
Heres some of the attempt, it does function to an extent
class TitlebarCoordinator: ObservableObject {
@Published var height: CGFloat
init(initial: CGFloat) {
height = initial
}
}
var titlebarCoordinator = TitlebarCoordinator(initial: 54)
extension NSWindow {
var titlebarHeight: CGFloat {
let titleHeight: CGFloat = frame.height - contentLayoutRect.height
let tabHeight: CGFloat = 30
guard self.tabbedWindows?.count ?? 0 > 1 else {
return titleHeight
}
return titleHeight + 0
}
}
extension AppWindow: NSWindowDelegate, NSTabViewDelegate {
func windowDidResize(_ notification: Notification) {
print("window resized")
titlebarCoordinator.height = titlebarHeight
}
func windowWillClose(_ notification: Notification) {
windowDidResize(Notification(name: Notification.Name(rawValue: "didResize")))
}
}
Padding and offset then have to be set to titlebarCoordinator.height for the view
Another near solution is to flip the view twice and scroll to the bottom but the alignment is off