|
@@ -75,20 +75,26 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate, UIGestureRecogni
|
|
|
|
|
|
// PDF VIEW
|
|
|
|
|
|
- if UIDevice.current.userInterfaceIdiom == .pad {
|
|
|
- pdfView = PDFView(frame: CGRect(x: thumbnailViewWidth, y: 0, width: view.frame.width - thumbnailViewWidth, height: view.frame.height))
|
|
|
- } else {
|
|
|
- pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
|
|
|
- }
|
|
|
- pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight, .flexibleTopMargin, .flexibleBottomMargin]
|
|
|
+ pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
|
|
|
+ pdfView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
pdfView.document = pdfDocument
|
|
|
pdfView.displayMode = .singlePageContinuous
|
|
|
- pdfView.autoScales = true
|
|
|
pdfView.displayDirection = .vertical
|
|
|
pdfView.maxScaleFactor = 4.0
|
|
|
pdfView.minScaleFactor = pdfView.scaleFactorForSizeToFit
|
|
|
view.addSubview(pdfView)
|
|
|
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
+ pdfView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
|
|
+ pdfView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
|
|
|
+ pdfView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
|
|
|
+ ])
|
|
|
+ if UIDevice.current.userInterfaceIdiom == .pad {
|
|
|
+ pdfView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: thumbnailViewWidth).isActive = true
|
|
|
+ } else {
|
|
|
+ pdfView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
|
|
|
+ }
|
|
|
+
|
|
|
// PDF THUMBNAIL
|
|
|
|
|
|
pdfThumbnailScrollView.translatesAutoresizingMaskIntoConstraints = false
|
|
@@ -98,7 +104,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate, UIGestureRecogni
|
|
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
pdfThumbnailScrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
|
|
- pdfThumbnailScrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
|
|
+ pdfThumbnailScrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
|
|
|
])
|
|
|
pdfThumbnailScrollViewleadingAnchor = pdfThumbnailScrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor)
|
|
|
pdfThumbnailScrollViewleadingAnchor?.isActive = true
|
|
@@ -127,7 +133,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate, UIGestureRecogni
|
|
|
pdfThumbnailViewleadingAnchor?.isActive = true
|
|
|
let contentViewCenterY = pdfThumbnailView.centerYAnchor.constraint(equalTo: pdfThumbnailScrollView.centerYAnchor)
|
|
|
contentViewCenterY.priority = .defaultLow
|
|
|
- let contentViewHeight = pdfThumbnailView.heightAnchor.constraint(equalToConstant: CGFloat(pageCount * thumbnailViewHeight) + CGFloat(pageCount * thumbnailPadding) + (thumbnailPadding * 2))
|
|
|
+ let contentViewHeight = pdfThumbnailView.heightAnchor.constraint(equalToConstant: CGFloat(pageCount * thumbnailViewHeight) + CGFloat(pageCount * thumbnailPadding) + 30)
|
|
|
contentViewHeight.priority = .defaultLow
|
|
|
NSLayoutConstraint.activate([
|
|
|
contentViewCenterY,
|
|
@@ -185,6 +191,10 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate, UIGestureRecogni
|
|
|
edgeLeftPdfView.edges = .left
|
|
|
pdfView.addGestureRecognizer(edgeLeftPdfView)
|
|
|
|
|
|
+ let edgeLeftView = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(gestureOpenPdfThumbnail))
|
|
|
+ edgeLeftView.edges = .left
|
|
|
+ view.addGestureRecognizer(edgeLeftView)
|
|
|
+
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(favoriteFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterFavoriteFile), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(deleteFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDeleteFile), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(renameFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterRenameFile), object: nil)
|
|
@@ -333,7 +343,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate, UIGestureRecogni
|
|
|
// MARK: - Action
|
|
|
|
|
|
@objc func openMenuMore() {
|
|
|
-
|
|
|
+
|
|
|
if imageIcon == nil { imageIcon = UIImage(named: "file_pdf") }
|
|
|
NCViewer.shared.toggleMenu(viewController: self, metadata: metadata, webView: false, imageIcon: imageIcon)
|
|
|
}
|