Slather logo

Coverage for "UIWindow+Extension.swift" : 100.00%

(9 of 9 relevant lines covered)

RouteComposer/Classes/Extensions/UIWindow+Extension.swift

1
//
2
// RouteComposer
3
// UIWindow+Extension.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
/// `UIWindow` helper functions.
17
public extension UIWindow {
18
19
    /// The topmost `UIViewController` in the view controller stack.
20
    var topmostViewController: UIViewController? {
392x
21
        var topmostViewController = rootViewController
392x
22
392x
23
        while let presentedViewController = topmostViewController?.presentedViewController, !presentedViewController.isBeingDismissed {
392x
24
            topmostViewController = presentedViewController
161x
25
        }
392x
26
392x
27
        return topmostViewController
392x
28
    }
392x
29
30
}