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"> <scene sceneID="HMt-bN-oMN">
<objects> <objects>
<viewController id="Vho-7i-T8m" userLabel="Detail View Controller" customClass="DetailViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController"> <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"/> <rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <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> <subviews>
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xI5-lx-RD8" customClass="DetailStatusBarView" customModule="NetNewsWire" customModuleProvider="target"> <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"/> <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"/> <outlet property="detailStatusBarView" destination="xI5-lx-RD8" id="yIZ-aP-fKF"/>
</connections> </connections>
</customView> </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> <connections>
<outlet property="containerView" destination="cJ9-6s-66u" id="gXc-Pz-9sQ"/> <outlet property="containerView" destination="cJ9-6s-66u" id="gXc-Pz-9sQ"/>
</connections> </connections>

View File

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