From 9f6203e839b4c67b211b80aefe1d2df40bde6734 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 6 Sep 2019 10:29:00 -0500 Subject: [PATCH] Improve launch performance and fix Search home page quick action --- .../MasterTimelineViewController.swift | 1 + iOS/SceneCoordinator.swift | 13 ++++++++++--- iOS/SceneDelegate.swift | 9 +++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 96d8f6e26..48cfcaeed 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -169,6 +169,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner func showSearchAll() { navigationItem.searchController?.isActive = true navigationItem.searchController?.searchBar.selectedScopeButtonIndex = 1 + navigationItem.searchController?.searchBar.becomeFirstResponder() } func focus() { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 27aaacbd6..ef7bdec59 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -327,7 +327,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { func showSearch() { selectFeed(nil) - masterTimelineViewController?.showSearchAll() + + masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self) + masterTimelineViewController!.coordinator = self + navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: false) + + DispatchQueue.main.asyncAfter(deadline: .now()) { + self.masterTimelineViewController!.showSearchAll() + } } // MARK: Notifications @@ -633,13 +640,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { if indexPath == nil { if rootSplitViewController.isCollapsed { if masterNavigationController.children.last is DetailViewController { - masterNavigationController.popViewController(animated: false) + masterNavigationController.popViewController(animated: !automated) } } else { let systemMessageViewController = UIStoryboard.main.instantiateController(ofType: SystemMessageViewController.self) installDetailController(systemMessageViewController, automated: automated) } - masterTimelineViewController?.updateArticleSelection(animate: true) + masterTimelineViewController?.updateArticleSelection(animate: !automated) return } diff --git a/iOS/SceneDelegate.swift b/iOS/SceneDelegate.swift index 4cdc78b5c..3c7503e7a 100644 --- a/iOS/SceneDelegate.swift +++ b/iOS/SceneDelegate.swift @@ -17,21 +17,22 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // UIWindowScene delegate func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + window = UIWindow(windowScene: scene as! UIWindowScene) window!.tintColor = AppAssets.netNewsWireBlueColor window!.rootViewController = coordinator.start() - window!.makeKeyAndVisible() if let shortcutItem = connectionOptions.shortcutItem { + window!.makeKeyAndVisible() handleShortcutItem(shortcutItem) return } if let userActivity = connectionOptions.userActivities.first ?? session.stateRestorationActivity { - DispatchQueue.main.asyncAfter(deadline: .now()) { - self.coordinator.handle(userActivity) - } + self.coordinator.handle(userActivity) } + + window!.makeKeyAndVisible() } func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {