Bladeren bron

remove some warning code

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 jaren geleden
bovenliggende
commit
efbc465c4c

+ 1 - 1
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -716,7 +716,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                     
                     let popup = NCPopupViewController(contentController: vcAccountRequest, popupWidth: 300, popupHeight: height)
                     
-                    UIApplication.shared.keyWindow?.rootViewController?.present(popup, animated: true)
+                    self.present(popup, animated: true)
                 }
 
                 // TIP

+ 2 - 1
iOSClient/Menu/NCMenu+FloatingPanel.swift

@@ -45,7 +45,8 @@ class NCMenuFloatingPanelLayout: FloatingPanelLayout {
         let screenHeight = UIApplication.shared.isLandscape
         ? min(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height)
         : max(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height)
-        let bottomInset = UIApplication.shared.keyWindow?.rootViewController?.view.safeAreaInsets.bottom ?? 0
+        let window = UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }
+        let bottomInset = window?.rootViewController?.view.safeAreaInsets.bottom ?? 0
         let panelHeight = CGFloat(actionsHeight) + bottomInset
 
         topInset = max(48, screenHeight - panelHeight)

+ 2 - 1
iOSClient/RichWorkspace/NCViewerRichWorkspaceWebView.swift

@@ -54,7 +54,8 @@ class NCViewerRichWorkspaceWebView: UIViewController, WKNavigationDelegate, WKSc
     }
 
     @objc func keyboardDidShow(notification: Notification) {
-        let safeAreaInsetsBottom = UIApplication.shared.keyWindow!.safeAreaInsets.bottom
+        let window = UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }
+        let safeAreaInsetsBottom = window?.safeAreaInsets.bottom ?? 0
         guard let info = notification.userInfo else { return }
         guard let frameInfo = info[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
         let keyboardFrame = frameInfo.cgRectValue

+ 2 - 1
iOSClient/Select/NCSelect.swift

@@ -83,6 +83,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
     private var backgroundImageView = UIImageView()
 
     private var activeAccount: tableAccount!
+    private let window = UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }
 
     // MARK: - View Life Cycle
 
@@ -114,7 +115,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
 
         buttonCancel.title = NSLocalizedString("_cancel_", comment: "")
 
-        bottomContraint?.constant = UIApplication.shared.keyWindow?.rootViewController?.view.safeAreaInsets.bottom ?? 0
+        bottomContraint?.constant = window?.rootViewController?.view.safeAreaInsets.bottom ?? 0
 
         // Empty
         emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsView, delegate: self)

+ 1 - 1
iOSClient/Utility/NCActivityIndicator.swift

@@ -64,7 +64,7 @@ class NCActivityIndicator: NSObject {
 
             #if !EXTENSION
             if backgroundView == nil {
-                if let window = UIApplication.shared.keyWindow {
+                if let window = (UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }) {
                     self.viewBackgroundActivityIndicator?.removeFromSuperview()
                     self.viewBackgroundActivityIndicator = NCViewActivityIndicator(frame: window.bounds)
                     window.addSubview(self.viewBackgroundActivityIndicator!)

+ 7 - 6
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -46,6 +46,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     private let thumbnailPadding: CGFloat = 2
     private let animateDuration: TimeInterval = 0.3
     private let pageViewtopAnchor: CGFloat = UIDevice.current.userInterfaceIdiom == .phone ? 10 : 30
+    private let window = UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }
 
     private var defaultBackgroundColor: UIColor = .clear
 
@@ -112,7 +113,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
             pdfThumbnailView.topAnchor.constraint(equalTo: pdfThumbnailScrollView.topAnchor),
             pdfThumbnailView.bottomAnchor.constraint(equalTo: pdfThumbnailScrollView.bottomAnchor),
             pdfThumbnailView.leadingAnchor.constraint(equalTo: pdfThumbnailScrollView.leadingAnchor),
-            pdfThumbnailView.leadingAnchor.constraint(equalTo: pdfThumbnailScrollView.trailingAnchor, constant: (UIApplication.shared.keyWindow?.safeAreaInsets.left ?? 0)),
+            pdfThumbnailView.leadingAnchor.constraint(equalTo: pdfThumbnailScrollView.trailingAnchor, constant: (window?.safeAreaInsets.left ?? 0)),
             pdfThumbnailView.widthAnchor.constraint(equalToConstant: thumbnailViewWidth)
         ])
         let contentViewCenterY = pdfThumbnailView.centerYAnchor.constraint(equalTo: pdfThumbnailScrollView.centerYAnchor)
@@ -199,7 +200,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         preferences.drawing.arrowPosition = .right
         preferences.drawing.cornerRadius = 10
 
-        preferences.positioning.bubbleInsets.right = UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0
+        preferences.positioning.bubbleInsets.right = window?.safeAreaInsets.right ?? 0
 
         preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
         preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
@@ -229,7 +230,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
         tipView?.dismiss()
         coordinator.animate(alongsideTransition: { context in
-            self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
+            self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (self.window?.safeAreaInsets.right ?? 0)
             self.pdfThumbnailScrollView.isHidden = true
         }, completion: { context in
             self.setConstraints()
@@ -410,7 +411,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
             self.tipView = nil
         }
         self.pdfThumbnailScrollView.isHidden = false
-        self.pdfThumbnailScrollViewWidthAnchor?.constant = thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
+        self.pdfThumbnailScrollViewWidthAnchor?.constant = thumbnailViewWidth + (window?.safeAreaInsets.right ?? 0)
         UIView.animate(withDuration: animateDuration, animations: {
             self.pdfThumbnailScrollViewTrailingAnchor?.constant = 0
             self.view.layoutIfNeeded()
@@ -421,7 +422,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
         if recognizer.state == .recognized && !self.pdfThumbnailScrollView.isHidden {
             UIView.animate(withDuration: animateDuration) {
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
+                self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (self.window?.safeAreaInsets.right ?? 0)
                 self.view.layoutIfNeeded()
             } completion: { _ in
                 self.pdfThumbnailScrollView.isHidden = true
@@ -433,7 +434,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
     func setConstraints() {
 
-        let widthThumbnail = thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
+        let widthThumbnail = thumbnailViewWidth + (window?.safeAreaInsets.right ?? 0)
 
         UIView.animate(withDuration: animateDuration, animations: {
             // Close