diff --git a/WordPress/Classes/Apps/Reader/ReaderTabViewController.swift b/WordPress/Classes/Apps/Reader/ReaderTabViewController.swift index 5527c9529dbe..5b5f82fdb0a0 100644 --- a/WordPress/Classes/Apps/Reader/ReaderTabViewController.swift +++ b/WordPress/Classes/Apps/Reader/ReaderTabViewController.swift @@ -108,8 +108,7 @@ final class ReaderTabViewController: UITabBarController, UITabBarControllerDeleg } private func makeNotificationsViewController() -> UIViewController { - let notificationsVC = UIStoryboard(name: "Notifications", bundle: Bundle(for: Self.self)) - .instantiateInitialViewController() as! NotificationsViewController + let notificationsVC = Notifications.instantiateInitialViewController() notificationsVC.tabBarItem = UITabBarItem( title: Strings.notifications, image: UIImage(named: "tab-bar-notifications"), diff --git a/WordPress/Classes/System/Root View/SplitViewRootPresenter+Notifications.swift b/WordPress/Classes/System/Root View/SplitViewRootPresenter+Notifications.swift index d75202e1ff4e..0a6e1d07aa9c 100644 --- a/WordPress/Classes/System/Root View/SplitViewRootPresenter+Notifications.swift +++ b/WordPress/Classes/System/Root View/SplitViewRootPresenter+Notifications.swift @@ -7,7 +7,7 @@ class NotificationsSplitViewContent: SplitViewDisplayable { var secondary: UINavigationController init() { - notificationsViewController = UIStoryboard(name: "Notifications", bundle: nil).instantiateInitialViewController() as! NotificationsViewController + notificationsViewController = Notifications.instantiateInitialViewController() supplementary = UINavigationController(rootViewController: notificationsViewController) secondary = UINavigationController() diff --git a/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewController.swift b/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewController.swift index 90c23e22ed5c..ce1b47b00238 100644 --- a/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewController.swift +++ b/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewController.swift @@ -119,7 +119,7 @@ class NotificationsViewController: UIViewController, UITableViewDataSource, UITa // MARK: - View Lifecycle static func showInPopover(from presentingVC: UIViewController, sourceItem: UIPopoverPresentationControllerSourceItem) { - let notificationsVC = UIStoryboard(name: "Notifications", bundle: nil).instantiateInitialViewController() as! NotificationsViewController + let notificationsVC = Notifications.instantiateInitialViewController() notificationsVC.isSidebarModeEnabled = true let navigationVC = UINavigationController(rootViewController: notificationsVC) diff --git a/WordPress/Classes/ViewRelated/Notifications/Tools/NotificationCommentDetailCoordinator.swift b/WordPress/Classes/ViewRelated/Notifications/Tools/NotificationCommentDetailCoordinator.swift index ca56af639c72..236aa50c7f4c 100644 --- a/WordPress/Classes/ViewRelated/Notifications/Tools/NotificationCommentDetailCoordinator.swift +++ b/WordPress/Classes/ViewRelated/Notifications/Tools/NotificationCommentDetailCoordinator.swift @@ -1,8 +1,20 @@ import Foundation import WordPressShared -// This facilitates showing the CommentDetailViewController within the context of Notifications. +enum Notifications { + private static let storyboardName = "Notifications" + static let storyboard = UIStoryboard( + name: Notifications.storyboardName, + bundle: Bundle(for: NotificationsViewController.self) + ) + + static func instantiateInitialViewController() -> NotificationsViewController { + storyboard.instantiateInitialViewController() as! NotificationsViewController + } +} + +/// Facilitates showing the `CommentDetailViewController` within the context of Notifications. protocol CommentDetailsNotificationDelegate: AnyObject { func previousNotificationTapped(current: Notification?) func nextNotificationTapped(current: Notification?) @@ -76,10 +88,9 @@ private extension NotificationCommentDetailCoordinator { } func showNotificationDetails(with notification: Notification) { - let storyboard = UIStoryboard(name: Notifications.storyboardName, bundle: nil) - guard let viewController, - let notificationDetailsViewController = storyboard.instantiateViewController(withIdentifier: Notifications.viewControllerName) as? NotificationDetailsViewController else { + let notificationDetailsViewController = Notifications.storyboard + .instantiateViewController(withIdentifier: NotificationDetailsViewController.classNameWithoutNamespaces()) as? NotificationDetailsViewController else { DDLogError("NotificationCommentDetailCoordinator: missing view controller.") return } @@ -125,12 +136,6 @@ private extension NotificationCommentDetailCoordinator { let properties = ["notification_type": notification.type ?? "unknown"] WPAnalytics.track(.openedNotificationDetails, withProperties: properties) } - - enum Notifications { - static let storyboardName = "Notifications" - static let viewControllerName = NotificationDetailsViewController.classNameWithoutNamespaces() - } - } // MARK: - CommentDetailsNotificationDelegate