From adffe41c9507aad1b2251d7126e9b9e6f0e19623 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 d963a68159..3cb24c350b 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 b2ce28066f..d76dbea4ef 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 e753d63308..614dd7fb1c 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 c44aaa56aa..53806a3091 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) {