2018-08-21 21:17:25 +00:00
|
|
|
//
|
|
|
|
// MainTabBarViewController.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
2019-02-08 18:41:19 +00:00
|
|
|
// Created by Shadowfacts on 8/21/18.
|
2018-08-21 21:17:25 +00:00
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
2019-01-05 17:59:55 +00:00
|
|
|
class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
|
2018-08-21 21:17:25 +00:00
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
2019-01-05 17:59:55 +00:00
|
|
|
self.delegate = self
|
|
|
|
|
|
|
|
viewControllers = [
|
2019-09-14 19:55:06 +00:00
|
|
|
embedInNavigationController(TimelinesPageViewController()),
|
2019-09-14 16:04:06 +00:00
|
|
|
embedInNavigationController(NotificationsPageViewController()),
|
2019-01-19 19:31:31 +00:00
|
|
|
ComposeViewController(),
|
|
|
|
embedInNavigationController(MyProfileTableViewController()),
|
2019-01-05 17:59:55 +00:00
|
|
|
]
|
2018-08-21 21:17:25 +00:00
|
|
|
}
|
|
|
|
|
2018-10-06 14:38:36 +00:00
|
|
|
func embedInNavigationController(_ vc: UIViewController) -> UINavigationController {
|
|
|
|
if let vc = vc as? UINavigationController {
|
|
|
|
return vc
|
|
|
|
} else {
|
|
|
|
return UINavigationController(rootViewController: vc)
|
|
|
|
}
|
2018-10-01 01:28:22 +00:00
|
|
|
}
|
2018-08-31 02:30:19 +00:00
|
|
|
|
2019-01-05 17:59:55 +00:00
|
|
|
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
|
|
|
|
if viewController is ComposeViewController {
|
2019-06-13 19:06:19 +00:00
|
|
|
let compose = ComposeViewController()
|
|
|
|
let navigationController = embedInNavigationController(compose)
|
|
|
|
navigationController.presentationController?.delegate = compose
|
|
|
|
present(navigationController, animated: true)
|
2019-01-05 17:59:55 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2018-08-21 21:17:25 +00:00
|
|
|
}
|