From fa002fbed6e028eef92f31fdea25ff59a1d84c43 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 30 Sep 2018 21:28:22 -0400 Subject: [PATCH] Add tapping hashtags to show tag timeline --- .../Main/MainTabBarViewController.swift | 9 ++++--- Tusker/Screens/Timeline/Timeline.storyboard | 24 ++----------------- .../TimelineTableViewController.swift | 8 +++---- Tusker/TuskerNavigationDelegate.swift | 7 +++++- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/Tusker/Screens/Main/MainTabBarViewController.swift b/Tusker/Screens/Main/MainTabBarViewController.swift index d963a681..3cb24c35 100644 --- a/Tusker/Screens/Main/MainTabBarViewController.swift +++ b/Tusker/Screens/Main/MainTabBarViewController.swift @@ -14,14 +14,17 @@ class MainTabBarViewController: UITabBarController { super.viewDidLoad() viewControllers = [ - TimelineTableViewController.create(for: .home), - TimelineTableViewController.create(for: .public(local: false)), - TimelineTableViewController.create(for: .public(local: true)), + navigationController(for: TimelineTableViewController.create(for: .home)), + navigationController(for: TimelineTableViewController.create(for: .public(local: false))), + navigationController(for: TimelineTableViewController.create(for: .public(local: true))), NotificationsTableViewController.create(), PreferencesTableViewController.create() ] } + func navigationController(for vc: UIViewController) -> UINavigationController { + return UINavigationController(rootViewController: vc) + } /* // MARK: - Navigation diff --git a/Tusker/Screens/Timeline/Timeline.storyboard b/Tusker/Screens/Timeline/Timeline.storyboard index b2ce2806..d76dbea4 100644 --- a/Tusker/Screens/Timeline/Timeline.storyboard +++ b/Tusker/Screens/Timeline/Timeline.storyboard @@ -1,10 +1,10 @@ - + - + @@ -49,25 +49,5 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/Tusker/Screens/Timeline/TimelineTableViewController.swift b/Tusker/Screens/Timeline/TimelineTableViewController.swift index e753d633..614dd7fb 100644 --- a/Tusker/Screens/Timeline/TimelineTableViewController.swift +++ b/Tusker/Screens/Timeline/TimelineTableViewController.swift @@ -12,8 +12,7 @@ import Pachyderm class TimelineTableViewController: UITableViewController { static func create(for timeline: Timeline) -> UIViewController { - guard let navigationController = UIStoryboard(name: "Timeline", bundle: nil).instantiateInitialViewController() as? UINavigationController, - let timelineController = navigationController.topViewController as? TimelineTableViewController else { fatalError() } + guard let timelineController = UIStoryboard(name: "Timeline", bundle: nil).instantiateInitialViewController() as? TimelineTableViewController else { fatalError() } timelineController.timeline = timeline let title: String @@ -29,10 +28,9 @@ class TimelineTableViewController: UITableViewController { case .direct: title = "Direct" } - navigationController.tabBarItem.title = title - timelineController.navigationItem.title = title + timelineController.title = title - return navigationController + return timelineController } lazy var favoriteActionImage: UIImage = UIGraphicsImageRenderer(size: CGSize(width: 30 * 137/131, height: 30)).image { _ in diff --git a/Tusker/TuskerNavigationDelegate.swift b/Tusker/TuskerNavigationDelegate.swift index c44aaa56..53806a30 100644 --- a/Tusker/TuskerNavigationDelegate.swift +++ b/Tusker/TuskerNavigationDelegate.swift @@ -53,7 +53,12 @@ extension TuskerNavigationDelegate where Self: UIViewController { } func selected(tag: Hashtag) { - + guard let navigationController = navigationController else { + fatalError("Can't show hashtag timeline when not in navigation controller") + } + let timeline = Timeline.tag(hashtag: tag.name) + let vc = TimelineTableViewController.create(for: timeline) + navigationController.pushViewController(vc, animated: true) } func selected(url: URL) {