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,52 +517,41 @@
<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> <subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="cJ9-6s-66u" customClass="DetailContainerView" customModule="NetNewsWire" customModuleProvider="target"> <customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xI5-lx-RD8" customClass="DetailStatusBarView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/> <rect key="frame" x="6" y="2" width="12" height="20"/>
<subviews> <subviews>
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xI5-lx-RD8" customClass="DetailStatusBarView" customModule="NetNewsWire" customModuleProvider="target"> <textField horizontalHuggingPriority="850" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Dim-ed-Dcz" userLabel="URL Label">
<rect key="frame" x="6" y="2" width="12" height="20"/> <rect key="frame" x="4" y="2" width="4" height="17"/>
<subviews> <textFieldCell key="cell" lineBreakMode="truncatingMiddle" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" usesSingleLineMode="YES" id="znU-Fh-L7H">
<textField horizontalHuggingPriority="850" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Dim-ed-Dcz" userLabel="URL Label"> <font key="font" metaFont="system"/>
<rect key="frame" x="4" y="2" width="4" height="17"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" usesSingleLineMode="YES" id="znU-Fh-L7H"> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<font key="font" metaFont="system"/> </textFieldCell>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> </textField>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="Dim-ed-Dcz" firstAttribute="centerY" secondItem="xI5-lx-RD8" secondAttribute="centerY" id="Hna-uB-3F7"/>
<constraint firstAttribute="trailing" secondItem="Dim-ed-Dcz" secondAttribute="trailing" constant="6" id="O5q-ZN-DjZ"/>
<constraint firstAttribute="height" constant="20" id="Sfk-Ri-WoD"/>
<constraint firstItem="Dim-ed-Dcz" firstAttribute="leading" secondItem="xI5-lx-RD8" secondAttribute="leading" constant="6" id="Y9c-WR-ZBY"/>
</constraints>
<connections>
<outlet property="urlLabel" destination="Dim-ed-Dcz" id="8fY-oo-cGT"/>
</connections>
</customView>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="xI5-lx-RD8" firstAttribute="leading" secondItem="cJ9-6s-66u" secondAttribute="leading" constant="6" id="5vz-ys-CAo"/> <constraint firstItem="Dim-ed-Dcz" firstAttribute="centerY" secondItem="xI5-lx-RD8" secondAttribute="centerY" id="Hna-uB-3F7"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="xI5-lx-RD8" secondAttribute="trailing" constant="6" id="pbD-LN-Gk1"/> <constraint firstAttribute="trailing" secondItem="Dim-ed-Dcz" secondAttribute="trailing" constant="6" id="O5q-ZN-DjZ"/>
<constraint firstAttribute="bottom" secondItem="xI5-lx-RD8" secondAttribute="bottom" constant="2" id="zsv-B0-ChW"/> <constraint firstAttribute="height" constant="20" id="Sfk-Ri-WoD"/>
<constraint firstItem="Dim-ed-Dcz" firstAttribute="leading" secondItem="xI5-lx-RD8" secondAttribute="leading" constant="6" id="Y9c-WR-ZBY"/>
</constraints> </constraints>
<connections> <connections>
<outlet property="detailStatusBarView" destination="xI5-lx-RD8" id="yIZ-aP-fKF"/> <outlet property="urlLabel" destination="Dim-ed-Dcz" id="8fY-oo-cGT"/>
</connections> </connections>
</customView> </customView>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="cJ9-6s-66u" firstAttribute="leading" secondItem="37A-bp-izR" secondAttribute="leading" id="AM2-YB-J0B"/> <constraint firstItem="xI5-lx-RD8" firstAttribute="leading" secondItem="cJ9-6s-66u" secondAttribute="leading" constant="6" id="5vz-ys-CAo"/>
<constraint firstItem="cJ9-6s-66u" firstAttribute="top" secondItem="37A-bp-izR" secondAttribute="top" id="DXp-ju-WpM"/> <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="xI5-lx-RD8" secondAttribute="trailing" constant="6" id="pbD-LN-Gk1"/>
<constraint firstAttribute="trailing" secondItem="cJ9-6s-66u" secondAttribute="trailing" id="hUh-Uk-62r"/> <constraint firstAttribute="bottom" secondItem="xI5-lx-RD8" secondAttribute="bottom" constant="2" id="zsv-B0-ChW"/>
<constraint firstAttribute="bottom" secondItem="cJ9-6s-66u" secondAttribute="bottom" id="wzr-Ci-6A8"/>
</constraints> </constraints>
<connections>
<outlet property="detailStatusBarView" destination="xI5-lx-RD8" id="yIZ-aP-fKF"/>
</connections>
</customView> </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"/>

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: -