diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 318ea7547..d7cfb6367 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -97,6 +97,11 @@ 511D43EF231FBDE900FB1562 /* LaunchScreenPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 511D43ED231FBDE800FB1562 /* LaunchScreenPad.storyboard */; }; 511D4419231FC02D00FB1562 /* KeyboardManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 511D4410231FC02D00FB1562 /* KeyboardManager.swift */; }; 51236339236915B100951F16 /* RoundedProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512363372369155100951F16 /* RoundedProgressView.swift */; }; + 512392BE24E33A3C00F11704 /* RedditSelectAccountTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 516AE603246AF37B00731738 /* RedditSelectAccountTableViewController.swift */; }; + 512392BF24E33A3C00F11704 /* RedditSelectSortTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 516AE607246AFC9900731738 /* RedditSelectSortTableViewController.swift */; }; + 512392C024E33A3C00F11704 /* RedditAdd.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 516AE5FF246AF34100731738 /* RedditAdd.storyboard */; }; + 512392C124E33A3C00F11704 /* RedditSelectTypeTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 516AE601246AF36100731738 /* RedditSelectTypeTableViewController.swift */; }; + 512392C224E33A3C00F11704 /* RedditEnterDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 516AE605246AF3A900731738 /* RedditEnterDetailTableViewController.swift */; }; 5125E6CA24AE461D002A7562 /* TimelineLayoutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17B223DB24AC24D2001E4592 /* TimelineLayoutView.swift */; }; 5126EE97226CB48A00C22AFC /* SceneCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5126EE96226CB48A00C22AFC /* SceneCoordinator.swift */; }; 5127B238222B4849006D641D /* DetailKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */; }; @@ -4139,6 +4144,7 @@ 511D43CF231FA62200FB1562 /* DetailKeyboardShortcuts.plist in Resources */, 51A1699A235E10D700EB091F /* Settings.storyboard in Resources */, 49F40DF92335B71000552BF4 /* newsfoot.js in Resources */, + 512392C024E33A3C00F11704 /* RedditAdd.storyboard in Resources */, 51F85BEF2272520B00C787DC /* Thanks.rtf in Resources */, 51CE1C0923621EDA005548FC /* RefreshProgressView.xib in Resources */, 84C9FC9D2262A1A900D921D6 /* Assets.xcassets in Resources */, @@ -4942,11 +4948,13 @@ C5A6ED6D23C9B0C800AB6BE2 /* UIActivityViewController-Extensions.swift in Sources */, 5108F6D42375EEEF001ABC45 /* TimelinePreviewTableViewController.swift in Sources */, 84CAFCA522BC8C08007694F0 /* FetchRequestQueue.swift in Sources */, + 512392BE24E33A3C00F11704 /* RedditSelectAccountTableViewController.swift in Sources */, 515A517B243E90260089E588 /* ExtensionPoint.swift in Sources */, 51C4529C22650A1000C03939 /* SingleFaviconDownloader.swift in Sources */, 51E595A6228CC36500FCC42B /* ArticleStatusSyncTimer.swift in Sources */, 51F9F3F723DF6DB200A314FD /* ArticleIconSchemeHandler.swift in Sources */, 512AF9C2236ED52C0066F8BE /* ImageHeaderView.swift in Sources */, + 512392C124E33A3C00F11704 /* RedditSelectTypeTableViewController.swift in Sources */, 515A5181243E90260089E588 /* ExtensionPointIdentifer.swift in Sources */, 51A1699F235E10D700EB091F /* AboutViewController.swift in Sources */, 51C45290226509C100C03939 /* PseudoFeed.swift in Sources */, @@ -4960,6 +4968,7 @@ 51EF0F7E2277A57D0050506E /* MasterTimelineAccessibilityCellLayout.swift in Sources */, 51A1699B235E10D700EB091F /* AccountInspectorViewController.swift in Sources */, 512D554423C804DE0023FFFA /* OpenInSafariActivity.swift in Sources */, + 512392C224E33A3C00F11704 /* RedditEnterDetailTableViewController.swift in Sources */, 51C452762265091600C03939 /* MasterTimelineViewController.swift in Sources */, 5108F6D823763094001ABC45 /* TickMarkSlider.swift in Sources */, 51C452882265093600C03939 /* AddWebFeedViewController.swift in Sources */, @@ -4980,6 +4989,7 @@ 51C4529B22650A1000C03939 /* FaviconDownloader.swift in Sources */, 84DEE56622C32CA4005FC42C /* SmartFeedDelegate.swift in Sources */, 512E09012268907400BDCFDD /* MasterFeedTableViewSectionHeader.swift in Sources */, + 512392BF24E33A3C00F11704 /* RedditSelectSortTableViewController.swift in Sources */, 516AE9E02372269A007DEEAA /* IconImage.swift in Sources */, 519ED456244828C3007F8E94 /* AddExtensionPointViewController.swift in Sources */, 51C45268226508F600C03939 /* MasterFeedUnreadCountView.swift in Sources */, diff --git a/iOS/Add/Add.storyboard b/iOS/Add/Add.storyboard index b05147e75..ef9b03fad 100644 --- a/iOS/Add/Add.storyboard +++ b/iOS/Add/Add.storyboard @@ -11,7 +11,7 @@ - + diff --git a/iOS/Add/AddWebFeedViewController.swift b/iOS/Add/AddWebFeedViewController.swift index 16f52fc58..48d5c5fde 100644 --- a/iOS/Add/AddWebFeedViewController.swift +++ b/iOS/Add/AddWebFeedViewController.swift @@ -12,6 +12,12 @@ import RSCore import RSTree import RSParser +enum AddFeedType { + case web + case reddit + case twitter +} + class AddWebFeedViewController: UITableViewController { @IBOutlet weak var activityIndicator: UIActivityIndicatorView! @@ -25,6 +31,7 @@ class AddWebFeedViewController: UITableViewController { private var folderLabel = "" private var userCancelled = false + var addFeedType = AddFeedType.web var initialFeed: String? var initialFeedName: String? @@ -33,6 +40,17 @@ class AddWebFeedViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() + switch addFeedType { + case .reddit: + navigationItem.title = NSLocalizedString("Add Reddit Feed", comment: "Add Reddit Feed") + navigationItem.leftBarButtonItem = nil + case .twitter: + navigationItem.title = NSLocalizedString("Add Twitter Feed", comment: "Add Twitter Feed") + navigationItem.leftBarButtonItem = nil + default: + break + } + activityIndicator.isHidden = true activityIndicator.color = .label diff --git a/iOS/Add/Reddit/RedditAdd.storyboard b/iOS/Add/Reddit/RedditAdd.storyboard index a1cd14bca..1add6b8b2 100644 --- a/iOS/Add/Reddit/RedditAdd.storyboard +++ b/iOS/Add/Reddit/RedditAdd.storyboard @@ -1,5 +1,5 @@ - + @@ -123,6 +123,13 @@ + + + + + + + @@ -215,10 +222,10 @@ - + - + @@ -226,11 +233,11 @@ - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + diff --git a/iOS/Add/Reddit/RedditEnterDetailTableViewController.swift b/iOS/Add/Reddit/RedditEnterDetailTableViewController.swift index 41791d4f7..be1e75073 100644 --- a/iOS/Add/Reddit/RedditEnterDetailTableViewController.swift +++ b/iOS/Add/Reddit/RedditEnterDetailTableViewController.swift @@ -11,13 +11,12 @@ import Foundation import UIKit import Account -class RedditEnterDetailTableViewController: UITableViewController, SelectURLBuilder { +class RedditEnterDetailTableViewController: UITableViewController { @IBOutlet weak var detailTextField: UITextField! var nextBarButtonItem = UIBarButtonItem() var redditFeedType: RedditFeedType? - weak var delegate: SelectURLBuilderDelegate? override func viewDidLoad() { super.viewDidLoad() @@ -38,7 +37,6 @@ class RedditEnterDetailTableViewController: UITableViewController, SelectURLBuil let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self) selectSort.redditFeedType = redditFeedType selectSort.subreddit = detailTextField.text?.collapsingWhitespace - selectSort.delegate = delegate navigationController?.pushViewController(selectSort, animated: true) } diff --git a/iOS/Add/Reddit/RedditSelectAccountTableViewController.swift b/iOS/Add/Reddit/RedditSelectAccountTableViewController.swift index fddceedd8..98ba818d2 100644 --- a/iOS/Add/Reddit/RedditSelectAccountTableViewController.swift +++ b/iOS/Add/Reddit/RedditSelectAccountTableViewController.swift @@ -11,12 +11,11 @@ import Foundation import UIKit import Account -class RedditSelectAccountTableViewController: UITableViewController, SelectURLBuilder { +class RedditSelectAccountTableViewController: UITableViewController { private var redditFeedProviders = [RedditFeedProvider]() var redditFeedType: RedditFeedType? - weak var delegate: SelectURLBuilderDelegate? override func viewDidLoad() { super.viewDidLoad() @@ -37,7 +36,6 @@ class RedditSelectAccountTableViewController: UITableViewController, SelectURLBu let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self) selectSort.redditFeedType = redditFeedType selectSort.username = redditFeedProviders[indexPath.row].username - selectSort.delegate = delegate navigationController?.pushViewController(selectSort, animated: true) } diff --git a/iOS/Add/Reddit/RedditSelectSortTableViewController.swift b/iOS/Add/Reddit/RedditSelectSortTableViewController.swift index 167d2ca75..c707a6031 100644 --- a/iOS/Add/Reddit/RedditSelectSortTableViewController.swift +++ b/iOS/Add/Reddit/RedditSelectSortTableViewController.swift @@ -9,16 +9,11 @@ import UIKit import Account -class RedditSelectSortTableViewController: UITableViewController, SelectURLBuilder { +class RedditSelectSortTableViewController: UITableViewController { - weak var delegate: SelectURLBuilderDelegate? var redditFeedType: RedditFeedType? var username: String? var subreddit: String? - - override func viewDidLoad() { - super.viewDidLoad() - } override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { @@ -39,11 +34,13 @@ class RedditSelectSortTableViewController: UITableViewController, SelectURLBuild } guard let redditFeedType = redditFeedType else { return } + let url = RedditFeedProvider.buildURL(redditFeedType, username: username, subreddit: subreddit, sort: sort)?.absoluteString - if let url = RedditFeedProvider.buildURL(redditFeedType, username: username, subreddit: subreddit, sort: sort) { - delegate?.selectURLBuilderDidBuildURL(url) - } - dismiss(animated: true) + let addViewController = UIStoryboard.add.instantiateViewController(withIdentifier: "AddWebFeedViewController") as! AddWebFeedViewController + addViewController.addFeedType = .reddit + addViewController.initialFeed = url + navigationController?.pushViewController(addViewController, animated: true) + } } diff --git a/iOS/Add/Reddit/RedditSelectTypeTableViewController.swift b/iOS/Add/Reddit/RedditSelectTypeTableViewController.swift index afc5069c9..1f8e2a0a7 100644 --- a/iOS/Add/Reddit/RedditSelectTypeTableViewController.swift +++ b/iOS/Add/Reddit/RedditSelectTypeTableViewController.swift @@ -9,14 +9,12 @@ import UIKit import Account -class RedditSelectTypeTableViewController: UITableViewController, SelectURLBuilder { +class RedditSelectTypeTableViewController: UITableViewController { - weak var delegate: SelectURLBuilderDelegate? + @IBAction func cancel(_ sender: Any) { + dismiss(animated: true) + } - override func viewDidLoad() { - super.viewDidLoad() - } - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { switch indexPath.row { case 0: @@ -25,28 +23,23 @@ class RedditSelectTypeTableViewController: UITableViewController, SelectURLBuild let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self) selectSort.redditFeedType = .home selectSort.username = redditFeedProviders.first!.username - selectSort.delegate = delegate navigationController?.pushViewController(selectSort, animated: true) } else { let selectAccount = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectAccountTableViewController.self) selectAccount.redditFeedType = .home - selectAccount.delegate = delegate navigationController?.pushViewController(selectAccount, animated: true) } case 1: let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self) selectSort.redditFeedType = .popular - selectSort.delegate = delegate navigationController?.pushViewController(selectSort, animated: true) case 2: let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self) selectSort.redditFeedType = .all - selectSort.delegate = delegate navigationController?.pushViewController(selectSort, animated: true) case 3: let enterDetail = UIStoryboard.redditAdd.instantiateController(ofType: RedditEnterDetailTableViewController.self) enterDetail.redditFeedType = .subreddit - enterDetail.delegate = delegate navigationController?.pushViewController(enterDetail, animated: true) default: fatalError() diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 3da0867dd..8114977eb 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -402,7 +402,12 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { let addWebFeedActionTitle = NSLocalizedString("Add Web Feed", comment: "Add Web Feed") let addWebFeedAction = UIAlertAction(title: addWebFeedActionTitle, style: .default) { _ in - self.coordinator.showAddFeed() + self.coordinator.showAddWebFeed() + } + + let addRedditFeedActionTitle = NSLocalizedString("Add Reddit Feed", comment: "Add Reddit Feed") + let addRedditFeedAction = UIAlertAction(title: addRedditFeedActionTitle, style: .default) { _ in + self.coordinator.showAddRedditFeed() } let addWebFolderdActionTitle = NSLocalizedString("Add Folder", comment: "Add Folder") @@ -411,6 +416,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { } alertController.addAction(addWebFeedAction) + alertController.addAction(addRedditFeedAction) alertController.addAction(addWebFolderAction) alertController.addAction(cancelAction) diff --git a/iOS/RootSplitViewController.swift b/iOS/RootSplitViewController.swift index 12d0d8084..e84a8241f 100644 --- a/iOS/RootSplitViewController.swift +++ b/iOS/RootSplitViewController.swift @@ -95,7 +95,7 @@ class RootSplitViewController: UISplitViewController { } @objc func addNewFeed(_ sender: Any?) { - coordinator.showAddFeed() + coordinator.showAddWebFeed() } @objc func addNewFolder(_ sender: Any?) { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 2a3301241..396e9efc4 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -384,7 +384,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { case .readArticle: self.handleReadArticle(activity.userInfo) case .addFeedIntent: - self.showAddFeed() + self.showAddWebFeed() } } } @@ -1167,7 +1167,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { rootSplitViewController.present(feedInspectorNavController, animated: true) } - func showAddFeed(initialFeed: String? = nil, initialFeedName: String? = nil) { + func showAddWebFeed(initialFeed: String? = nil, initialFeedName: String? = nil) { // Since Add Feed can be opened from anywhere with a keyboard shortcut, we have to deselect any currently selected feeds selectFeed(nil) @@ -1183,6 +1183,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { masterFeedViewController.present(addNavViewController, animated: true) } + func showAddRedditFeed() { + let addNavViewController = UIStoryboard.redditAdd.instantiateInitialViewController() as! UINavigationController + addNavViewController.modalPresentationStyle = .formSheet + addNavViewController.preferredContentSize = AddWebFeedViewController.preferredContentSizeForFormSheetDisplay + masterFeedViewController.present(addNavViewController, animated: true) + } + func showAddFolder() { let addNavViewController = UIStoryboard.add.instantiateViewController(withIdentifier: "AddFolderViewControllerNav") as! UINavigationController addNavViewController.modalPresentationStyle = .formSheet diff --git a/iOS/SceneDelegate.swift b/iOS/SceneDelegate.swift index 74a99a543..70c95a717 100644 --- a/iOS/SceneDelegate.swift +++ b/iOS/SceneDelegate.swift @@ -100,7 +100,7 @@ private extension SceneDelegate { case "com.ranchero.NetNewsWire.ShowSearch": coordinator.showSearch() case "com.ranchero.NetNewsWire.ShowAdd": - coordinator.showAddFeed() + coordinator.showAddWebFeed() default: break }