Skip to content

Commit

Permalink
⭐️ Impl: UIViewController.topmostModalLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 27, 2024
1 parent 52280f2 commit 98fdbdf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ios/Temp/UIViewController+ModalHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,19 @@ extension UIViewController {

return presentedView.layer.animation(forKey: "position");
};

/// The current highest modal level in the window
///
/// return value of `nil` means that there is no modal presented, and a
/// return value of `0` is the first presented modal, and so on...
///
public var topmostModalLevel: Int? {
let window = self.view.window ?? UIApplication.shared.activeWindow;

guard let window = window else {
return nil;
};

return window.currentModalLevel;
};
};

0 comments on commit 98fdbdf

Please sign in to comment.