diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2023-08-16 12:11:32 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2023-08-17 14:04:00 +0200 |
| commit | 2dadfaedacd4f0e6396a50d70274ba0afb1a6325 (patch) | |
| tree | 9ab75fdafda115c747223c8b7dd240eb8ca19a67 | |
| parent | b32ea9f1ccb6b4b1e9fc438f764bcdd9c027a715 (diff) | |
| download | mullvadvpn-2dadfaedacd4f0e6396a50d70274ba0afb1a6325.tar.xz mullvadvpn-2dadfaedacd4f0e6396a50d70274ba0afb1a6325.zip | |
Add AppRouteGroupProtocol.modalLevel, add default impl of Comparable
| -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 - } } /** |
