Remove the gear menu from the bottom of the sidebar. Animate in and out the refresh-status view (a la Mail).

This commit is contained in:
Brent Simmons 2019-02-01 20:53:02 -08:00
parent 21a5a00cd1
commit 51ef880d4f
2 changed files with 32 additions and 27 deletions

View File

@ -355,19 +355,19 @@
</scroller> </scroller>
</scrollView> </scrollView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="HZs-Zf-G8s" customClass="SidebarStatusBarView" customModule="NetNewsWire" customModuleProvider="target"> <customView translatesAutoresizingMaskIntoConstraints="NO" id="HZs-Zf-G8s" customClass="SidebarStatusBarView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="166" height="0.0"/> <rect key="frame" x="0.0" y="-28" width="166" height="28"/>
<subviews> <subviews>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="agw-l1-HkL"> <box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="agw-l1-HkL">
<rect key="frame" x="0.0" y="-3" width="166" height="5"/> <rect key="frame" x="0.0" y="25" width="166" height="5"/>
</box> </box>
<progressIndicator hidden="YES" wantsLayer="YES" maxValue="100" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="y9c-Xf-2fS"> <progressIndicator hidden="YES" wantsLayer="YES" maxValue="100" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="y9c-Xf-2fS">
<rect key="frame" x="20" y="-11" width="40" height="20"/> <rect key="frame" x="20" y="3" width="40" height="20"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="40" id="1Yw-ER-8pT"/> <constraint firstAttribute="width" constant="40" id="1Yw-ER-8pT"/>
</constraints> </constraints>
</progressIndicator> </progressIndicator>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iyL-pW-cT6"> <textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iyL-pW-cT6">
<rect key="frame" x="62" y="-8" width="86" height="17"/> <rect key="frame" x="62" y="6" width="86" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="dVE-XG-mlU"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="dVE-XG-mlU">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
@ -383,10 +383,11 @@
<constraint firstItem="iyL-pW-cT6" firstAttribute="leading" secondItem="y9c-Xf-2fS" secondAttribute="trailing" constant="4" id="TAM-VN-Syu"/> <constraint firstItem="iyL-pW-cT6" firstAttribute="leading" secondItem="y9c-Xf-2fS" secondAttribute="trailing" constant="4" id="TAM-VN-Syu"/>
<constraint firstItem="y9c-Xf-2fS" firstAttribute="leading" secondItem="HZs-Zf-G8s" secondAttribute="leading" constant="20" symbolic="YES" id="TV9-iE-nuE"/> <constraint firstItem="y9c-Xf-2fS" firstAttribute="leading" secondItem="HZs-Zf-G8s" secondAttribute="leading" constant="20" symbolic="YES" id="TV9-iE-nuE"/>
<constraint firstItem="agw-l1-HkL" firstAttribute="top" secondItem="HZs-Zf-G8s" secondAttribute="top" id="rBv-S6-j3b"/> <constraint firstItem="agw-l1-HkL" firstAttribute="top" secondItem="HZs-Zf-G8s" secondAttribute="top" id="rBv-S6-j3b"/>
<constraint firstAttribute="height" id="xOq-XX-qcd"/> <constraint firstAttribute="height" constant="28" id="xOq-XX-qcd"/>
</constraints> </constraints>
<connections> <connections>
<outlet property="heightConstraint" destination="xOq-XX-qcd" id="wOf-xs-dFM"/> <outlet property="bottomConstraint" destination="UN9-Wa-uxb" id="SYv-ax-8md"/>
<outlet property="heightConstraint" destination="xOq-XX-qcd" id="ktU-yd-g8x"/>
<outlet property="progressIndicator" destination="y9c-Xf-2fS" id="gaf-6e-siu"/> <outlet property="progressIndicator" destination="y9c-Xf-2fS" id="gaf-6e-siu"/>
<outlet property="progressLabel" destination="iyL-pW-cT6" id="Zpv-44-cfX"/> <outlet property="progressLabel" destination="iyL-pW-cT6" id="Zpv-44-cfX"/>
</connections> </connections>
@ -396,7 +397,7 @@
<constraint firstItem="HZs-Zf-G8s" firstAttribute="top" secondItem="cJj-Wv-9ep" secondAttribute="bottom" id="0Zg-oW-o7U"/> <constraint firstItem="HZs-Zf-G8s" firstAttribute="top" secondItem="cJj-Wv-9ep" secondAttribute="bottom" id="0Zg-oW-o7U"/>
<constraint firstItem="cJj-Wv-9ep" firstAttribute="leading" secondItem="bJZ-bH-vgc" secondAttribute="leading" id="5Rs-9M-TKq"/> <constraint firstItem="cJj-Wv-9ep" firstAttribute="leading" secondItem="bJZ-bH-vgc" secondAttribute="leading" id="5Rs-9M-TKq"/>
<constraint firstAttribute="trailing" secondItem="iyL-pW-cT6" secondAttribute="trailing" constant="20" id="Mnm-9S-Qpm"/> <constraint firstAttribute="trailing" secondItem="iyL-pW-cT6" secondAttribute="trailing" constant="20" id="Mnm-9S-Qpm"/>
<constraint firstAttribute="bottom" secondItem="HZs-Zf-G8s" secondAttribute="bottom" id="UN9-Wa-uxb"/> <constraint firstAttribute="bottom" secondItem="HZs-Zf-G8s" secondAttribute="bottom" constant="-28" id="UN9-Wa-uxb"/>
<constraint firstAttribute="trailing" secondItem="HZs-Zf-G8s" secondAttribute="trailing" id="iNE-nb-QEB"/> <constraint firstAttribute="trailing" secondItem="HZs-Zf-G8s" secondAttribute="trailing" id="iNE-nb-QEB"/>
<constraint firstItem="HZs-Zf-G8s" firstAttribute="leading" secondItem="bJZ-bH-vgc" secondAttribute="leading" id="tPp-xB-CgB"/> <constraint firstItem="HZs-Zf-G8s" firstAttribute="leading" secondItem="bJZ-bH-vgc" secondAttribute="leading" id="tPp-xB-CgB"/>
<constraint firstItem="cJj-Wv-9ep" firstAttribute="top" secondItem="bJZ-bH-vgc" secondAttribute="top" id="vAT-Wo-8fl"/> <constraint firstItem="cJj-Wv-9ep" firstAttribute="top" secondItem="bJZ-bH-vgc" secondAttribute="top" id="vAT-Wo-8fl"/>

View File

@ -16,14 +16,10 @@ final class SidebarStatusBarView: NSView {
@IBOutlet var progressIndicator: NSProgressIndicator! @IBOutlet var progressIndicator: NSProgressIndicator!
@IBOutlet var progressLabel: NSTextField! @IBOutlet var progressLabel: NSTextField!
@IBOutlet var bottomConstraint: NSLayoutConstraint!
@IBOutlet var heightConstraint: NSLayoutConstraint! @IBOutlet var heightConstraint: NSLayoutConstraint!
private var isAnimatingProgress = false { private var isAnimatingProgress = false
didSet {
progressIndicator.isHidden = !isAnimatingProgress
progressLabel.isHidden = !isAnimatingProgress
}
}
private var progress: CombinedRefreshProgress? = nil { private var progress: CombinedRefreshProgress? = nil {
didSet { didSet {
@ -69,24 +65,25 @@ private extension SidebarStatusBarView {
// MARK: Progress // MARK: Progress
static let animationDuration = 0.2
func stopProgressIfNeeded() { func stopProgressIfNeeded() {
if !isAnimatingProgress { if !isAnimatingProgress {
return return
} }
isAnimatingProgress = false isAnimatingProgress = false
// progressIndicator.needsDisplay = true self.progressIndicator.stopAnimation(self)
progressIndicator.isHidden = true
progressLabel.isHidden = true
superview?.layoutSubtreeIfNeeded() superview?.layoutSubtreeIfNeeded()
NSAnimationContext.runAnimationGroup({ (context) in NSAnimationContext.runAnimationGroup{ (context) in
context.duration = 0.2 context.duration = SidebarStatusBarView.animationDuration
context.allowsImplicitAnimation = true context.allowsImplicitAnimation = true
heightConstraint.constant = 0 bottomConstraint.constant = -(heightConstraint.constant)
superview?.layoutSubtreeIfNeeded() superview?.layoutSubtreeIfNeeded()
}) {
progressIndicator.stopAnimation(self)
} }
} }
@ -96,8 +93,18 @@ private extension SidebarStatusBarView {
return return
} }
isAnimatingProgress = true isAnimatingProgress = true
progressIndicator.isHidden = false
progressLabel.isHidden = false
progressIndicator.startAnimation(self) progressIndicator.startAnimation(self)
heightConstraint.constant = 28
superview?.layoutSubtreeIfNeeded()
NSAnimationContext.runAnimationGroup{ (context) in
context.duration = SidebarStatusBarView.animationDuration
context.allowsImplicitAnimation = true
bottomConstraint.constant = 0
superview?.layoutSubtreeIfNeeded()
}
} }
func updateProgressIndicator(_ progress: CombinedRefreshProgress) { func updateProgressIndicator(_ progress: CombinedRefreshProgress) {
@ -127,11 +134,8 @@ private extension SidebarStatusBarView {
return return
} }
let numberOfTasks = progress.numberOfTasks
let numberCompleted = progress.numberCompleted
let formatString = NSLocalizedString("%@ of %@", comment: "Status bar progress") let formatString = NSLocalizedString("%@ of %@", comment: "Status bar progress")
let s = NSString(format: formatString as NSString, NSNumber(value: numberCompleted), NSNumber(value: numberOfTasks)) let s = NSString(format: formatString as NSString, NSNumber(value: progress.numberCompleted), NSNumber(value: progress.numberOfTasks))
progressLabel.stringValue = s as String progressLabel.stringValue = s as String
} }