diff --git a/Mac/Base.lproj/MainWindow.storyboard b/Mac/Base.lproj/MainWindow.storyboard index d6444a8d3..7d5f2c5dc 100644 --- a/Mac/Base.lproj/MainWindow.storyboard +++ b/Mac/Base.lproj/MainWindow.storyboard @@ -1,7 +1,7 @@ - + - + @@ -486,11 +486,11 @@ - - - - - - + + + + + + diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 4ce676290..c6282b4a3 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -8,8 +8,10 @@ /* Begin PBXBuildFile section */ 51126DA4225FDE2F00722696 /* RSImage-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51126DA3225FDE2F00722696 /* RSImage-Extensions.swift */; }; + 5115CAF42266301400B21BCE /* AddContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51121B5A22661FEF00BC0EC1 /* AddContainerViewController.swift */; }; 5127B238222B4849006D641D /* DetailKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */; }; 5127B23A222B4849006D641D /* DetailKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */; }; + 517D9075226639F500323654 /* AddAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 517D906B2266392900323654 /* AddAccountViewController.swift */; }; 519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519B8D322143397200FA689C /* SharingServiceDelegate.swift */; }; 51C451A9226377C200C03939 /* ArticlesDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8407167F2262A61100344432 /* ArticlesDatabase.framework */; }; 51C451AA226377C200C03939 /* ArticlesDatabase.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8407167F2262A61100344432 /* ArticlesDatabase.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -596,9 +598,11 @@ /* Begin PBXFileReference section */ 51121AA12265430A00BC0EC1 /* NetNewsWire_iOS_target.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = NetNewsWire_iOS_target.xcconfig; sourceTree = ""; }; + 51121B5A22661FEF00BC0EC1 /* AddContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddContainerViewController.swift; sourceTree = ""; }; 51126DA3225FDE2F00722696 /* RSImage-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RSImage-Extensions.swift"; sourceTree = ""; }; 5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailKeyboardDelegate.swift; sourceTree = ""; }; 5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = DetailKeyboardShortcuts.plist; sourceTree = ""; }; + 517D906B2266392900323654 /* AddAccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountViewController.swift; sourceTree = ""; }; 519B8D322143397200FA689C /* SharingServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingServiceDelegate.swift; sourceTree = ""; }; 51C4524E226506F400C03939 /* UIStoryboard-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStoryboard-Extensions.swift"; sourceTree = ""; }; 51C4524F226506F400C03939 /* UIImage-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage-Extensions.swift"; sourceTree = ""; }; @@ -948,16 +952,18 @@ path = Detail; sourceTree = ""; }; - 51C452802265093600C03939 /* Add Feed */ = { + 51C452802265093600C03939 /* Add */ = { isa = PBXGroup; children = ( 51C452822265093600C03939 /* Add.storyboard */, + 51121B5A22661FEF00BC0EC1 /* AddContainerViewController.swift */, + 51C452842265093600C03939 /* AddFeedViewController.swift */, 51C452812265093600C03939 /* AddFeedFolderPickerData.swift */, 51C452832265093600C03939 /* FolderTreeControllerDelegate.swift */, - 51C452842265093600C03939 /* AddFeedViewController.swift */, 51C4528B2265095F00C03939 /* AddFolderViewController.swift */, + 517D906B2266392900323654 /* AddAccountViewController.swift */, ); - path = "Add Feed"; + path = Add; sourceTree = ""; }; 51C452A822650DA100C03939 /* Article Rendering */ = { @@ -1503,7 +1509,7 @@ 51C4525D226508F600C03939 /* Master */, 51C4526D2265091600C03939 /* Timeline */, 51C4527D2265092C00C03939 /* Detail */, - 51C452802265093600C03939 /* Add Feed */, + 51C452802265093600C03939 /* Add */, 51C45245226506C800C03939 /* Extensions */, 84C9FC9A2262A1A900D921D6 /* Resources */, ); @@ -2137,6 +2143,7 @@ 51C452A622650A3500C03939 /* Node-Extensions.swift in Sources */, 51C45294226509C800C03939 /* SearchFeedDelegate.swift in Sources */, 51C452A022650A1900C03939 /* FeedIconDownloader.swift in Sources */, + 517D9075226639F500323654 /* AddAccountViewController.swift in Sources */, 51C4529E22650A1900C03939 /* ImageDownloader.swift in Sources */, 51C45292226509C800C03939 /* TodayFeedDelegate.swift in Sources */, 84F3EE1B20DEC97E003FADEB /* HTMLFeedFinder.swift in Sources */, @@ -2157,6 +2164,7 @@ 51C4529C22650A1000C03939 /* SingleFaviconDownloader.swift in Sources */, 51C45290226509C100C03939 /* PseudoFeed.swift in Sources */, 51C452A922650DC600C03939 /* ArticleRenderer.swift in Sources */, + 5115CAF42266301400B21BCE /* AddContainerViewController.swift in Sources */, 51C45297226509E300C03939 /* DefaultFeedsImporter.swift in Sources */, 51C452AC22650FD200C03939 /* AppNotifications.swift in Sources */, 51C452762265091600C03939 /* MasterTimelineViewController.swift in Sources */, diff --git a/iOS/Add Feed/Add.storyboard b/iOS/Add/Add.storyboard similarity index 68% rename from iOS/Add Feed/Add.storyboard rename to iOS/Add/Add.storyboard index 207c7564a..2eb9e7470 100644 --- a/iOS/Add Feed/Add.storyboard +++ b/iOS/Add/Add.storyboard @@ -1,11 +1,12 @@ - - + + + @@ -13,22 +14,22 @@ - - + + - + - + - + - + - + @@ -46,14 +47,14 @@ - + - + - + @@ -69,23 +70,23 @@ - + - + - + - - + + - + - - + + @@ -168,44 +169,116 @@ - + - + - - - + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + - + - - + + @@ -224,23 +297,23 @@ - + - + - + - - + + - + - - + + @@ -304,23 +377,52 @@ - + - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/iOS/Add/AddAccountViewController.swift b/iOS/Add/AddAccountViewController.swift new file mode 100644 index 000000000..0fe1e73c0 --- /dev/null +++ b/iOS/Add/AddAccountViewController.swift @@ -0,0 +1,21 @@ +// +// AddAccountViewController.swift +// NetNewsWire +// +// Created by Maurice Parker on 4/16/19. +// Copyright © 2019 Ranchero Software, LLC. All rights reserved. +// + +import UIKit + +class AddAccountViewController: UITableViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // I couldn't figure out the gap at the top of the UITableView, so I took a hammer to it. + tableView.contentInset = UIEdgeInsets(top: -28, left: 0, bottom: 0, right: 0) + + } + +} diff --git a/iOS/Add/AddContainerViewController.swift b/iOS/Add/AddContainerViewController.swift new file mode 100644 index 000000000..bd98bbfce --- /dev/null +++ b/iOS/Add/AddContainerViewController.swift @@ -0,0 +1,101 @@ +// +// AddContainerViewController.swift +// NetNewsWire +// +// Created by Maurice Parker on 4/16/19. +// Copyright © 2019 Ranchero Software, LLC. All rights reserved. +// + +import UIKit + +class AddContainerViewController: UIViewController { + + @IBOutlet weak var cancelButton: UIBarButtonItem! + @IBOutlet weak var activityIndicatorView: UIActivityIndicatorView! + @IBOutlet weak var addButton: UIBarButtonItem! + @IBOutlet weak var containerView: UIView! + + private var currentViewController: UIViewController? + + override func viewDidLoad() { + + super.viewDidLoad() + activityIndicatorView.isHidden = true + + switchToFeed() + + } + + @IBAction func typeSelectorChanged(_ sender: UISegmentedControl) { + + switch sender.selectedSegmentIndex { + case 0: + switchToFeed() + case 1: + switchToFolder() + default: + switchToAccount() + } + + } + + @IBAction func cancel(_ sender: Any) { + dismiss(animated: true) + } + + @IBAction func add(_ sender: Any) { + } + +} + +private extension AddContainerViewController { + + func switchToFeed() { + guard !(currentViewController is AddFeedViewController) else { + return + } + hideCurrentController() + displayContentController(UIStoryboard.add.instantiateController(ofType: AddFeedViewController.self)) + } + + func switchToFolder() { + guard !(currentViewController is AddFolderViewController) else { + return + } + hideCurrentController() + displayContentController(UIStoryboard.add.instantiateController(ofType: AddFolderViewController.self)) + } + + func switchToAccount() { + guard !(currentViewController is AddAccountViewController) else { + return + } + hideCurrentController() + displayContentController(UIStoryboard.add.instantiateController(ofType: AddAccountViewController.self)) + } + + func displayContentController(_ controller: UIViewController) { + + addChild(controller) + + containerView.addSubview(controller.view) + controller.view.translatesAutoresizingMaskIntoConstraints = false + controller.view.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true + controller.view.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true + controller.view.leadingAnchor.constraint(equalTo: containerView.leadingAnchor).isActive = true + controller.view.trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true + + controller.didMove(toParent: self) + + } + + func hideCurrentController() { + guard let currentViewController = currentViewController else { + return + } + currentViewController.willMove(toParent: nil) + currentViewController.view.removeFromSuperview() + currentViewController.removeFromParent() + } + +} diff --git a/iOS/Add Feed/AddFeedFolderPickerData.swift b/iOS/Add/AddFeedFolderPickerData.swift similarity index 86% rename from iOS/Add Feed/AddFeedFolderPickerData.swift rename to iOS/Add/AddFeedFolderPickerData.swift index 92dbe1c73..70d3d0293 100644 --- a/iOS/Add Feed/AddFeedFolderPickerData.swift +++ b/iOS/Add/AddFeedFolderPickerData.swift @@ -1,4 +1,11 @@ -//Copyright © 2019 Vincode, Inc. All rights reserved. +// +// AddFeedFolderPickerData.swift +// NetNewsWire +// +// Created by Maurice Parker on 4/16/19. +// Copyright © 2019 Ranchero Software, LLC. All rights reserved. +// + import Foundation import Account diff --git a/iOS/Add Feed/AddFeedViewController.swift b/iOS/Add/AddFeedViewController.swift similarity index 94% rename from iOS/Add Feed/AddFeedViewController.swift rename to iOS/Add/AddFeedViewController.swift index 7257624f9..9b7d44974 100644 --- a/iOS/Add Feed/AddFeedViewController.swift +++ b/iOS/Add/AddFeedViewController.swift @@ -1,4 +1,10 @@ -//Copyright © 2019 Vincode, Inc. All rights reserved. +// +// AddFeedViewController.swift +// NetNewsWire +// +// Created by Maurice Parker on 4/16/19. +// Copyright © 2019 Ranchero Software, LLC. All rights reserved. +// import UIKit import Account @@ -42,7 +48,11 @@ class AddFeedViewController: UITableViewController { pickerData = AddFeedFolderPickerData() folderPickerView.dataSource = self folderPickerView.delegate = self + folderPickerView.showsSelectionIndicator = true folderLabel.text = pickerData.containerNames[0] + + // I couldn't figure out the gap at the top of the UITableView, so I took a hammer to it. + tableView.contentInset = UIEdgeInsets(top: -28, left: 0, bottom: 0, right: 0) } diff --git a/iOS/Add Feed/AddFolderViewController.swift b/iOS/Add/AddFolderViewController.swift similarity index 85% rename from iOS/Add Feed/AddFolderViewController.swift rename to iOS/Add/AddFolderViewController.swift index 9eee0bbcf..362f5f006 100644 --- a/iOS/Add Feed/AddFolderViewController.swift +++ b/iOS/Add/AddFolderViewController.swift @@ -1,4 +1,10 @@ -//Copyright © 2019 Vincode, Inc. All rights reserved. +// +// AddFolderViewController.swift +// NetNewsWire +// +// Created by Maurice Parker on 4/16/19. +// Copyright © 2019 Ranchero Software, LLC. All rights reserved. +// import UIKit import Account @@ -23,6 +29,8 @@ class AddFolderViewController: UITableViewController { accountPickerView.dataSource = self accountPickerView.delegate = self + // I couldn't figure out the gap at the top of the UITableView, so I took a hammer to it. + tableView.contentInset = UIEdgeInsets(top: -28, left: 0, bottom: 0, right: 0) } @IBAction func cancel(_ sender: Any) { diff --git a/iOS/Add Feed/FolderTreeControllerDelegate.swift b/iOS/Add/FolderTreeControllerDelegate.swift similarity index 100% rename from iOS/Add Feed/FolderTreeControllerDelegate.swift rename to iOS/Add/FolderTreeControllerDelegate.swift diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index 39c689e13..37d4b8323 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -29,7 +29,7 @@ - + @@ -92,13 +92,13 @@ - + - + @@ -160,13 +160,13 @@ - + - + @@ -187,18 +187,11 @@ - - - - - - - - - - - - + + + + + @@ -208,13 +201,13 @@ - + - + @@ -268,7 +261,6 @@ - diff --git a/iOS/Extensions/UIStoryboard-Extensions.swift b/iOS/Extensions/UIStoryboard-Extensions.swift index df0f99c0a..66bfc485a 100644 --- a/iOS/Extensions/UIStoryboard-Extensions.swift +++ b/iOS/Extensions/UIStoryboard-Extensions.swift @@ -14,6 +14,10 @@ extension UIStoryboard { return UIStoryboard(name: "Main", bundle: nil) } + static var add: UIStoryboard { + return UIStoryboard(name: "Add", bundle: nil) + } + func instantiateController(ofType type: T.Type = T.self) -> T where T: UIViewController { let storyboardId = String(describing: type) diff --git a/iOS/Master/MasterViewController.swift b/iOS/Master/MasterViewController.swift index aff6b0a4b..762e2f9ca 100644 --- a/iOS/Master/MasterViewController.swift +++ b/iOS/Master/MasterViewController.swift @@ -175,15 +175,8 @@ class MasterViewController: UITableViewController { // MARK: Actions - @IBAction func addFeed(_ sender: UIBarButtonItem) { - let feedViewController = UIStoryboard(name: "Add", bundle: nil).instantiateViewController(withIdentifier: "AddFeedNavigationController") - feedViewController.modalPresentationStyle = .popover - feedViewController.popoverPresentationController?.barButtonItem = sender - self.present(feedViewController, animated: true) - } - - @IBAction func addFolder(_ sender: UIBarButtonItem) { - let feedViewController = UIStoryboard(name: "Add", bundle: nil).instantiateViewController(withIdentifier: "AddFolderNavigationController") + @IBAction func add(_ sender: UIBarButtonItem) { + let feedViewController = UIStoryboard.add.instantiateInitialViewController()! feedViewController.modalPresentationStyle = .popover feedViewController.popoverPresentationController?.barButtonItem = sender self.present(feedViewController, animated: true)