frenzy-ios/Reader/Screens/AppSplitViewController.swift

63 lines
1.9 KiB
Swift

//
// AppSplitViewController.swift
// Reader
//
// Created by Shadowfacts on 1/14/22.
//
import UIKit
#if targetEnvironment(macCatalyst)
import AppKit
#endif
class AppSplitViewController: UISplitViewController {
private let fervorController: FervorController
private var secondaryNav: UINavigationController!
init(fervorController: FervorController) {
self.fervorController = fervorController
super.init(style: .doubleColumn)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
preferredDisplayMode = .oneBesideSecondary
preferredSplitBehavior = .tile
presentsWithGesture = true
showsSecondaryOnlyButton = true
primaryBackgroundStyle = .sidebar
let sidebarHome = HomeViewController(fervorController: fervorController)
sidebarHome.enableStretchyMenu = false
sidebarHome.itemsDelegate = self
let sidebarNav = UINavigationController(rootViewController: sidebarHome)
sidebarNav.navigationBar.prefersLargeTitles = true
setViewController(sidebarNav, for: .primary)
secondaryNav = UINavigationController()
secondaryNav.isNavigationBarHidden = true
secondaryNav.view.backgroundColor = .appBackground
setViewController(secondaryNav, for: .secondary)
let home = HomeViewController(fervorController: fervorController)
let nav = AppNavigationController(rootViewController: home)
setViewController(nav, for: .compact)
}
}
extension AppSplitViewController: ItemsViewControllerDelegate {
func showReadItem(_ item: Item) {
secondaryNav.setViewControllers([ReadViewController(item: item, fervorController: fervorController)], animated: false)
}
}