-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathRouter.swift
More file actions
55 lines (45 loc) · 1.83 KB
/
Router.swift
File metadata and controls
55 lines (45 loc) · 1.83 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
//
// Router.swift
// RoutingExample
//
// Created by Cassius Pacheco on 5/3/20.
// Copyright © 2020 Cassius Pacheco. All rights reserved.
//
import UIKit
import DependencyContainer
protocol Closable: class {
/// Closes the Router's root view controller using the transition used to show it.
func close()
/// Closes the Router's root view controller using the transition used to show it.
func close(completion: (() -> Void)?)
}
protocol Dismissable: class {
/// Dismisses the Router's root view controller ignoring the transition used to show it.
func dismiss()
/// Dismisses the Router's root view controller ignoring the transition used to show it.
func dismiss(completion: (() -> Void)?)
}
protocol Deeplinkable: class {
/// Route to a view controller applying the transition provided by resolving the URL to a specific Route.
@discardableResult
func route(to url: URL, as transition: Transition) -> Bool
}
protocol Routable: class {
/// Route to a view controller using the transition provided.
func route(to viewController: UIViewController, as transition: Transition)
/// Route to a view controller using the transition provided.
func route(to viewController: UIViewController, as transition: Transition, completion: (() -> Void)?)
}
protocol Router: Routable {
/// The root view controller of this router.
var root: UIViewController? { get set }
// Depending on the App's architecture it may be better to expose
// a way of accessing dependencies in the Routers through a DI Container,
// or something similar, in order to ensure the controllers and
// view models instantiated by this class become testable.
//
// Dependency Container example:
// https://github.com/CassiusPacheco/DependencyContainer
//
var container: DependencyContainer { get }
}