From 5a7863d4470c7ac00f3ec611627b62e5fc91f0a1 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 3 Jan 2020 08:42:43 -0700 Subject: [PATCH] Rollback pull to refresh on the timeline and modified pull to refresh control. Issue #1520 --- NetNewsWire.xcodeproj/project.pbxproj | 4 -- iOS/MasterFeed/MasterFeedViewController.swift | 24 ++------- .../MasterTimelineViewController.swift | 2 - .../AccountRefreshControl.swift | 51 ------------------- 4 files changed, 4 insertions(+), 77 deletions(-) delete mode 100644 iOS/UIKit Extensions/AccountRefreshControl.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 9187130d1..dcacef335 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -227,7 +227,6 @@ 51CE1C0B23622007005548FC /* RefreshProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51CE1C0A23622006005548FC /* RefreshProgressView.swift */; }; 51CE1C712367721A005548FC /* testURLsOfCurrentArticle.applescript in Sources */ = {isa = PBXBuildFile; fileRef = 84F9EADB213660A100CF2DE4 /* testURLsOfCurrentArticle.applescript */; }; 51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84702AA31FA27AC0006B8943 /* MarkStatusCommand.swift */; }; - 51D637C223BEEF8300A3BBCD /* AccountRefreshControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D637C123BEEF8300A3BBCD /* AccountRefreshControl.swift */; }; 51D6A5BC23199C85001C27D8 /* MasterTimelineDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6A5BB23199C85001C27D8 /* MasterTimelineDataSource.swift */; }; 51D87EE12311D34700E63F03 /* ActivityType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D87EE02311D34700E63F03 /* ActivityType.swift */; }; 51E36E71239D6610006F47A5 /* AddWebFeedSelectFolderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E36E70239D6610006F47A5 /* AddWebFeedSelectFolderTableViewCell.swift */; }; @@ -1349,7 +1348,6 @@ 51C452B72265178500C03939 /* styleSheet.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = styleSheet.css; sourceTree = ""; }; 51CE1C0823621EDA005548FC /* RefreshProgressView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RefreshProgressView.xib; sourceTree = ""; }; 51CE1C0A23622006005548FC /* RefreshProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshProgressView.swift; sourceTree = ""; }; - 51D637C123BEEF8300A3BBCD /* AccountRefreshControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountRefreshControl.swift; sourceTree = ""; }; 51D6A5BB23199C85001C27D8 /* MasterTimelineDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineDataSource.swift; sourceTree = ""; }; 51D87EE02311D34700E63F03 /* ActivityType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityType.swift; sourceTree = ""; }; 51E36E70239D6610006F47A5 /* AddWebFeedSelectFolderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWebFeedSelectFolderTableViewCell.swift; sourceTree = ""; }; @@ -1871,7 +1869,6 @@ 51C45245226506C800C03939 /* UIKit Extensions */ = { isa = PBXGroup; children = ( - 51D637C123BEEF8300A3BBCD /* AccountRefreshControl.swift */, 51F85BFA2275D85000C787DC /* Array-Extensions.swift */, 51F85BF42273625800C787DC /* Bundle-Extensions.swift */, 51627A92238A3836007B3B4B /* CroppingPreviewParameters.swift */, @@ -3910,7 +3907,6 @@ 51E595A6228CC36500FCC42B /* ArticleStatusSyncTimer.swift in Sources */, 512AF9C2236ED52C0066F8BE /* ImageHeaderView.swift in Sources */, 51A1699F235E10D700EB091F /* AboutViewController.swift in Sources */, - 51D637C223BEEF8300A3BBCD /* AccountRefreshControl.swift in Sources */, 51C45290226509C100C03939 /* PseudoFeed.swift in Sources */, 51C452A922650DC600C03939 /* ArticleRenderer.swift in Sources */, 5115CAF42266301400B21BCE /* AddContainerViewController.swift in Sources */, diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 39d92fd2a..6a1995f86 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -63,8 +63,9 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil) - refreshControl = AccountRefreshControl(errorHandler: ErrorHandler.present(self)) - + refreshControl = UIRefreshControl() + refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged) + configureToolbar() becomeFirstResponder() @@ -435,29 +436,12 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { } @objc func refreshAccounts(_ sender: Any) { - guard let refreshControl = refreshControl else { return } - + refreshControl?.endRefreshing() // This is a hack to make sure that an error dialog doesn't interfere with dismissing the refreshControl. // If the error dialog appears too closely to the call to endRefreshing, then the refreshControl never disappears. DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) } - - let checkImageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill")) - checkImageView.tintColor = .label - checkImageView.translatesAutoresizingMaskIntoConstraints = false - refreshControl.addSubview(checkImageView) - NSLayoutConstraint.activate([ - checkImageView.heightAnchor.constraint(equalToConstant: 35.0), - checkImageView.widthAnchor.constraint(equalToConstant: 35.0), - checkImageView.centerXAnchor.constraint(equalTo: refreshControl.centerXAnchor), - checkImageView.centerYAnchor.constraint(equalTo: refreshControl.centerYAnchor) - ]) - - DispatchQueue.main.asyncAfter(deadline: .now() + 0.33) { - refreshControl.endRefreshing() - checkImageView.removeFromSuperview() - } } // MARK: Keyboard shortcuts diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index e0a91330d..0bc0c2cbc 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -50,8 +50,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil) - refreshControl = AccountRefreshControl(errorHandler: ErrorHandler.present(self)) - // Setup the Search Controller searchController.delegate = self searchController.searchResultsUpdater = self diff --git a/iOS/UIKit Extensions/AccountRefreshControl.swift b/iOS/UIKit Extensions/AccountRefreshControl.swift deleted file mode 100644 index 67e0fc2bd..000000000 --- a/iOS/UIKit Extensions/AccountRefreshControl.swift +++ /dev/null @@ -1,51 +0,0 @@ -// -// AccountRefreshControl.swift -// NetNewsWire-iOS -// -// Created by Maurice Parker on 1/2/20. -// Copyright © 2020 Ranchero Software. All rights reserved. -// - -import UIKit -import Account - -class AccountRefreshControl: UIRefreshControl { - - var errorHandler: ((Error) -> ())? = nil - - init(errorHandler: @escaping (Error) -> ()) { - super.init() - self.errorHandler = errorHandler - addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged) - } - - required init?(coder: NSCoder) { - fatalError() - } - - @objc func refreshAccounts(_ sender: Any) { - - let checkImageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill")) - checkImageView.tintColor = .label - checkImageView.translatesAutoresizingMaskIntoConstraints = false - addSubview(checkImageView) - NSLayoutConstraint.activate([ - checkImageView.heightAnchor.constraint(equalToConstant: 35.0), - checkImageView.widthAnchor.constraint(equalToConstant: 35.0), - checkImageView.centerXAnchor.constraint(equalTo: centerXAnchor), - checkImageView.centerYAnchor.constraint(equalTo: centerYAnchor) - ]) - - DispatchQueue.main.asyncAfter(deadline: .now() + 0.33) { - self.endRefreshing() - checkImageView.removeFromSuperview() - - // This is a hack to make sure that an error dialog doesn't interfere with dismissing the refreshControl. - // If the error dialog appears too closely to the call to endRefreshing, then the refreshControl never disappears. - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - AccountManager.shared.refreshAll(errorHandler: self.errorHandler!) - } - } - } - -}