Add keyboard shortcuts for Add Feed and Add Folder

This commit is contained in:
Maurice Parker 2019-09-05 15:07:35 -05:00
parent 7582ade6f5
commit afce6ff26f
12 changed files with 45 additions and 48 deletions

View File

@ -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 = "<group>"; };
510D707F22B02A5F004E8F65 /* SettingsFeedbinAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsFeedbinAccountView.swift; sourceTree = "<group>"; };
510D708122B041CC004E8F65 /* SettingsAccountLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAccountLabelView.swift; sourceTree = "<group>"; };
5110AB7722B7BD6200A94F76 /* AddView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddView.swift; sourceTree = "<group>"; };
51121AA12265430A00BC0EC1 /* NetNewsWire_iOSapp_target.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = NetNewsWire_iOSapp_target.xcconfig; sourceTree = "<group>"; };
51121B5A22661FEF00BC0EC1 /* AddContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddContainerViewController.swift; sourceTree = "<group>"; };
51126DA3225FDE2F00722696 /* RSImage-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RSImage-Extensions.swift"; sourceTree = "<group>"; };
@ -707,6 +706,7 @@
5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsFeedbinWindowController.swift; sourceTree = "<group>"; };
5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsFeedbin.xib; sourceTree = "<group>"; };
514B7C8223205EFB00BAC947 /* RootSplitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootSplitViewController.swift; sourceTree = "<group>"; };
514B7D1E23219F3C00BAC947 /* AddControllerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddControllerType.swift; sourceTree = "<group>"; };
51543684228F6753005E1CDF /* DetailAccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailAccountViewController.swift; sourceTree = "<group>"; };
515436872291D75D005E1CDF /* AddLocalAccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddLocalAccountViewController.swift; sourceTree = "<group>"; };
515436892291FED9005E1CDF /* FeedbinAccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinAccountViewController.swift; sourceTree = "<group>"; };
@ -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 = "<group>";
};
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 = "<group>";
@ -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 */,

View File

@ -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) {

View File

@ -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
}

View File

@ -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)

View File

@ -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 {

View File

@ -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

View File

@ -347,7 +347,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
}
@IBAction func add(_ sender: UIBarButtonItem) {
coordinator.showAdd()
coordinator.showAdd(.feed)
}
@objc func toggleSectionHeader(_ sender: UITapGestureRecognizer) {

View File

@ -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?) {

View File

@ -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)

View File

@ -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
}