mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-24 16:51:19 +01:00
Show a visual effect view, with behind-window-blending, when there is no selected Article. Fix #214.
After I check this in I’m going to reverse it, because it’s just too obtrusive. But this way there’s a record of having tried it, plus code.
This commit is contained in:
parent
4e05f35f6d
commit
05b158e92f
@ -15,10 +15,12 @@ import RSWeb
|
||||
class DetailViewController: NSViewController, WKNavigationDelegate, WKUIDelegate {
|
||||
|
||||
var webview: WKWebView!
|
||||
|
||||
var visualEffectView: NSVisualEffectView!
|
||||
|
||||
var article: Article? {
|
||||
didSet {
|
||||
reloadHTML()
|
||||
showOrHideWebView()
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,11 +56,14 @@ class DetailViewController: NSViewController, WKNavigationDelegate, WKUIDelegate
|
||||
webview.customUserAgent = userAgent
|
||||
}
|
||||
|
||||
visualEffectView = NSVisualEffectView(frame: self.view.bounds)
|
||||
visualEffectView.material = .appearanceBased
|
||||
visualEffectView.blendingMode = .behindWindow
|
||||
|
||||
let boxView = self.view as! DetailBox
|
||||
boxView.contentView = webview
|
||||
boxView.rs_addFullSizeConstraints(forSubview: webview)
|
||||
|
||||
boxView.viewController = self
|
||||
|
||||
showOrHideWebView()
|
||||
}
|
||||
|
||||
// MARK: Notifications
|
||||
@ -93,7 +98,27 @@ class DetailViewController: NSViewController, WKNavigationDelegate, WKUIDelegate
|
||||
webview.loadHTMLString("", baseURL: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func showOrHideWebView() {
|
||||
|
||||
if let _ = article {
|
||||
switchToView(webview)
|
||||
}
|
||||
else {
|
||||
switchToView(visualEffectView)
|
||||
}
|
||||
}
|
||||
|
||||
private func switchToView(_ view: NSView) {
|
||||
|
||||
let boxView = self.view as! DetailBox
|
||||
if boxView.contentView == view {
|
||||
return
|
||||
}
|
||||
boxView.contentView = view
|
||||
boxView.rs_addFullSizeConstraints(forSubview: view)
|
||||
}
|
||||
|
||||
// MARK: WKNavigationDelegate
|
||||
|
||||
public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||
|
Loading…
Reference in New Issue
Block a user