Skip to content

Commit

Permalink
Update RefdsApplication.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelesantos committed Aug 22, 2024
1 parent 7840961 commit 2c13d74
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions Sources/RefdsShared/Application/RefdsApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,15 @@ import UIKit

public final class RefdsApplication {
public static let shared = RefdsApplication()
#if os(macOS)
public var rootViewController: NSViewController? {
if let window = NSApplication.shared.windows.first,
let rootViewController = window.contentViewController {
return rootViewController
}
return nil
}
#else
public var rootViewController: UIViewController? {
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first,
let rootViewController = window.rootViewController {
return rootViewController
}
return nil

public var rootViewController: RefdsViewController? {
#if os(macOS)
let window = NSApplication.shared.windows.first
return window?.contentViewController?.refdsViewController
#else
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
let window = windowScene?.windows.first
return window?.rootViewController?.refdsViewController
#endif
}
#endif
}

0 comments on commit 2c13d74

Please sign in to comment.