Skip to content

Commit

Permalink
fix: random warnings in the project
Browse files Browse the repository at this point in the history
  • Loading branch information
gtokman committed May 3, 2021
1 parent 0b56745 commit bc3b979
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions Sources/ExtensionKit/UIKit/UIApplication.swift
@@ -1,11 +1,21 @@
#if canImport(UIKit)

import UIKit
import UIKit

#endif

public extension UIApplication {


/// Application key window
static let keyWindow = UIApplication
.shared
.connectedScenes
.filter { $0.activationState == .foregroundActive }
.compactMap { $0 as? UIWindowScene }
.first?.windows
.filter { $0.isKeyWindow }
.first

/// Open application settings
func openSettings() {
if let url = URL(string: UIApplication.openSettingsURLString), canOpenURL(url) {
Expand All @@ -16,7 +26,7 @@ public extension UIApplication {
}
}
}

/// Opens application sheet for phonen number
func openPhone(calling number: String) {
if let url = URL(string: "tel://" + number) {
Expand All @@ -27,7 +37,7 @@ public extension UIApplication {
}
}
}

/// Find My Facebook ID: https://findmyfbid.com/
/// - Parameters:
/// - name: Facebook name
Expand All @@ -46,7 +56,7 @@ public extension UIApplication {
UIViewController.getCurrentViewController()?.pushSafariViewController(urlString: "https://www.facebook.com/" + name)
}
}

/// Launches the Instagram app and loads the Instagram user
/// - Parameter name: Instagram username
func openInstagram(name: String?) {
Expand All @@ -63,7 +73,7 @@ public extension UIApplication {
}
}
}

/// Launches the Instagram app and loads the Instagram user
/// - Parameter name: Instagram username
func openInstagram(media: String?) {
Expand All @@ -80,7 +90,7 @@ public extension UIApplication {
}
}
}

/// Open a map app with the given query. Orders: Google Map -> Apple Map
///
/// - Parameter query: The query to search on the map.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ExtensionKit/UIKit/UIViewController.swift
Expand Up @@ -210,7 +210,7 @@ public extension UIViewController {
///
/// - Parameter base: `UIViewController` to search
/// - Returns: Current `UIViewController`
class func getCurrentViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
class func getCurrentViewController(base: UIViewController? = UIApplication.keyWindow?.rootViewController) -> UIViewController? {
if let nav = base as? UINavigationController {
return getCurrentViewController(base: nav.visibleViewController)
}
Expand Down

0 comments on commit bc3b979

Please sign in to comment.