Skip to content

Commit

Permalink
Fixed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ActuallyTaylor committed Jun 28, 2023
1 parent 0c42e58 commit 3813325
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import UIKit

/// https://stackoverflow.com/a/68989580/14886210
extension UIApplication {
var mainScene: UIScene? {
return UIApplication.shared.connectedScenes
.first(where: {$0.activationState == .foregroundActive})
}

var keyWindow: UIWindow? {
// Get connected scenes
return UIApplication.shared.connectedScenes
// Keep only active scenes, onscreen and visible to the user
.filter { $0.activationState == .foregroundActive }
// Keep only the first `UIWindowScene`
.first(where: { $0 is UIWindowScene })
// Get its associated windows
.flatMap({ $0 as? UIWindowScene })?.windows
// Finally, keep only the key window
.first(where: \.isKeyWindow)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct DebugView: View {

@discardableResult
func shareLog() throws -> Bool {
guard let source = UIApplication.shared.windows.last?.rootViewController else {
guard let source = UIApplication.shared.keyWindow?.rootViewController else {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ struct StatisticsView: View {
RowView(label: "Device Name", data: UIDevice.modelName, onTapData: UIDevice.current.model)
RowView(label: "System Bane", data: UIDevice.current.systemName)
RowView(label: "System Version", data: UIDevice.current.systemVersion)
#if os(xrOS)
#else
RowView(label: "Orientation", data: parseOrientation(UIDevice.current.orientation))
RowView(label: "In Valid Orientation", data: "\(UIDevice.current.orientation.isValidInterfaceOrientation)")
#endif
RowView(label: "Multitasking Supported", data: "\(UIDevice.current.isMultitaskingSupported)")
RowView(label: "Interface Idiom", data: parseInterfaceIdiom(UIDevice.current.userInterfaceIdiom))
}
Expand Down

0 comments on commit 3813325

Please sign in to comment.