blob: 2ba223a8f94b940a5aba134475d8c9a15abd2081 (
plain)
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
64
|
//
// AppRouteProtocol.swift
// MullvadVPN
//
// Created by pronebird on 17/08/2023.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Foundation
/**
Formal protocol describing a group of routes.
*/
public protocol AppRouteGroupProtocol: Comparable, Equatable, Hashable, Sendable {
/**
Returns `true` if group is presented modally, otherwise `false` if group is a part of root view
controller.
*/
var isModal: Bool { get }
/**
Defines a modal level that's used for restricting modal presentation.
A group with higher modal level can be presented above a group with lower level but not the other way around. For example, if a modal group is represented by
`UIAlertController`, it should have the highest level (i.e `Int.max`) to prevent other modals from being presented above it, however it enables alert
controller to be presented above any other modal.
*/
var modalLevel: Int { get }
}
/**
Default implementation of `Comparable` for `AppRouteGroupProtocol` which compares `modalLevel` of both sides.
*/
extension AppRouteGroupProtocol {
public static func < (lhs: Self, rhs: Self) -> Bool {
lhs.modalLevel < rhs.modalLevel
}
public static func <= (lhs: Self, rhs: Self) -> Bool {
lhs.modalLevel <= rhs.modalLevel
}
}
/**
Formal protocol describing a single route.
*/
public protocol AppRouteProtocol: Equatable, Hashable, Sendable {
associatedtype RouteGroupType: AppRouteGroupProtocol
/**
Returns `true` when only one route of a kind can be displayed.
*/
var isExclusive: Bool { get }
/**
Returns `true` if the route supports sub-navigation.
*/
var supportsSubNavigation: Bool { get }
/**
Navigation group to which the route belongs to.
*/
var routeGroup: RouteGroupType { get }
}
|