47 lines
1.5 KiB
Swift
47 lines
1.5 KiB
Swift
//
|
|
// MainTabBarViewController.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 8/21/18.
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
self.delegate = self
|
|
|
|
viewControllers = [
|
|
embedInNavigationController(TimelineTableViewController(for: .home)),
|
|
embedInNavigationController(NotificationsTableViewController()),
|
|
ComposeViewController(),
|
|
embedInNavigationController(TimelineTableViewController(for: .public(local: false))),
|
|
embedInNavigationController(MyProfileTableViewController()),
|
|
]
|
|
}
|
|
|
|
func embedInNavigationController(_ vc: UIViewController) -> UINavigationController {
|
|
if let vc = vc as? UINavigationController {
|
|
return vc
|
|
} else {
|
|
return UINavigationController(rootViewController: vc)
|
|
}
|
|
}
|
|
|
|
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
|
|
if viewController is ComposeViewController {
|
|
let compose = ComposeViewController()
|
|
let navigationController = embedInNavigationController(compose)
|
|
navigationController.presentationController?.delegate = compose
|
|
present(navigationController, animated: true)
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
}
|