Fix progress bar width, add contraints to progress label
This commit is contained in:
parent
3a0f57e4da
commit
115405f1f0
|
@ -13,7 +13,6 @@ class RefreshProgressView: UIView {
|
||||||
|
|
||||||
@IBOutlet weak var progressView: UIProgressView!
|
@IBOutlet weak var progressView: UIProgressView!
|
||||||
@IBOutlet weak var label: UILabel!
|
@IBOutlet weak var label: UILabel!
|
||||||
private lazy var progressWidthConstraint = progressView.widthAnchor.constraint(equalToConstant: 100.0)
|
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
|
||||||
|
@ -86,21 +85,20 @@ private extension RefreshProgressView {
|
||||||
progressView.setProgress(1, animated: true)
|
progressView.setProgress(1, animated: true)
|
||||||
}
|
}
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||||
|
// Check that there are no pending downloads.
|
||||||
|
if (AccountManager.shared.combinedRefreshProgress.isComplete) {
|
||||||
self.updateRefreshLabel()
|
self.updateRefreshLabel()
|
||||||
self.label.isHidden = false
|
self.label.isHidden = false
|
||||||
self.progressView.isHidden = true
|
self.progressView.isHidden = true
|
||||||
self.progressWidthConstraint.isActive = false
|
if self.superview != nil {
|
||||||
if isInViewHierarchy {
|
|
||||||
self.progressView.setProgress(0, animated: true)
|
self.progressView.setProgress(0, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
label.isHidden = true
|
label.isHidden = true
|
||||||
progressView.isHidden = false
|
progressView.isHidden = false
|
||||||
progressWidthConstraint.isActive = true
|
|
||||||
if isInViewHierarchy {
|
if isInViewHierarchy {
|
||||||
progressView.setNeedsLayout()
|
|
||||||
progressView.layoutIfNeeded()
|
|
||||||
let percent = Float(progress.numberCompleted) / Float(progress.numberOfTasks)
|
let percent = Float(progress.numberCompleted) / Float(progress.numberOfTasks)
|
||||||
|
|
||||||
// Don't let the progress bar go backwards unless we need to go back more than 25%
|
// Don't let the progress bar go backwards unless we need to go back more than 25%
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
|
||||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -14,13 +14,14 @@
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="gKH-fc-zh7" customClass="RoundedProgressView" customModule="NetNewsWire" customModuleProvider="target">
|
<progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="gKH-fc-zh7" customClass="RoundedProgressView" customModule="NetNewsWire" customModuleProvider="target">
|
||||||
<rect key="frame" x="0.0" y="27.5" width="375" height="5"/>
|
<rect key="frame" x="137.5" y="27.5" width="100" height="5"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="height" constant="5" id="OCl-qi-owb"/>
|
<constraint firstAttribute="height" constant="5" id="OCl-qi-owb"/>
|
||||||
|
<constraint firstAttribute="width" constant="100" id="v3Q-GE-krS"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</progressView>
|
</progressView>
|
||||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="07B-Zy-FCt">
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="07B-Zy-FCt">
|
||||||
<rect key="frame" x="0.0" y="30" width="375" height="0.0"/>
|
<rect key="frame" x="187.5" y="30" width="0.0" height="0.0"/>
|
||||||
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
|
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
|
||||||
<color key="textColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
<color key="textColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
|
@ -28,11 +29,13 @@
|
||||||
</subviews>
|
</subviews>
|
||||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="07B-Zy-FCt" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="6eL-GN-NIE"/>
|
<constraint firstItem="07B-Zy-FCt" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="01K-1E-PEm"/>
|
||||||
|
<constraint firstItem="07B-Zy-FCt" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="vUN-kp-3ea" secondAttribute="leading" id="6eL-GN-NIE"/>
|
||||||
<constraint firstItem="07B-Zy-FCt" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="QJ0-os-kZt"/>
|
<constraint firstItem="07B-Zy-FCt" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="QJ0-os-kZt"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="gKH-fc-zh7" secondAttribute="trailing" id="SbS-0T-bdo"/>
|
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="gKH-fc-zh7" secondAttribute="trailing" id="SbS-0T-bdo"/>
|
||||||
<constraint firstItem="gKH-fc-zh7" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="V0P-ix-fa3"/>
|
<constraint firstItem="gKH-fc-zh7" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="iN0-l3-epB" secondAttribute="leading" id="V0P-ix-fa3"/>
|
||||||
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="07B-Zy-FCt" secondAttribute="trailing" id="Zor-53-U98"/>
|
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="07B-Zy-FCt" secondAttribute="trailing" id="Zor-53-U98"/>
|
||||||
|
<constraint firstItem="gKH-fc-zh7" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="eX0-hg-5sb"/>
|
||||||
<constraint firstItem="gKH-fc-zh7" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="mnf-7m-knt"/>
|
<constraint firstItem="gKH-fc-zh7" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="mnf-7m-knt"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<nil key="simulatedTopBarMetrics"/>
|
<nil key="simulatedTopBarMetrics"/>
|
||||||
|
|
Loading…
Reference in New Issue