Create and use a plain-background NoSelectionView to display in the detail pane when there’s no current article. Fix #237.
This commit is contained in:
parent
05b158e92f
commit
bef77bc4a1
|
@ -12,10 +12,10 @@ import RSCore
|
|||
import Data
|
||||
import RSWeb
|
||||
|
||||
class DetailViewController: NSViewController, WKNavigationDelegate, WKUIDelegate {
|
||||
final class DetailViewController: NSViewController, WKNavigationDelegate, WKUIDelegate {
|
||||
|
||||
var webview: WKWebView!
|
||||
var visualEffectView: NSVisualEffectView!
|
||||
var noSelectionView: NoSelectionView!
|
||||
|
||||
var article: Article? {
|
||||
didSet {
|
||||
|
@ -56,9 +56,7 @@ class DetailViewController: NSViewController, WKNavigationDelegate, WKUIDelegate
|
|||
webview.customUserAgent = userAgent
|
||||
}
|
||||
|
||||
visualEffectView = NSVisualEffectView(frame: self.view.bounds)
|
||||
visualEffectView.material = .appearanceBased
|
||||
visualEffectView.blendingMode = .behindWindow
|
||||
noSelectionView = NoSelectionView(frame: self.view.bounds)
|
||||
|
||||
let boxView = self.view as! DetailBox
|
||||
boxView.viewController = self
|
||||
|
@ -105,7 +103,7 @@ class DetailViewController: NSViewController, WKNavigationDelegate, WKUIDelegate
|
|||
switchToView(webview)
|
||||
}
|
||||
else {
|
||||
switchToView(visualEffectView)
|
||||
switchToView(noSelectionView)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +170,7 @@ extension DetailViewController: WKScriptMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
class DetailBox: NSBox {
|
||||
final class DetailBox: NSBox {
|
||||
|
||||
weak var viewController: DetailViewController?
|
||||
|
||||
|
@ -186,3 +184,25 @@ class DetailBox: NSBox {
|
|||
viewController?.viewDidEndLiveResize()
|
||||
}
|
||||
}
|
||||
|
||||
final class NoSelectionView: NSView {
|
||||
|
||||
private var didConfigureLayer = false
|
||||
|
||||
override var wantsUpdateLayer: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
override func updateLayer() {
|
||||
|
||||
guard !didConfigureLayer else {
|
||||
return
|
||||
}
|
||||
if let layer = layer {
|
||||
let color = appDelegate.currentTheme.color(forKey: "MainWindow.Detail.noSelectionView.backgroundColor")
|
||||
layer.backgroundColor = color.cgColor
|
||||
didConfigureLayer = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,14 @@
|
|||
<integer>4</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Detail</key>
|
||||
<dict>
|
||||
<key>noSelectionView</key>
|
||||
<dict>
|
||||
<key>backgroundColor</key>
|
||||
<string>FFFFFF</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
|
Loading…
Reference in New Issue