NavigationViewController.swift
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// NavigationControllerViewController.swift
// browser
//
// Created by Artem Talko on 26.09.2023.
//
import UIKit
final class NavigationViewController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
initViewController()
}
private func initViewController() {
setStartControllers()
view.backgroundColor = .blue
delegate = self
}
}
// MARK: - Helpers
extension NavigationViewController {
private func setStartControllers() {
let tabsViewController = TabsViewController()
let browserHomeViewController = BrowserHomeViewController(url: nil, currentTabId: nil)
let payloadViewController = PayloadViewController()
let cachingManager = CachingManager.shared
if cachingManager.isFirstAppLoad == false {
setViewControllers([tabsViewController, browserHomeViewController, payloadViewController], animated: true)
cachingManager.isFirstAppLoad.toggle()
} else {
setViewControllers([tabsViewController, browserHomeViewController], animated: true)
}
}
}
//MARK: Navigation Controller delegate
extension NavigationViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
if (fromVC is BrowserHomeViewController && toVC is TabsViewController) {
return OpenTabsTransition(operation: operation)
}
if (fromVC is TabsViewController && toVC is BrowserHomeViewController) {
return OpenTabsTransition(operation: operation)
}
return nil
}
}