diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 5bd756139..5ca775c33 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 5110AB7822B7BD6200A94F76 /* AddView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5110AB7722B7BD6200A94F76 /* AddView.swift */; }; 51126DA4225FDE2F00722696 /* RSImage-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51126DA3225FDE2F00722696 /* RSImage-Extensions.swift */; }; 5115CAF42266301400B21BCE /* AddContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51121B5A22661FEF00BC0EC1 /* AddContainerViewController.swift */; }; 511D43CF231FA62200FB1562 /* DetailKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */; }; @@ -34,6 +33,7 @@ 5144EA51227B8E4500D19003 /* AccountsFeedbinWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */; }; 5144EA52227B8E4500D19003 /* AccountsFeedbin.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */; }; 514B7C8323205EFB00BAC947 /* RootSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514B7C8223205EFB00BAC947 /* RootSplitViewController.swift */; }; + 514B7D1F23219F3C00BAC947 /* AddControllerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514B7D1E23219F3C00BAC947 /* AddControllerType.swift */; }; 51543685228F6753005E1CDF /* DetailAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51543684228F6753005E1CDF /* DetailAccountViewController.swift */; }; 515436882291D75D005E1CDF /* AddLocalAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515436872291D75D005E1CDF /* AddLocalAccountViewController.swift */; }; 5154368A2291FED9005E1CDF /* FeedbinAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 515436892291FED9005E1CDF /* FeedbinAccountViewController.swift */; }; @@ -686,7 +686,6 @@ 510D707D22B02A4B004E8F65 /* SettingsLocalAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsLocalAccountView.swift; sourceTree = ""; }; 510D707F22B02A5F004E8F65 /* SettingsFeedbinAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsFeedbinAccountView.swift; sourceTree = ""; }; 510D708122B041CC004E8F65 /* SettingsAccountLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAccountLabelView.swift; sourceTree = ""; }; - 5110AB7722B7BD6200A94F76 /* AddView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddView.swift; sourceTree = ""; }; 51121AA12265430A00BC0EC1 /* NetNewsWire_iOSapp_target.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = NetNewsWire_iOSapp_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 = ""; }; @@ -707,6 +706,7 @@ 5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsFeedbinWindowController.swift; sourceTree = ""; }; 5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsFeedbin.xib; sourceTree = ""; }; 514B7C8223205EFB00BAC947 /* RootSplitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootSplitViewController.swift; sourceTree = ""; }; + 514B7D1E23219F3C00BAC947 /* AddControllerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddControllerType.swift; sourceTree = ""; }; 51543684228F6753005E1CDF /* DetailAccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailAccountViewController.swift; sourceTree = ""; }; 515436872291D75D005E1CDF /* AddLocalAccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddLocalAccountViewController.swift; sourceTree = ""; }; 515436892291FED9005E1CDF /* FeedbinAccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinAccountViewController.swift; sourceTree = ""; }; @@ -1028,18 +1028,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 5110AB6E22B7BD3C00A94F76 /* UIKit */ = { - isa = PBXGroup; - children = ( - 51C452822265093600C03939 /* Add.storyboard */, - 51121B5A22661FEF00BC0EC1 /* AddContainerViewController.swift */, - 51C452842265093600C03939 /* AddFeedViewController.swift */, - 51C452812265093600C03939 /* AddFeedFolderPickerData.swift */, - 51C4528B2265095F00C03939 /* AddFolderViewController.swift */, - ); - path = UIKit; - sourceTree = ""; - }; 511D43CE231FA51100FB1562 /* Resources */ = { isa = PBXGroup; children = ( @@ -1217,8 +1205,12 @@ 51C452802265093600C03939 /* Add */ = { isa = PBXGroup; children = ( - 5110AB6E22B7BD3C00A94F76 /* UIKit */, - 5110AB7722B7BD6200A94F76 /* AddView.swift */, + 51C452822265093600C03939 /* Add.storyboard */, + 51121B5A22661FEF00BC0EC1 /* AddContainerViewController.swift */, + 514B7D1E23219F3C00BAC947 /* AddControllerType.swift */, + 51C452842265093600C03939 /* AddFeedViewController.swift */, + 51C452812265093600C03939 /* AddFeedFolderPickerData.swift */, + 51C4528B2265095F00C03939 /* AddFolderViewController.swift */, ); path = Add; sourceTree = ""; @@ -2434,7 +2426,6 @@ files = ( 840D617F2029031C009BC708 /* AppDelegate.swift in Sources */, 512E08E72268801200BDCFDD /* FeedTreeControllerDelegate.swift in Sources */, - 5110AB7822B7BD6200A94F76 /* AddView.swift in Sources */, 51C452A422650A2D00C03939 /* ArticleUtilities.swift in Sources */, 51EF0F79227716380050506E /* ColorHash.swift in Sources */, 5183CCDA226E31A50010922C /* NonIntrinsicImageView.swift in Sources */, @@ -2477,6 +2468,7 @@ 51C4529E22650A1900C03939 /* ImageDownloader.swift in Sources */, 51C45292226509C800C03939 /* TodayFeedDelegate.swift in Sources */, 51C452A222650A1900C03939 /* RSHTMLMetadata+Extension.swift in Sources */, + 514B7D1F23219F3C00BAC947 /* AddControllerType.swift in Sources */, 51E3EB3D229AB08300645299 /* ErrorHandler.swift in Sources */, 5183CCE5226F4DFA0010922C /* RefreshInterval.swift in Sources */, 51EF0F7C2277919E0050506E /* TimelineNumberOfLinesViewController.swift in Sources */, diff --git a/iOS/Add/UIKit/Add.storyboard b/iOS/Add/Add.storyboard similarity index 100% rename from iOS/Add/UIKit/Add.storyboard rename to iOS/Add/Add.storyboard diff --git a/iOS/Add/UIKit/AddContainerViewController.swift b/iOS/Add/AddContainerViewController.swift similarity index 93% rename from iOS/Add/UIKit/AddContainerViewController.swift rename to iOS/Add/AddContainerViewController.swift index 16d92719c..dc574c02f 100644 --- a/iOS/Add/UIKit/AddContainerViewController.swift +++ b/iOS/Add/AddContainerViewController.swift @@ -33,6 +33,7 @@ class AddContainerViewController: UIViewController { private var currentViewController: AddContainerViewControllerChild? + var initialControllerType: AddControllerType? var initialFeed: String? var initialFeedName: String? @@ -40,20 +41,26 @@ class AddContainerViewController: UIViewController { super.viewDidLoad() activityIndicatorView.isHidden = true - - switchToFeed() + + typeSelectorSegmentedControl.selectedSegmentIndex = initialControllerType?.rawValue ?? 0 + switch initialControllerType { + case .feed: + switchToFeed() + case .folder: + switchToFolder() + default: + assertionFailure() + } } @IBAction func typeSelectorChanged(_ sender: UISegmentedControl) { - switch sender.selectedSegmentIndex { case 0: switchToFeed() default: switchToFolder() } - } @IBAction func cancel(_ sender: Any) { diff --git a/iOS/Add/AddControllerType.swift b/iOS/Add/AddControllerType.swift new file mode 100644 index 000000000..cf68e97af --- /dev/null +++ b/iOS/Add/AddControllerType.swift @@ -0,0 +1,14 @@ +// +// AddControllerType.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 9/5/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import Foundation + +enum AddControllerType: Int { + case feed = 0 + case folder = 1 +} diff --git a/iOS/Add/UIKit/AddFeedFolderPickerData.swift b/iOS/Add/AddFeedFolderPickerData.swift similarity index 100% rename from iOS/Add/UIKit/AddFeedFolderPickerData.swift rename to iOS/Add/AddFeedFolderPickerData.swift diff --git a/iOS/Add/UIKit/AddFeedViewController.swift b/iOS/Add/AddFeedViewController.swift similarity index 99% rename from iOS/Add/UIKit/AddFeedViewController.swift rename to iOS/Add/AddFeedViewController.swift index 2d6295c62..a6736dbba 100644 --- a/iOS/Add/UIKit/AddFeedViewController.swift +++ b/iOS/Add/AddFeedViewController.swift @@ -44,6 +44,7 @@ class AddFeedViewController: UITableViewController, AddContainerViewControllerCh urlTextField.autocapitalizationType = .none urlTextField.text = initialFeed urlTextField.delegate = self + urlTextField.becomeFirstResponder() if initialFeed != nil { delegate?.readyToAdd(state: true) diff --git a/iOS/Add/UIKit/AddFolderViewController.swift b/iOS/Add/AddFolderViewController.swift similarity index 98% rename from iOS/Add/UIKit/AddFolderViewController.swift rename to iOS/Add/AddFolderViewController.swift index 3e7849937..77844d460 100644 --- a/iOS/Add/UIKit/AddFolderViewController.swift +++ b/iOS/Add/AddFolderViewController.swift @@ -31,6 +31,8 @@ class AddFolderViewController: UITableViewController, AddContainerViewController accounts = AccountManager.shared.sortedActiveAccounts nameTextField.delegate = self + nameTextField.becomeFirstResponder() + accountLabel.text = (accounts[0] as DisplayNameProvider).nameForDisplay if shouldDisplayPicker { diff --git a/iOS/Add/AddView.swift b/iOS/Add/AddView.swift deleted file mode 100644 index 0c57b1a97..000000000 --- a/iOS/Add/AddView.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// AddView.swift -// NetNewsWire-iOS -// -// Created by Maurice Parker on 6/17/19. -// Copyright © 2019 Ranchero Software. All rights reserved. -// - -import SwiftUI - -struct AddView : View { - var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello World!"/*@END_MENU_TOKEN@*/) - } -} - -#if DEBUG -struct AddView_Previews : PreviewProvider { - static var previews: some View { - AddView() - } -} -#endif diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 8a16f7ae5..ed86b3da7 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -347,7 +347,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { } @IBAction func add(_ sender: UIBarButtonItem) { - coordinator.showAdd() + coordinator.showAdd(.feed) } @objc func toggleSectionHeader(_ sender: UITapGestureRecognizer) { diff --git a/iOS/RootSplitViewController.swift b/iOS/RootSplitViewController.swift index 278e0c6a7..7f862138a 100644 --- a/iOS/RootSplitViewController.swift +++ b/iOS/RootSplitViewController.swift @@ -64,9 +64,11 @@ class RootSplitViewController: UISplitViewController { } @objc func addNewFeed(_ sender: Any?) { + coordinator.showAdd(.feed) } @objc func addNewFolder(_ sender: Any?) { + coordinator.showAdd(.folder) } @objc func refresh(_ sender: Any?) { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index b6519fa4e..ad32518b9 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -805,8 +805,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { // self.present(settings, animated: true) } - func showAdd() { - let addViewController = UIStoryboard.add.instantiateInitialViewController()! + func showAdd(_ type: AddControllerType) { + let addViewController = UIStoryboard.add.instantiateInitialViewController() as! UINavigationController + let containerController = addViewController.topViewController as! AddContainerViewController + containerController.initialControllerType = type addViewController.modalPresentationStyle = .formSheet addViewController.preferredContentSize = AddContainerViewController.preferredContentSizeForFormSheetDisplay masterFeedViewController.present(addViewController, animated: true) diff --git a/iOS/SceneDelegate.swift b/iOS/SceneDelegate.swift index dc496dff8..4cdc78b5c 100644 --- a/iOS/SceneDelegate.swift +++ b/iOS/SceneDelegate.swift @@ -66,7 +66,7 @@ private extension SceneDelegate { case "com.ranchero.NetNewsWire.ShowSearch": coordinator.showSearch() case "com.ranchero.NetNewsWire.ShowAdd": - coordinator.showAdd() + coordinator.showAdd(.feed) default: break }