diff options
Diffstat (limited to 'ios')
| -rw-r--r-- | ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift b/ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift index a5118e47e2..880593e2bd 100644 --- a/ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift +++ b/ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift @@ -19,6 +19,24 @@ protocol AppRouteGroupProtocol: Comparable, Equatable, Hashable { 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 { + static func < (lhs: Self, rhs: Self) -> Bool { + lhs.modalLevel < rhs.modalLevel + } } /** @@ -83,7 +101,7 @@ enum AppRouteGroup: Comparable, Equatable, Hashable { } } - private var order: Int { + var modalLevel: Int { switch self { case .primary: return 0 @@ -91,10 +109,6 @@ enum AppRouteGroup: Comparable, Equatable, Hashable { return 1 } } - - static func < (lhs: AppRouteGroup, rhs: AppRouteGroup) -> Bool { - lhs.order < rhs.order - } } /** |
