Skip to content

Commit

Permalink
fix: make getTopWindow more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
thespacemanatee committed Oct 8, 2024
1 parent 0553cd8 commit 7b919e7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ios/extensions/UIWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ public extension UIWindow {

func getTopWindow() -> UIWindow? {
// Return the keyboard window if it's available, otherwise return the last window
return keyboardWindow ?? UIApplication.shared.windows.last
if let keyboardWindow = keyboardWindow {
return keyboardWindow
}

Check failure on line 44 in ios/extensions/UIWindow.swift

View workflow job for this annotation

GitHub Actions / 🔎 Swift Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
if #available(iOS 13.0, *) {
for scene in UIApplication.shared.connectedScenes {
if scene.activationState == .foregroundActive,
let windowScene = scene as? UIWindowScene,
let keyWindow = windowScene.windows.first(where: { $0.isKeyWindow }) {
return keyWindow
}
}
return nil
} else {
return UIApplication.shared.windows.last { $0.isKeyWindow }
}
}
}

Expand Down

0 comments on commit 7b919e7

Please sign in to comment.