Remove unneeded whitespaces

This commit is contained in:
Michele Volpato 2020-03-02 22:33:59 +01:00
parent 115405f1f0
commit ee0f982e93
1 changed files with 16 additions and 16 deletions

View File

@ -17,52 +17,52 @@ class RefreshProgressView: UIView {
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)
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange(_:)), name: UIContentSizeCategory.didChangeNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange(_:)), name: UIContentSizeCategory.didChangeNotification, object: nil)
if !AccountManager.shared.combinedRefreshProgress.isComplete { if !AccountManager.shared.combinedRefreshProgress.isComplete {
progressChanged() progressChanged()
} else { } else {
updateRefreshLabel() updateRefreshLabel()
} }
scheduleUpdateRefreshLabel() scheduleUpdateRefreshLabel()
} }
override func didMoveToSuperview() { override func didMoveToSuperview() {
progressChanged() progressChanged()
} }
func updateRefreshLabel() { func updateRefreshLabel() {
if let accountLastArticleFetchEndTime = AccountManager.shared.lastArticleFetchEndTime { if let accountLastArticleFetchEndTime = AccountManager.shared.lastArticleFetchEndTime {
if Date() > accountLastArticleFetchEndTime.addingTimeInterval(60) { if Date() > accountLastArticleFetchEndTime.addingTimeInterval(60) {
let relativeDateTimeFormatter = RelativeDateTimeFormatter() let relativeDateTimeFormatter = RelativeDateTimeFormatter()
relativeDateTimeFormatter.dateTimeStyle = .named relativeDateTimeFormatter.dateTimeStyle = .named
let refreshed = relativeDateTimeFormatter.localizedString(for: accountLastArticleFetchEndTime, relativeTo: Date()) let refreshed = relativeDateTimeFormatter.localizedString(for: accountLastArticleFetchEndTime, relativeTo: Date())
let localizedRefreshText = NSLocalizedString("Updated %@", comment: "Updated") let localizedRefreshText = NSLocalizedString("Updated %@", comment: "Updated")
let refreshText = NSString.localizedStringWithFormat(localizedRefreshText as NSString, refreshed) as String let refreshText = NSString.localizedStringWithFormat(localizedRefreshText as NSString, refreshed) as String
label.text = refreshText label.text = refreshText
} else { } else {
label.text = NSLocalizedString("Updated Just Now", comment: "Updated Just Now") label.text = NSLocalizedString("Updated Just Now", comment: "Updated Just Now")
} }
} else { } else {
label.text = "" label.text = ""
} }
} }
@objc func progressDidChange(_ note: Notification) { @objc func progressDidChange(_ note: Notification) {
progressChanged() progressChanged()
} }
@objc func contentSizeCategoryDidChange(_ note: Notification) { @objc func contentSizeCategoryDidChange(_ note: Notification) {
// This hack is probably necessary because custom views in the toolbar don't get // This hack is probably necessary because custom views in the toolbar don't get
// notifications that the content size changed. // notifications that the content size changed.
label.font = UIFont.preferredFont(forTextStyle: .footnote) label.font = UIFont.preferredFont(forTextStyle: .footnote)
} }
deinit { deinit {
NotificationCenter.default.removeObserver(self) NotificationCenter.default.removeObserver(self)
} }
@ -72,14 +72,14 @@ class RefreshProgressView: UIView {
// MARK: Private // MARK: Private
private extension RefreshProgressView { private extension RefreshProgressView {
func progressChanged() { func progressChanged() {
// Layout may crash if not in the view hierarchy. // Layout may crash if not in the view hierarchy.
// https://github.com/Ranchero-Software/NetNewsWire/issues/1764 // https://github.com/Ranchero-Software/NetNewsWire/issues/1764
let isInViewHierarchy = self.superview != nil let isInViewHierarchy = self.superview != nil
let progress = AccountManager.shared.combinedRefreshProgress let progress = AccountManager.shared.combinedRefreshProgress
if progress.isComplete { if progress.isComplete {
if isInViewHierarchy { if isInViewHierarchy {
progressView.setProgress(1, animated: true) progressView.setProgress(1, animated: true)
@ -100,7 +100,7 @@ private extension RefreshProgressView {
progressView.isHidden = false progressView.isHidden = false
if isInViewHierarchy { if isInViewHierarchy {
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%
if percent > progressView.progress || progressView.progress - percent > 0.25 { if percent > progressView.progress || progressView.progress - percent > 0.25 {
progressView.setProgress(percent, animated: true) progressView.setProgress(percent, animated: true)