Files
GitHawk/Classes/View Controllers/RootViewControllers.swift
Hesham Salman 1e2e0c1698 Chore/bookmark rewrite (#865)
* Unified store behavior, new bookmark model

- Added a `Store` protocol to the project with default implementations
  that should be sufficient for most models. (#855)
- Switched images in the notification type category to #imageLiterals,
  so we can avoid the optionality of the image.

* Implemented BookMark ViewModel

* Created Bookmark Collection Cell

* Created Bookmark View Controller

Done:
  - Displays empty state
  - Displays bookmarks
  - Allows for adding of new bookmarks
  - Navigating to bookmarks

In flight:
  - Clear All

TODO:
  - Search
  - Cleanup old files & remove SwipeCell hacks

* Unified search and clear all behavior

The search bar and clear all buttons between the search and bookmarks
page had different styles and behavior. This PR:
  - Makes a generic clear-all header
  - Gives one to each VC
  - Makes them behave the same to the user re: visibility etc

* Re-implemented filter

* Deleted old files

* Attributed String Sizing

* Removed bookmark store tests

* Reloading bookmarks & namespacing

Can now reload bookmarks through the listener pattern (#773, #783).
Bookmark store is now correctly namespaced again.
2017-11-06 09:03:29 -05:00

63 lines
2.4 KiB
Swift

//
// RootViewControllers.swift
// Freetime
//
// Created by Ryan Nystrom on 5/17/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit
func newSettingsRootViewController(
sessionManager: GithubSessionManager,
client: GithubClient,
rootNavigationManager: RootNavigationManager
) -> UIViewController {
guard let controller = UIStoryboard(name: "Settings", bundle: nil).instantiateInitialViewController()
else { fatalError("Could not unpack settings storyboard") }
if let nav = controller as? UINavigationController,
let first = nav.viewControllers.first as? SettingsViewController {
first.client = client
first.sessionManager = sessionManager
first.rootNavigationManager = rootNavigationManager
nav.tabBarItem.title = NSLocalizedString("Settings", comment: "")
nav.tabBarItem.image = UIImage(named: "tab-gear")
nav.tabBarItem.selectedImage = UIImage(named: "tab-gear-selected")
}
return controller
}
func newNotificationsRootViewController(client: GithubClient) -> UIViewController {
let controller = NotificationsViewController(client: NotificationClient(githubClient: client), showRead: false)
let title = NSLocalizedString("Inbox", comment: "")
controller.title = title
let nav = UINavigationController(rootViewController: controller)
nav.tabBarItem.title = title
nav.tabBarItem.image = UIImage(named: "tab-inbox")
nav.tabBarItem.selectedImage = UIImage(named: "tab-inbox-selected")
return nav
}
func newSearchRootViewController(client: GithubClient) -> UIViewController {
let controller = SearchViewController(client: client)
let nav = UINavigationController(rootViewController: controller)
nav.tabBarItem.title = Constants.Strings.search
nav.tabBarItem.image = UIImage(named: "tab-search")
nav.tabBarItem.selectedImage = UIImage(named: "tab-search-selected")
return nav
}
func newBookmarksRootViewController(client: GithubClient) -> UIViewController {
let title = Constants.Strings.bookmarks
let controller = BookmarkViewController(client: client)
controller.makeBackBarItemEmpty()
controller.title = title
let nav = UINavigationController(rootViewController: controller)
nav.tabBarItem.image = UIImage(named: "tab-bookmark")
nav.tabBarItem.selectedImage = UIImage(named: "tab-bookmark-selected")
nav.tabBarItem.title = title
return nav
}