marinofaggiana před 3 roky
rodič
revize
8381eac05c

+ 25 - 0
iOSClient/Menu/NCViewer+Menu.swift

@@ -274,6 +274,31 @@ extension NCViewer {
                     }
                 )
             )
+            
+            var title = ""
+            var icon = UIImage()
+            
+            if CCUtility.getPDFDisplayDirection() == .horizontal {
+                title = NSLocalizedString("_pdf_vertical_", comment: "")
+                icon = UIImage(named: "pdf-vertical")!.image(color: NCBrandColor.shared.gray, size: 50)
+            } else {
+                title = NSLocalizedString("_pdf_horizontal_", comment: "")
+                icon = UIImage(named: "pdf-horizontal")!.image(color: NCBrandColor.shared.gray, size: 50)
+            }
+            
+            actions.append(
+                NCMenuAction(
+                    title: title,
+                    icon: icon,
+                    action: { menuAction in
+                        if CCUtility.getPDFDisplayDirection() == .horizontal {
+                            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuPDFDisplayDirection, userInfo: ["direction": PDFDisplayDirection.vertical])
+                        } else {
+                            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuPDFDisplayDirection, userInfo: ["direction": PDFDisplayDirection.horizontal])
+                        }
+                    }
+                )
+            )
         }
         
         //

+ 1 - 0
iOSClient/NCGlobal.swift

@@ -315,6 +315,7 @@ class NCGlobal: NSObject {
     let notificationCenterFavoriteFile                          = "favoriteFile"                    // userInfo: ocId
 
     let notificationCenterMenuSearchTextPDF                     = "menuSearchTextPDF"
+    let notificationCenterMenuPDFDisplayDirection               = "menuPDFDisplayDirection"         // userInfo: direction
     let notificationCenterMenuDetailClose                       = "menuDetailClose"
     
     let notificationCenterChangedLocation                       = "changedLocation"

+ 2 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -177,6 +177,8 @@
 "_certificate_installed_"   = "Certificate installed";
 "_want_delete_account_"     = "Do you want to delete the account %@";
 "_prevent_http_redirection_"= "The redirection in HTTP is not permitted";
+"_pdf_vertical_"            = "PDF vertical display";
+"_pdf_horizontal_"          = "PDF horizontal Display";
 
 /* Background of the file listing view */
 "_use_as_background_"       = "Use it as a background";

+ 10 - 0
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -128,6 +128,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
         NotificationCenter.default.addObserver(self, selector: #selector(viewUnload), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMenuDetailClose), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(searchText), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMenuSearchTextPDF), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(direction(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMenuPDFDisplayDirection), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(handlePageChange), name: Notification.Name.PDFViewPageChanged, object: nil)
         
         //
@@ -218,6 +219,15 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         }
     }
 
+    @objc func direction(_ notification: NSNotification) {
+        if let userInfo = notification.userInfo as NSDictionary? {
+            if let direction = userInfo["direction"] as? PDFDisplayDirection {
+                pdfView.displayDirection = direction
+                CCUtility.setPDFDisplayDirection(direction)
+            }
+        }
+    }
+    
     @objc func handlePageChange() {
         
         guard let curPage = pdfView.currentPage?.pageRef?.pageNumber else { pageView.alpha = 0; return }