Pārlūkot izejas kodu

fix tip

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 gadi atpakaļ
vecāks
revīzija
a8dd100309

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

@@ -262,8 +262,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         self.collectionView?.collectionViewLayout.invalidateLayout()
         self.collectionView?.reloadData()
-
         self.tipView?.dismiss()
+        
         coordinator.animate(alongsideTransition: nil) { _ in
             self.showTip()
         }
@@ -633,7 +633,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     func showTip() {
 
-        if self is NCFiles, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account, self.serverUrl == NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account), let view = self.navigationItem.leftBarButtonItem?.customView {
+        if self is NCFiles, self.view.window != nil, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account, self.serverUrl == NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account), let view = self.navigationItem.leftBarButtonItem?.customView {
             if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest), NCManageDatabase.shared.getAllAccountOrderAlias().count > 0 {
                 self.tipView?.show(forView: view)
             }

+ 46 - 56
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -72,11 +72,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
         // PDF VIEW
 
-        if UIDevice.current.userInterfaceIdiom == .phone {
-            pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
-        } else {
-            pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: view.frame.width-thumbnailViewWidth, height: view.frame.height))
-        }
+        pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
         pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight, .flexibleTopMargin, .flexibleLeftMargin]
         pdfView.document = pdfDocument
         pdfView.autoScales = true
@@ -107,11 +103,8 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         pdfThumbnailView.layoutMode = .vertical
         pdfThumbnailView.thumbnailSize = CGSize(width: thumbnailViewHeight, height: thumbnailViewHeight)
         pdfThumbnailView.backgroundColor = .clear
-        if UIDevice.current.userInterfaceIdiom == .phone {
-            self.pdfThumbnailScrollView.isHidden = true
-        } else {
-            self.pdfThumbnailScrollView.isHidden = false
-        }
+
+        pdfThumbnailScrollView.isHidden = true
         pdfThumbnailScrollView.addSubview(pdfThumbnailView)
 
         NSLayoutConstraint.activate([
@@ -198,25 +191,22 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         NotificationCenter.default.addObserver(self, selector: #selector(handlePageChange), name: Notification.Name.PDFViewPageChanged, object: nil)
 
         // Tip
-        if UIDevice.current.userInterfaceIdiom == .phone && !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerPDFThumbnail){
-
-            var preferences = EasyTipView.Preferences()
-            preferences.drawing.foregroundColor = .white
-            preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
-            preferences.drawing.textAlignment = .left
-            preferences.drawing.arrowPosition = .right
-            preferences.drawing.cornerRadius = 10
+        var preferences = EasyTipView.Preferences()
+        preferences.drawing.foregroundColor = .white
+        preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
+        preferences.drawing.textAlignment = .left
+        preferences.drawing.arrowPosition = .right
+        preferences.drawing.cornerRadius = 10
 
-            preferences.positioning.bubbleInsets.right = UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0
+        preferences.positioning.bubbleInsets.right = UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0
 
-            preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
-            preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
-            preferences.animating.showInitialAlpha = 0
-            preferences.animating.showDuration = 1.5
-            preferences.animating.dismissDuration = 1.5
+        preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
+        preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
+        preferences.animating.showInitialAlpha = 0
+        preferences.animating.showDuration = 1.5
+        preferences.animating.dismissDuration = 1.5
 
-            tipView = EasyTipView(text: NSLocalizedString("_tip_pdf_thumbnails_", comment: ""), preferences: preferences, delegate: self)
-        }
+        tipView = EasyTipView(text: NSLocalizedString("_tip_pdf_thumbnails_", comment: ""), preferences: preferences, delegate: self)
 
         setConstraints()
         handlePageChange()
@@ -225,7 +215,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
 
-        self.tipView?.show(forView: self.pdfThumbnailScrollView, withinSuperview: self.view)
+        showTip()
     }
 
     @objc func viewUnload() {
@@ -236,15 +226,13 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
         super.viewWillTransition(to: size, with: coordinator)
 
+        tipView?.dismiss()
         coordinator.animate(alongsideTransition: { context in
-            if UIDevice.current.userInterfaceIdiom == .phone {
-                // Close
-                self.tipView?.dismiss()
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
-                self.pdfThumbnailScrollView.isHidden = true
-            }
+            self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
+            self.pdfThumbnailScrollView.isHidden = true
         }, completion: { context in
             self.setConstraints()
+            self.showTip()
         })
     }
 
@@ -263,6 +251,15 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         NotificationCenter.default.removeObserver(self, name: Notification.Name.PDFViewPageChanged, object: nil)
     }
 
+    // MARK: - Tip
+
+    func showTip() {
+
+        if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerPDFThumbnail) {
+            self.tipView?.show(forView: self.pdfThumbnailScrollView, withinSuperview: self.view)
+        }
+    }
+
     // MARK: - NotificationCenter
 
     @objc func uploadStartFile(_ notification: NSNotification) {
@@ -406,24 +403,22 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     @objc func gestureOpenPdfThumbnail(_ recognizer: UIScreenEdgePanGestureRecognizer) {
         guard let pdfDocument = pdfView.document, !pdfDocument.isLocked else { return }
 
-        if UIDevice.current.userInterfaceIdiom == .phone && self.pdfThumbnailScrollView.isHidden {
-            if let tipView = self.tipView {
-                tipView.dismiss()
-                NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerPDFThumbnail)
-                self.tipView = nil
-            }
-            self.pdfThumbnailScrollView.isHidden = false
-            self.pdfThumbnailScrollViewWidthAnchor?.constant = thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
-            UIView.animate(withDuration: animateDuration, animations: {
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = 0
-                self.view.layoutIfNeeded()
-            })
+        if let tipView = self.tipView {
+            tipView.dismiss()
+            NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerPDFThumbnail)
+            self.tipView = nil
         }
+        self.pdfThumbnailScrollView.isHidden = false
+        self.pdfThumbnailScrollViewWidthAnchor?.constant = thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
+        UIView.animate(withDuration: animateDuration, animations: {
+            self.pdfThumbnailScrollViewTrailingAnchor?.constant = 0
+            self.view.layoutIfNeeded()
+        })
     }
 
     @objc func gestureClosePdfThumbnail(_ recognizer: UIScreenEdgePanGestureRecognizer) {
 
-        if recognizer.state == .recognized && UIDevice.current.userInterfaceIdiom == .phone && !self.pdfThumbnailScrollView.isHidden {
+        if recognizer.state == .recognized && !self.pdfThumbnailScrollView.isHidden {
             UIView.animate(withDuration: animateDuration) {
                 self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
                 self.view.layoutIfNeeded()
@@ -440,16 +435,11 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         let widthThumbnail = thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
 
         UIView.animate(withDuration: animateDuration, animations: {
-            if UIDevice.current.userInterfaceIdiom == .phone {
-                // Close
-                self.pdfThumbnailScrollView.isHidden = true
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = widthThumbnail
-                self.pdfThumbnailScrollViewWidthAnchor?.constant = widthThumbnail
-            } else {
-                // Open
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = 0
-                self.pdfThumbnailScrollViewWidthAnchor?.constant = widthThumbnail
-            }
+            // Close
+            self.pdfThumbnailScrollView.isHidden = true
+            self.pdfThumbnailScrollViewTrailingAnchor?.constant = widthThumbnail
+            self.pdfThumbnailScrollViewWidthAnchor?.constant = widthThumbnail
+
             self.view.layoutIfNeeded()
             self.pdfView.autoScales = true
         })