1 |
//
|
|
2 |
// RouteComposer
|
|
3 |
// RoutingInterceptable.swift
|
|
4 |
// https://github.com/ekazaev/route-composer
|
|
5 |
//
|
|
6 |
// Created by Eugene Kazaev in 2018-2022.
|
|
7 |
// Distributed under the MIT license.
|
|
8 |
//
|
|
9 |
// Become a sponsor:
|
|
10 |
// https://github.com/sponsors/ekazaev
|
|
11 |
//
|
|
12 |
|
|
13 |
import Foundation
|
|
14 |
import UIKit
|
|
15 |
|
|
16 |
/// `UIViewController` that conforms to this protocol may overtake the control of the view controllers stack and
|
|
17 |
/// forbid the `Router` to dismiss or cover itself with another view controller.
|
|
18 |
/// Return false if the view controller can be dismissed.
|
|
19 |
public protocol RoutingInterceptable where Self: UIViewController {
|
|
20 |
|
|
21 |
// MARK: Properties to implement
|
|
22 |
|
|
23 |
/// true: if a view controller can be dismissed or covered by the `Router`, false otherwise.
|
|
24 |
var canBeDismissed: Bool { get }
|
|
25 |
|
|
26 |
/// Returns `UIViewController` that `Router` should consider as a parent `UIViewController`.
|
|
27 |
/// It may be useful to override it when you are building complicated custom `ContainerViewController`s.
|
|
28 |
var overriddenParentViewController: UIViewController? { get }
|
|
29 |
|
|
30 |
}
|
|
31 |
|
|
32 |
// MARK: Helper methods
|
|
33 |
|
|
34 |
public extension RoutingInterceptable {
|
|
35 |
|
|
36 |
/// Default implementation returns regular `UIViewController.parent`
|
|
37 |
var overriddenParentViewController: UIViewController? {
|
432x |
38 |
return parent
|
432x |
39 |
}
|
432x |
40 |
|
|
41 |
}
|
|