NavigationViewController.swift
2.08 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
56
57
58
59
60
61
62
63
//
// 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() {
delegate = self
setStartControllers()
}
}
// MARK: - Helpers
extension NavigationViewController {
private func setStartControllers() {
let payloadViewController = PayloadViewController()
let removeAdvertViewController = RemoveAdvertViewController()
let cachingManager = CachingManager.shared
if !cachingManager.isFirstAppLoad {
setViewControllers([removeAdvertViewController, payloadViewController], animated: true)
cachingManager.isFirstAppLoad.toggle()
} else {
setViewControllers([removeAdvertViewController], 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)
}
if (fromVC is RemoveAdvertViewController && toVC is BrowserHomeViewController) {
return OpenBrowserHomeTransition(operation: operation)
}
if (fromVC is BrowserHomeViewController && toVC is RemoveAdvertViewController) {
return OpenBrowserHomeTransition(operation: operation)
}
return nil
}
}