Fix #2833: Titlebar is overlapped by toolbar in fullscreen

Fix issue where detail web view would be overlapped by the toolbar in full screen by setting web view constraints to use the `safeAreaLayoutGuide` in macOS 11+.
This commit is contained in:
Collin Donnell 2021-02-27 16:32:57 -08:00 committed by Maurice Parker
parent 74298e7cde
commit 035759947a

View File

@ -98,14 +98,25 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
box.addSubview(webView) box.addSubview(webView)
// Use the safe area layout guides if they are available.
if #available(OSX 11.0, *) {
let constraints = [
webView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
webView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
webView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
webView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
]
NSLayoutConstraint.activate(constraints)
} else {
let constraints = [ let constraints = [
webView.topAnchor.constraint(equalTo: view.topAnchor), webView.topAnchor.constraint(equalTo: view.topAnchor),
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor), webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor), webView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
] ]
NSLayoutConstraint.activate(constraints) NSLayoutConstraint.activate(constraints)
}
// Hide the web view until the first reload (navigation) is complete (plus some delay) to avoid the awful white flash that happens on the initial display in dark mode. // Hide the web view until the first reload (navigation) is complete (plus some delay) to avoid the awful white flash that happens on the initial display in dark mode.
// See bug #901. // See bug #901.