/
NavigationCoordinator.swift
48 lines (39 loc) · 1.41 KB
/
NavigationCoordinator.swift
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
//
// NavigationCoordinator.swift
// sample-coordinator
//
// Created by 加賀江 優幸 on 2017/12/24.
// Copyright © 2017年 yuutetu. All rights reserved.
//
import UIKit
class NavigationCoordinator: Coordinator, TransitionDelegate {
let text: String
let navigationController: UINavigationController
let rootViewController: UIViewController
init(navigationController: UINavigationController, text: String) {
self.text = text
self.navigationController = navigationController
let rootViewController: TransitionViewController = TransitionViewController.viewController(with: text)
self.rootViewController = rootViewController
rootViewController.delegate = self
}
func start() {
navigationController.viewControllers = [rootViewController]
}
// MARK: - TransitionDelegate
func push() {
let viewController = TransitionViewController.viewController(with: text)
viewController.delegate = self
navigationController.pushViewController(viewController, animated: true)
}
func pop() {
navigationController.popViewController(animated: true)
}
func popToRoot() {
navigationController.popToRootViewController(animated: true)
}
func startFlow() {
let coordinator = FlowCoordinator(navigationController: navigationController)
coordinator.start()
}
}