|
@@ -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
|