Simplify the view hierarchy for the detail view — remove one unneeded view.

This commit is contained in:
Brent Simmons 2019-02-10 20:51:28 -08:00
parent c23bdc74cb
commit a74e0762e7
2 changed files with 26 additions and 40 deletions

View File

@ -517,12 +517,9 @@
<scene sceneID="HMt-bN-oMN">
<objects>
<viewController id="Vho-7i-T8m" userLabel="Detail View Controller" customClass="DetailViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<customView key="view" id="37A-bp-izR">
<customView key="view" id="cJ9-6s-66u" customClass="DetailContainerView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="cJ9-6s-66u" customClass="DetailContainerView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<subviews>
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xI5-lx-RD8" customClass="DetailStatusBarView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="6" y="2" width="12" height="20"/>
@ -556,14 +553,6 @@
<outlet property="detailStatusBarView" destination="xI5-lx-RD8" id="yIZ-aP-fKF"/>
</connections>
</customView>
</subviews>
<constraints>
<constraint firstItem="cJ9-6s-66u" firstAttribute="leading" secondItem="37A-bp-izR" secondAttribute="leading" id="AM2-YB-J0B"/>
<constraint firstItem="cJ9-6s-66u" firstAttribute="top" secondItem="37A-bp-izR" secondAttribute="top" id="DXp-ju-WpM"/>
<constraint firstAttribute="trailing" secondItem="cJ9-6s-66u" secondAttribute="trailing" id="hUh-Uk-62r"/>
<constraint firstAttribute="bottom" secondItem="cJ9-6s-66u" secondAttribute="bottom" id="wzr-Ci-6A8"/>
</constraints>
</customView>
<connections>
<outlet property="containerView" destination="cJ9-6s-66u" id="gXc-Pz-9sQ"/>
</connections>

View File

@ -225,7 +225,7 @@ private extension DetailViewController {
}
}
// MARK: -
// MARK: - DetailContainerView
final class DetailContainerView: NSView {
@ -235,9 +235,10 @@ final class DetailContainerView: NSView {
var contentView: NSView? {
didSet {
if let oldContentView = oldValue {
oldContentView.removeFromSuperviewWithoutNeedingDisplay()
if contentView == oldValue {
return
}
oldValue?.removeFromSuperviewWithoutNeedingDisplay()
if let contentView = contentView {
contentView.translatesAutoresizingMaskIntoConstraints = false
addSubview(contentView, positioned: .below, relativeTo: detailStatusBarView)
@ -247,12 +248,10 @@ final class DetailContainerView: NSView {
}
override func viewWillStartLiveResize() {
viewController?.viewWillStartLiveResize()
}
override func viewDidEndLiveResize() {
viewController?.viewDidEndLiveResize()
}
@ -260,8 +259,6 @@ final class DetailContainerView: NSView {
NSColor.textBackgroundColor.setFill()
dirtyRect.fill()
}
}
// MARK: -